diff --git a/lib/MusicBrainz/Server/Constants.pm b/lib/MusicBrainz/Server/Constants.pm index 7140d9916d1..955b9c95ad1 100644 --- a/lib/MusicBrainz/Server/Constants.pm +++ b/lib/MusicBrainz/Server/Constants.pm @@ -70,7 +70,7 @@ our @EXPORT_OK = ( $ARTIST_ARTIST_COLLABORATION %PART_OF_SERIES $PART_OF_AREA_LINK_TYPE $PART_OF_AREA_LINK_TYPE_ID $SERIES_ORDERING_TYPE_AUTOMATIC $SERIES_ORDERING_TYPE_MANUAL - $SERIES_ORDERING_ATTRIBUTE + $SERIES_ORDERING_ATTRIBUTE $LABEL_RENAME_LINK_TYPE $MAX_INITIAL_MEDIUMS $MAX_INITIAL_TRACKS $MAX_POSTGRES_INT $MAX_POSTGRES_BIGINT @FULL_TABLE_LIST @@ -405,6 +405,8 @@ Readonly our $PART_OF_AREA_LINK_TYPE => 'de7cc874-8b1b-3a05-8272-f3834c968fb7'; Readonly our $PART_OF_AREA_LINK_TYPE_ID => 356; +Readonly our $LABEL_RENAME_LINK_TYPE => 'e6159066-6013-4d09-a2f8-bc473f21e89e'; + Readonly our $MAX_INITIAL_MEDIUMS => 10; Readonly our $MAX_INITIAL_TRACKS => 100; diff --git a/lib/MusicBrainz/Server/Controller/Label.pm b/lib/MusicBrainz/Server/Controller/Label.pm index f7d213f12d2..649b6053ccb 100644 --- a/lib/MusicBrainz/Server/Controller/Label.pm +++ b/lib/MusicBrainz/Server/Controller/Label.pm @@ -10,7 +10,7 @@ with 'MusicBrainz::Server::Controller::Role::Load' => { cardinal => ['edit'], default => ['url'], subset => { - show => ['artist', 'url'], + show => ['artist', 'label', 'url'], relationships => [qw( area artist event instrument label place series url )], }, paged_subset => { @@ -40,7 +40,15 @@ with 'MusicBrainz::Server::Controller::Role::Collection' => { entity_type => 'label' }; -use MusicBrainz::Server::Constants qw( $DLABEL_ID $EDIT_LABEL_CREATE $EDIT_LABEL_DELETE $EDIT_LABEL_EDIT $EDIT_LABEL_MERGE ); +use MusicBrainz::Server::Constants qw( + $DLABEL_ID + $EDIT_LABEL_CREATE + $EDIT_LABEL_DELETE + $EDIT_LABEL_EDIT + $EDIT_LABEL_MERGE + $LABEL_RENAME_LINK_TYPE + :direction +); use MusicBrainz::Server::ControllerUtils::JSON qw( serialize_pager ); use Data::Page; use MusicBrainz::Server::Data::Utils qw( is_special_label ); @@ -112,8 +120,10 @@ sub show : PathPart('') Chained('load') { my ($self, $c) = @_; + my $label = $c->stash->{label}; + my $releases = $self->_load_paged($c, sub { - $c->model('Release')->find_by_label($c->stash->{label}->id, shift, shift); + $c->model('Release')->find_by_label($label->id, shift, shift); }); $c->model('ArtistCredit')->load(@$releases); @@ -123,11 +133,32 @@ sub show : PathPart('') Chained('load') $c->model('MediumFormat')->load(map { $_->all_mediums } @$releases); $c->model('ReleaseLabel')->load(@$releases); + my (@renamed_from, @renamed_into); + + for my $rel (@{ $label->relationships }) { + if ($rel->link->type->gid eq $LABEL_RENAME_LINK_TYPE) { + if ($rel->direction == $DIRECTION_FORWARD) { + push @renamed_into, $rel->target; + } else { + push @renamed_from, $rel->target; + } + } + } + + if (@renamed_from || @renamed_into) { + $c->model('Relationship')->load_subset( + ['label'], + @renamed_from, @renamed_into, + ); + } + my %props = ( - label => $c->stash->{label}->TO_JSON, + label => $label->TO_JSON, numberOfRevisions => $c->stash->{number_of_revisions}, pager => serialize_pager($c->stash->{pager}), releases => to_json_array($releases), + renamedFrom => to_json_array(\@renamed_from), + renamedInto => to_json_array(\@renamed_into), wikipediaExtract => to_json_object($c->stash->{wikipedia_extract}), ); diff --git a/root/artist/ArtistIndex.js b/root/artist/ArtistIndex.js index 09ba90c4d9a..d7984025788 100644 --- a/root/artist/ArtistIndex.js +++ b/root/artist/ArtistIndex.js @@ -17,7 +17,6 @@ import {type FilterFormT} from '../static/scripts/common/components/FilterForm'; import WikipediaExtract from '../static/scripts/common/components/WikipediaExtract'; -import {addColonText} from '../static/scripts/common/i18n/addColon'; import commaOnlyList, {commaOnlyListText} from '../static/scripts/common/i18n/commaOnlyList'; import {bracketedText} from '../static/scripts/common/utility/bracketed'; @@ -25,25 +24,13 @@ import FormSubmit from '../components/FormSubmit'; import RecordingList from '../components/list/RecordingList'; import ReleaseGroupList from '../components/list/ReleaseGroupList'; import PaginatedResults from '../components/PaginatedResults'; +import RelatedEntitiesDisplay from '../components/RelatedEntitiesDisplay'; import * as manifest from '../static/manifest'; import entityHref from '../static/scripts/common/utility/entityHref'; import {returnToCurrentPage} from '../utility/returnUri'; import ArtistLayout from './ArtistLayout'; -type RelatedArtistsProps = { - +children: React$Node, - +title: string, -}; - -const RelatedArtists = ({children, title}: RelatedArtistsProps) => ( -

- {addColonText(title)} - {' '} - {children} -

-); - type FooterSwitchProps = { +artist: ArtistT, +hasDefault: boolean, @@ -244,27 +231,27 @@ const ArtistIndex = ({ /> {legalName ? ( - + {legalNameArtistAliases ? ' ' + bracketedText(commaOnlyListText(legalNameArtistAliases)) : null} - + ) : legalNameAliases?.length ? ( - + {commaOnlyListText(legalNameAliases)} - + ) : null} {otherIdentities?.length ? ( - + {commaOnlyList( otherIdentities.map(a => ( )), )} - + ) : null} => ( +

+ {addColonText(title)} + {' '} + {children} +

+); + +export default RelatedEntitiesDisplay; diff --git a/root/label/LabelIndex.js b/root/label/LabelIndex.js index 6ef4f51f4f2..189ef0773a0 100644 --- a/root/label/LabelIndex.js +++ b/root/label/LabelIndex.js @@ -13,9 +13,13 @@ import CleanupBanner from '../components/CleanupBanner'; import FormRow from '../components/FormRow'; import FormSubmit from '../components/FormSubmit'; import PaginatedResults from '../components/PaginatedResults'; +import DescriptiveLink + from '../static/scripts/common/components/DescriptiveLink'; import WikipediaExtract from '../static/scripts/common/components/WikipediaExtract'; +import commaOnlyList from '../static/scripts/common/i18n/commaOnlyList'; import ReleaseList from '../components/list/ReleaseList'; +import RelatedEntitiesDisplay from '../components/RelatedEntitiesDisplay'; import * as manifest from '../static/manifest'; import Annotation from '../static/scripts/common/components/Annotation'; import {returnToCurrentPage} from '../utility/returnUri'; @@ -29,6 +33,8 @@ type Props = { +numberOfRevisions: number, +pager: PagerT, +releases: ?$ReadOnlyArray, + +renamedFrom: $ReadOnlyArray, + +renamedInto: $ReadOnlyArray, +wikipediaExtract: WikipediaExtractT | null, }; @@ -39,6 +45,8 @@ const LabelIndex = ({ numberOfRevisions, pager, releases, + renamedFrom, + renamedInto, wikipediaExtract, }: Props): React.Element => ( @@ -51,6 +59,20 @@ const LabelIndex = ({ entity={label} numberOfRevisions={numberOfRevisions} /> + {renamedFrom.length ? ( + + {commaOnlyList(renamedFrom.map( + label => , + ))} + + ) : null} + {renamedInto.length ? ( + + {commaOnlyList(renamedInto.map( + label => , + ))} + + ) : null}