Skip to content

Commit

Permalink
MBS-10793: Convert historic Move Release edit to React
Browse files Browse the repository at this point in the history
Changes from the TT:

Actually attempt to link the artists if possible, rather than just
printing their names. That might be because a fair amount of them
have their IDs missing (one example had Metallica with an ID of 0)
but we should still try to link them where we can.

Additionally, this actually tries to pass move_tracks to the template -
it was trying to load it from display_data but AFAICT it wasn't
being added to display_data at all. Not sure if it's ever not false,
but just in case.
  • Loading branch information
reosarevok committed Apr 28, 2020
1 parent 1572bcb commit ccc707d
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 27 deletions.
14 changes: 10 additions & 4 deletions lib/MusicBrainz/Server/Edit/Historic/MoveRelease.pm
Expand Up @@ -3,6 +3,7 @@ use strict;
use warnings;

use MusicBrainz::Server::Constants qw( $EDIT_HISTORIC_MOVE_RELEASE );
use MusicBrainz::Server::Data::Utils qw( boolean_to_json );
use MusicBrainz::Server::Translation qw( N_l );

use aliased 'MusicBrainz::Server::Entity::Artist';
Expand All @@ -13,7 +14,7 @@ sub edit_name { N_l('Edit release') }
sub edit_kind { 'edit' }
sub historic_type { 8 }
sub edit_type { $EDIT_HISTORIC_MOVE_RELEASE }
sub edit_template { 'historic/move_release' }
sub edit_template_react { 'historic/MoveRelease' }

sub _build_related_entities
{
Expand Down Expand Up @@ -52,14 +53,18 @@ sub build_display_data
$loaded->{Artist}->{ $self->data->{artist_id} },
name => $self->data->{artist_name},
)
: Artist->new( name => $self->data->{artist_name} );
: Artist->new(
id => $self->data->{artist_id},
name => $self->data->{artist_name} );

my $old_artist = defined $loaded->{Artist}->{ $self->data->{old_artist_id} }
? Artist->meta->clone_object(
$loaded->{Artist}->{ $self->data->{old_artist_id} },
name => $self->data->{old_artist_name},
)
: Artist->new( name => $self->data->{old_artist_name} );
: Artist->new(
id => $self->data->{old_artist_id},
name => $self->data->{old_artist_name} );

return {
releases => [
Expand All @@ -70,7 +75,8 @@ sub build_display_data
artist => {
new => $new_artist,
old => $old_artist
}
},
move_tracks => boolean_to_json($self->data->{move_tracks}),
}
}

Expand Down
48 changes: 48 additions & 0 deletions root/edit/details/historic/MoveRelease.js
@@ -0,0 +1,48 @@
/*
* @flow
* 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';

import HistoricReleaseList from '../../components/HistoricReleaseList';
import DescriptiveLink
from '../../../static/scripts/common/components/DescriptiveLink';
import yesNo from '../../../static/scripts/common/utility/yesNo';

type ChangeReleaseArtistT = {
...EditT,
+display_data: {
+artist: CompT<ArtistT>,
+move_tracks?: boolean,
+releases: $ReadOnlyArray<ReleaseT>,
},
};

const ChangeReleaseArtist = ({edit}: {+edit: ChangeReleaseArtistT}) => (
<table className="details edit-release">
<HistoricReleaseList
colSpan="2"
releases={edit.display_data.releases}
/>
<tr>
<th>{l('Change track artists:')}</th>
<td colSpan="2">{yesNo(edit.display_data.move_tracks)}</td>
</tr>
<tr>
<th>{l('Artist:')}</th>
<td className="old">
<DescriptiveLink entity={edit.display_data.artist.old} />
</td>
<td className="new">
<DescriptiveLink entity={edit.display_data.artist.new} />
</td>
</tr>
</table>
);

export default ChangeReleaseArtist;
23 changes: 0 additions & 23 deletions root/edit/details/historic/move_release.tt

This file was deleted.

1 change: 1 addition & 0 deletions root/server/components.js
Expand Up @@ -289,6 +289,7 @@ module.exports = {
'edit/details/historic/ChangeReleaseQuality': require('../edit/details/historic/ChangeReleaseQuality'),
'edit/details/historic/MergeReleases': require('../edit/details/historic/MergeReleases'),
'edit/details/historic/MoveDiscId': require('../edit/details/historic/MoveDiscId'),
'edit/details/historic/MoveRelease': require('../edit/details/historic/MoveRelease'),
'edit/details/historic/RemoveDiscId': require('../edit/details/historic/RemoveDiscId'),
'edit/details/historic/RemoveLabelAlias': require('../edit/details/historic/RemoveLabelAlias'),
'edit/details/historic/RemovePuid': require('../edit/details/historic/RemovePuid'),
Expand Down

0 comments on commit ccc707d

Please sign in to comment.