Skip to content

Commit c108331

Browse files
authored
Merge pull request metabrainz#2221 from reosarevok/MBS-11839
MBS-11839: Convert Remove Relationship Attribute edit to React
2 parents cd6db28 + 9eb9ace commit c108331

File tree

6 files changed

+75
-12
lines changed

6 files changed

+75
-12
lines changed

lib/MusicBrainz/Server/Edit/Relationship/RemoveLinkAttribute.pm

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ with 'MusicBrainz::Server::Edit::Role::AlwaysAutoEdit';
1313
sub edit_name { N_l('Remove relationship attribute') }
1414
sub edit_kind { 'remove' }
1515
sub edit_type { $EDIT_RELATIONSHIP_REMOVE_LINK_ATTRIBUTE }
16+
sub edit_template_react { 'RemoveRelationshipAttribute' }
1617

1718
has '+data' => (
1819
isa => Dict[
@@ -24,6 +25,15 @@ has '+data' => (
2425
]
2526
);
2627

28+
sub build_display_data {
29+
my ($self, $loaded) = @_;
30+
31+
return {
32+
description => $self->data->{description},
33+
name => $self->data->{name},
34+
};
35+
}
36+
2737
sub accept {
2838
my $self = shift;
2939
$self->c->model('LinkAttributeType')->delete($self->data->{id})

root/edit/details/AddRelationshipType.js

-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ const AddRelationshipType = ({
102102
{rawIconSection}
103103
</>
104104
) : lp('(none)', 'description')}
105-
{}
106105
</td>
107106
</tr>
108107

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* @flow strict
3+
* Copyright (C) 2021 MetaBrainz Foundation
4+
*
5+
* This file is part of MusicBrainz, the open internet music database,
6+
* and is licensed under the GPL version 2, or (at your option) any
7+
* later version: http://www.gnu.org/licenses/gpl-2.0.txt
8+
*/
9+
10+
import * as React from 'react';
11+
12+
import IntentionallyRawIcon from '../components/IntentionallyRawIcon';
13+
14+
type RemoveRelationshipAttributeEditT = {
15+
...EditT,
16+
+display_data: {
17+
+description: string | null,
18+
+name: string,
19+
},
20+
};
21+
22+
type Props = {
23+
+edit: RemoveRelationshipAttributeEditT,
24+
};
25+
26+
const RemoveRelationshipAttribute = ({
27+
edit,
28+
}: Props): React.Element<'table'> => {
29+
const display = edit.display_data;
30+
31+
const rawIconSection = (
32+
<>
33+
{' '}
34+
<IntentionallyRawIcon />
35+
</>
36+
);
37+
38+
return (
39+
<table className="details remove-relationship-attribute">
40+
<tr>
41+
<th>{addColonText(l('Name'))}</th>
42+
<td>
43+
{display.name}
44+
{rawIconSection}
45+
</td>
46+
</tr>
47+
48+
<tr>
49+
<th>{addColonText(l('Description'))}</th>
50+
<td>
51+
{nonEmpty(display.description)
52+
? (
53+
<>
54+
{display.description}
55+
{rawIconSection}
56+
</>
57+
) : lp('(none)', 'description')}
58+
</td>
59+
</tr>
60+
</table>
61+
);
62+
};
63+
64+
export default RemoveRelationshipAttribute;

root/edit/details/RemoveRelationshipType.js

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ const RemoveRelationshipType = ({edit}: Props): React.Element<'table'> => {
7474
{rawIconSection}
7575
</>
7676
) : lp('(none)', 'description')}
77-
{}
7877
</td>
7978
</tr>
8079

root/edit/details/remove_relationship_attribute.tt

-10
This file was deleted.

root/server/components.js

+1
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ module.exports = {
395395
'edit/details/RemoveIswc': require('../edit/details/RemoveIswc'),
396396
'edit/details/RemoveMedium': require('../edit/details/RemoveMedium'),
397397
'edit/details/RemoveRelationship': require('../edit/details/RemoveRelationship'),
398+
'edit/details/RemoveRelationshipAttribute': require('../edit/details/RemoveRelationshipAttribute'),
398399
'edit/details/RemoveRelationshipType': require('../edit/details/RemoveRelationshipType'),
399400
'edit/details/RemoveReleaseLabel': require('../edit/details/RemoveReleaseLabel'),
400401
'edit/details/ReorderCoverArt': require('../edit/details/ReorderCoverArt'),

0 commit comments

Comments
 (0)