Skip to content

Commit

Permalink
MBS-10910: Display renamed from/to on label overview
Browse files Browse the repository at this point in the history
This seems like a sensible way to follow the flow of labels that
were renamed, and I see no negatives about showing them there.
I saw artist legal name is treated as only ever one result (which
seems weird to me, but that's a separate issue). Because a label
could be listed as renamed from or to multiple others, I pass these
as arrays. I expect in most cases these would be data errors, but having
them be visible makes them more likely to get fixed anyway.
  • Loading branch information
reosarevok committed Aug 19, 2021
1 parent cfe6812 commit 0bc24bf
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 25 deletions.
4 changes: 3 additions & 1 deletion lib/MusicBrainz/Server/Constants.pm
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
39 changes: 35 additions & 4 deletions lib/MusicBrainz/Server/Controller/Label.pm
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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);
Expand All @@ -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}),
);

Expand Down
27 changes: 7 additions & 20 deletions root/artist/ArtistIndex.js
Expand Up @@ -17,33 +17,20 @@ 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';
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) => (
<p>
<strong>{addColonText(title)}</strong>
{' '}
{children}
</p>
);

type FooterSwitchProps = {
+artist: ArtistT,
+hasDefault: boolean,
Expand Down Expand Up @@ -244,27 +231,27 @@ const ArtistIndex = ({
/>

{legalName ? (
<RelatedArtists title={l('Legal name')}>
<RelatedEntitiesDisplay title={l('Legal name')}>
<DescriptiveLink entity={legalName} />
{legalNameArtistAliases
? ' ' + bracketedText(commaOnlyListText(legalNameArtistAliases))
: null}
</RelatedArtists>
</RelatedEntitiesDisplay>

) : legalNameAliases?.length ? (
<RelatedArtists title={l('Legal name')}>
<RelatedEntitiesDisplay title={l('Legal name')}>
{commaOnlyListText(legalNameAliases)}
</RelatedArtists>
</RelatedEntitiesDisplay>
) : null}

{otherIdentities?.length ? (
<RelatedArtists title={l('Also performs as')}>
<RelatedEntitiesDisplay title={l('Also performs as')}>
{commaOnlyList(
otherIdentities.map(a => (
<DescriptiveLink entity={a} key={a.id} />
)),
)}
</RelatedArtists>
</RelatedEntitiesDisplay>
) : null}

<WikipediaExtract
Expand Down
27 changes: 27 additions & 0 deletions root/components/RelatedEntitiesDisplay.js
@@ -0,0 +1,27 @@
/*
* @flow strict
* Copyright (C) 2020 MetaBrainz Foundation
*
* This file is part of MusicBrainz, the open internet music database,
* and is licensed under the GPL version 2, or (at your option) any
* later version: http://www.gnu.org/licenses/gpl-2.0.txt
*/

import * as React from 'react';

type Props = {
+children: React$Node,
+title: string,
};

const RelatedEntitiesDisplay = (
{children, title}: Props,
): React.Element<'p'> => (
<p>
<strong>{addColonText(title)}</strong>
{' '}
{children}
</p>
);

export default RelatedEntitiesDisplay;
22 changes: 22 additions & 0 deletions root/label/LabelIndex.js
Expand Up @@ -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';
Expand All @@ -29,6 +33,8 @@ type Props = {
+numberOfRevisions: number,
+pager: PagerT,
+releases: ?$ReadOnlyArray<ReleaseT>,
+renamedFrom: $ReadOnlyArray<LabelT>,
+renamedInto: $ReadOnlyArray<LabelT>,
+wikipediaExtract: WikipediaExtractT | null,
};

Expand All @@ -39,6 +45,8 @@ const LabelIndex = ({
numberOfRevisions,
pager,
releases,
renamedFrom,
renamedInto,
wikipediaExtract,
}: Props): React.Element<typeof LabelLayout> => (
<LabelLayout entity={label} page="index">
Expand All @@ -51,6 +59,20 @@ const LabelIndex = ({
entity={label}
numberOfRevisions={numberOfRevisions}
/>
{renamedFrom.length ? (
<RelatedEntitiesDisplay title={l('Previously known as')}>
{commaOnlyList(renamedFrom.map(
label => <DescriptiveLink entity={label} key={label.gid} />,
))}
</RelatedEntitiesDisplay>
) : null}
{renamedInto.length ? (
<RelatedEntitiesDisplay title={l('Renamed to')}>
{commaOnlyList(renamedInto.map(
label => <DescriptiveLink entity={label} key={label.gid} />,
))}
</RelatedEntitiesDisplay>
) : null}
<WikipediaExtract
cachedWikipediaExtract={wikipediaExtract}
entity={label}
Expand Down

0 comments on commit 0bc24bf

Please sign in to comment.