Skip to content

Commit e25ed28

Browse files
committed
Merge branch 'master' into beta
* master: Update POT files using the production database Update translations from Transifex MBS-11513: Use React.useContext in reports Output work recordings sitemaps Simplify the user tag pages UI Add link back to UserTag from UserTagEntity More specific headers / texts depending on entity type MBS-10690: Convert user/tags.tt to React MBS-1870 / MBS-8477 / MBS-10341: User tag page improvements MBS-11429: Don't error on existing but now blocked links MBS-11432: Allow also linking places and works to Operabase MBS-11454: Don't consider hasTooEarlyFormat a blocking error MBS-11485: Allow irc(s):// links on expand2react MBS-11503: Block smart links: trac.co MBS-11508: Move Qobuz favicon to external-favicons MBS-11506 - Redirect 'data' link on home page MBS-10726 (II): Also do disc -> medium in backend MBS-1178: Relationships table paging Move DIRECTION_ constants to Constants.pm Don't sort arbitrary link types by child_order Improve wording for DisambiguationSameName Make reports use ReportLayout (XII: Releases III) Make reports use ReportLayout (XI: Releases II) Make reports use ReportLayout (X: Releases I) Make reports use ReportLayout (IX: RGs) Make reports use ReportLayout (VIII: Labels / Editors / Events / Places) Make reports use ReportLayout (VII: Recordings) Make reports use ReportLayout (VI: Instruments/ISRCs/ISWCs) Make reports use ReportLayout (V: Discogs links) Make reports use ReportLayout (IV: Artists) Make reports use ReportLayout (III: Duplicate rels) Make reports use ReportLayout (II: Deprecated rels) Make reports use ReportLayout (I: Annotation) Add reusable ReportLayout component MBS-10726: Use "medium", not "disc", as a generic term in RE buttons Bump Flow to 0.147.0 MBS-11217: Only show instrument reports to relationship editors Refactor ReportsIndex to reuse component for each entry
2 parents ef96130 + a632e0a commit e25ed28

File tree

182 files changed

+5302
-5347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+5302
-5347
lines changed

lib/MusicBrainz/Server/Constants.pm

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ sub _get
2525
}
2626

2727
our %EXPORT_TAGS = (
28+
direction => _get(qr/^DIRECTION_/),
2829
edit_type => _get(qr/^EDIT_/),
2930
expire_action => _get(qr/^EXPIRE_/),
3031
quality => _get(qr/^QUALITY_/),
@@ -104,6 +105,9 @@ Readonly our $VARTIST_ID => 1;
104105
Readonly our $NOLABEL_GID => '157afde4-4bf5-4039-8ad2-5a15acc85176';
105106
Readonly our $NOLABEL_ID => 3267;
106107

108+
Readonly our $DIRECTION_FORWARD => 1;
109+
Readonly our $DIRECTION_BACKWARD => 2;
110+
107111
Readonly our $EXPIRE_ACCEPT => 1;
108112
Readonly our $EXPIRE_REJECT => 2;
109113

lib/MusicBrainz/Server/Controller/Area.pm

+37-9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ with 'MusicBrainz::Server::Controller::Role::Load' => {
99
cardinal => ['edit'],
1010
subset => {
1111
show => [qw( area artist label place series instrument release_group url )],
12+
},
13+
paged_subset => {
1214
recordings => ['recording'],
1315
releases => ['release'],
1416
works => ['work'],
@@ -214,17 +216,27 @@ sub releases : Chained('load')
214216
{
215217
my ($self, $c) = @_;
216218

217-
my $releases = $self->_load_paged($c, sub {
218-
$c->model('Release')->find_by_country($c->stash->{area}->id, shift, shift);
219+
my $stash = $c->stash;
220+
my $paged_link_type_group = $stash->{paged_link_type_group};
221+
my $releases;
222+
223+
unless ($paged_link_type_group) {
224+
$releases = $self->_load_paged($c, sub {
225+
$c->model('Release')->find_by_country($stash->{area}->id, shift, shift);
219226
});
227+
$c->model('ArtistCredit')->load(@$releases);
228+
$c->model('Release')->load_related_info(@$releases);
229+
}
220230

221-
$c->model('ArtistCredit')->load(@$releases);
222-
$c->model('Release')->load_related_info(@$releases);
231+
my $pager = defined $stash->{pager}
232+
? serialize_pager($stash->{pager})
233+
: undef;
223234

224235
my %props = (
225-
area => $c->stash->{area}->TO_JSON,
226-
releases => to_json_array($releases),
227-
pager => serialize_pager($c->stash->{pager}),
236+
area => $stash->{area}->TO_JSON,
237+
releases => to_json_array($releases),
238+
pagedLinkTypeGroup => to_json_object($paged_link_type_group),
239+
pager => $pager,
228240
);
229241

230242
$c->stash(
@@ -310,9 +322,17 @@ Shows recordings related to this area.
310322
sub recordings : Chained('load') {
311323
my ($self, $c) = @_;
312324

325+
my $stash = $c->stash;
326+
my $pager = defined $stash->{pager}
327+
? serialize_pager($stash->{pager})
328+
: undef;
313329
$c->stash(
314330
component_path => 'area/AreaRecordings',
315-
component_props => { area => $c->stash->{area}->TO_JSON },
331+
component_props => {
332+
area => $stash->{area}->TO_JSON,
333+
pagedLinkTypeGroup => to_json_object($stash->{paged_link_type_group}),
334+
pager => $pager,
335+
},
316336
current_view => 'Node',
317337
);
318338
}
@@ -326,9 +346,17 @@ Shows works related to this area.
326346
sub works : Chained('load') {
327347
my ($self, $c) = @_;
328348

349+
my $stash = $c->stash;
350+
my $pager = defined $stash->{pager}
351+
? serialize_pager($stash->{pager})
352+
: undef;
329353
$c->stash(
330354
component_path => 'area/AreaWorks',
331-
component_props => { area => $c->stash->{area}->TO_JSON },
355+
component_props => {
356+
area => $stash->{area}->TO_JSON,
357+
pagedLinkTypeGroup => to_json_object($stash->{paged_link_type_group}),
358+
pager => $pager,
359+
},
332360
current_view => 'Node',
333361
);
334362
}

lib/MusicBrainz/Server/Controller/Artist.pm

+21-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ BEGIN { extends 'MusicBrainz::Server::Controller'; }
99
with 'MusicBrainz::Server::Controller::Role::Load' => {
1010
model => 'Artist',
1111
relationships => {
12-
all => ['relationships'],
1312
cardinal => ['edit'],
14-
subset => { split => ['artist'], show => ['artist', 'url'] },
15-
default => ['url']
13+
subset => {
14+
split => ['artist'],
15+
show => ['artist', 'url'],
16+
relationships => [qw( area artist event instrument label place series url )],
17+
},
18+
default => ['url'],
19+
paged_subset => {
20+
relationships => [qw( recording release release_group work )],
21+
},
1622
},
1723
};
1824
with 'MusicBrainz::Server::Controller::Role::LoadWithRowID';
@@ -50,6 +56,7 @@ use MusicBrainz::Server::Data::Utils qw(
5056
is_special_artist
5157
);
5258
use MusicBrainz::Server::Constants qw(
59+
:direction
5360
$DARTIST_ID
5461
$EDITOR_MODBOT
5562
$EDIT_ARTIST_MERGE
@@ -261,7 +268,7 @@ sub show : PathPart('') Chained('load')
261268
my $legal_name_artist_aliases;
262269
my $legal_name_aliases;
263270
my ($legal_name) = map { $_->target }
264-
grep { $_->direction == $MusicBrainz::Server::Entity::Relationship::DIRECTION_BACKWARD }
271+
grep { $_->direction == $DIRECTION_BACKWARD }
265272
grep { $_->link->type->gid eq 'dd9886f2-1dfe-4270-97db-283f6839a666' } @{ $artist->relationships };
266273
if (defined $legal_name) {
267274
$c->model('Relationship')->load_subset(['artist'], $legal_name);
@@ -293,7 +300,7 @@ sub show : PathPart('') Chained('load')
293300
grep { $_->id != $artist->id }
294301
uniq
295302
map { $_->target }
296-
grep { $_->direction == $MusicBrainz::Server::Entity::Relationship::DIRECTION_FORWARD }
303+
grep { $_->direction == $DIRECTION_FORWARD }
297304
grep { $_->link->type->gid eq 'dd9886f2-1dfe-4270-97db-283f6839a666' }
298305
@{ ($legal_name // $artist)->relationships };
299306
push(@identities, @other_identities);
@@ -330,9 +337,17 @@ sub show : PathPart('') Chained('load')
330337
sub relationships : Chained('load') PathPart('relationships') {
331338
my ($self, $c) = @_;
332339

340+
my $stash = $c->stash;
341+
my $pager = defined $stash->{pager}
342+
? serialize_pager($stash->{pager})
343+
: undef;
333344
$c->stash(
334345
component_path => 'artist/ArtistRelationships',
335-
component_props => { artist => $c->stash->{artist}->TO_JSON },
346+
component_props => {
347+
artist => $stash->{artist}->TO_JSON,
348+
pagedLinkTypeGroup => to_json_object($stash->{paged_link_type_group}),
349+
pager => $pager,
350+
},
336351
current_view => 'Node',
337352
);
338353
}

lib/MusicBrainz/Server/Controller/Label.pm

+16-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ with 'MusicBrainz::Server::Controller::Role::Load' => {
77
model => 'Label',
88
entity_name => 'label',
99
relationships => {
10-
all => ['relationships'],
1110
cardinal => ['edit'],
1211
default => ['url'],
13-
subset => { show => ['artist', 'url'] }
12+
subset => {
13+
show => ['artist', 'url'],
14+
relationships => [qw( area artist event instrument label place series url )],
15+
},
16+
paged_subset => {
17+
relationships => [qw( recording release release_group work )],
18+
},
1419
},
1520
};
1621
with 'MusicBrainz::Server::Controller::Role::LoadWithRowID';
@@ -137,9 +142,17 @@ sub show : PathPart('') Chained('load')
137142
sub relationships : Chained('load') PathPart('relationships') {
138143
my ($self, $c) = @_;
139144

145+
my $stash = $c->stash;
146+
my $pager = defined $stash->{pager}
147+
? serialize_pager($stash->{pager})
148+
: undef;
140149
$c->stash(
141150
component_path => 'label/LabelRelationships',
142-
component_props => {label => $c->stash->{label}->TO_JSON},
151+
component_props => {
152+
label => $stash->{label}->TO_JSON,
153+
pagedLinkTypeGroup => to_json_object($stash->{paged_link_type_group}),
154+
pager => $pager,
155+
},
143156
current_view => 'Node',
144157
);
145158
}

lib/MusicBrainz/Server/Controller/Place.pm

+16-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ with 'MusicBrainz::Server::Controller::Role::Load' => {
1010
default => ['url'],
1111
subset => {
1212
show => [qw( area artist label place url work series instrument )],
13-
performances => [qw( release release_group recording work url )],
14-
}
13+
performances => [qw( url )],
14+
},
15+
paged_subset => {
16+
performances => [qw( recording release release_group work )],
17+
},
1518
},
1619
};
1720
with 'MusicBrainz::Server::Controller::Role::LoadWithRowID';
@@ -140,10 +143,18 @@ Shows performances linked to a place.
140143
sub performances : Chained('load') {
141144
my ($self, $c) = @_;
142145

146+
my $stash = $c->stash;
147+
my $pager = defined $stash->{pager}
148+
? serialize_pager($stash->{pager})
149+
: undef;
143150
$c->stash(
144-
component_path => 'place/PlacePerformances',
145-
component_props => {place => $c->stash->{place}->TO_JSON},
146-
current_view => 'Node',
151+
component_path => 'place/PlacePerformances',
152+
component_props => {
153+
place => $stash->{place}->TO_JSON,
154+
pagedLinkTypeGroup => to_json_object($stash->{paged_link_type_group}),
155+
pager => $pager,
156+
},
157+
current_view => 'Node',
147158
);
148159
}
149160

lib/MusicBrainz/Server/Controller/Relationship/LinkType.pm

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use List::UtilsBy qw( partition_by sort_by );
88
use MusicBrainz::Server::Data::Relationship;
99
use MusicBrainz::Server::Data::Utils qw( partial_date_to_hash type_to_model );
1010
use MusicBrainz::Server::Constants qw(
11+
:direction
1112
$EDIT_RELATIONSHIP_ADD_TYPE
1213
$EDIT_RELATIONSHIP_EDIT_LINK_TYPE
1314
$EDIT_RELATIONSHIP_REMOVE_LINK_TYPE
@@ -237,7 +238,7 @@ sub edit : Chained('load') RequireAuth(relationship_editor)
237238

238239
# We have to store relationships in the forward direction.
239240
my ($e0, $e1) =
240-
$relationship->direction == $MusicBrainz::Server::Entity::Relationship::DIRECTION_FORWARD
241+
$relationship->direction == $DIRECTION_FORWARD
241242
? ($relationship->entity0, $relationship->entity1)
242243
: ($relationship->entity1, $relationship->entity0);
243244

lib/MusicBrainz/Server/Controller/Role/Load.pm

+65-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package MusicBrainz::Server::Controller::Role::Load;
2+
23
use MooseX::MethodAttributes::Role;
34
use MooseX::Role::Parameterized;
45
use MusicBrainz::Server::Data::Utils 'model_to_type';
56
use MusicBrainz::Server::Validation qw( is_guid is_positive_integer );
6-
use MusicBrainz::Server::Constants qw( %ENTITIES );
7+
use MusicBrainz::Server::Constants qw( :direction %ENTITIES );
8+
use Readonly;
79

810
no if $] >= 5.018, warnings => "experimental::smartmatch";
911

@@ -33,6 +35,8 @@ parameter 'allow_integer_ids' => (
3335
default => sub { 1 },
3436
);
3537

38+
Readonly our $RELATIONSHIP_PAGE_SIZE => 100;
39+
3640
role
3741
{
3842
my $params = shift;
@@ -66,14 +70,72 @@ role
6670
if (exists $entity_properties->{mbid} && $entity_properties->{mbid}{relatable}) {
6771
my $action = $c->action->name;
6872
my $relationships = $params->relationships;
73+
my $loaded = 0;
6974

7075
if ($action ~~ $relationships->{all}) {
7176
$c->model('Relationship')->load($entity);
77+
$loaded = 1;
7278
} elsif ($action ~~ $relationships->{cardinal}) {
7379
$c->model('Relationship')->load_cardinal($entity);
74-
} else {
75-
my $types = $relationships->{subset}->{$action} // $relationships->{default};
80+
$loaded = 1;
81+
}
82+
83+
my $paged_types = $relationships->{paged_subset}{$action};
84+
if ($paged_types) {
85+
my $params = $c->req->query_params;
86+
my $link_type_id = $params->{link_type_id};
87+
my $pager;
88+
my %opts;
89+
90+
if (is_positive_integer($link_type_id)) {
91+
$opts{link_type_id} = $link_type_id;
92+
$opts{limit} = $RELATIONSHIP_PAGE_SIZE;
93+
94+
my $direction = $params->{direction};
95+
if (
96+
is_positive_integer($direction) &&
97+
($direction == $DIRECTION_FORWARD ||
98+
$direction == $DIRECTION_BACKWARD)
99+
) {
100+
$opts{direction} = $direction;
101+
}
102+
103+
my $page = is_positive_integer($params->{page})
104+
? $params->{page} : 1;
105+
$opts{offset} = ($page - 1) * $RELATIONSHIP_PAGE_SIZE;
106+
107+
$pager = Data::Page->new;
108+
$pager->entries_per_page($RELATIONSHIP_PAGE_SIZE);
109+
$pager->current_page($page);
110+
}
76111

112+
my $lt_groups = $c->model('Relationship')->load_paged(
113+
$entity,
114+
$paged_types,
115+
%opts,
116+
);
117+
118+
if (defined $pager) {
119+
if (!scalar @$lt_groups) {
120+
$c->detach('/error_400');
121+
}
122+
if (scalar @$lt_groups > 1) {
123+
die 'Expected only one link type group';
124+
}
125+
my $lt_group = $lt_groups->[0];
126+
$pager->total_entries($lt_group->total_relationships);
127+
$c->stash->{pager} = $pager;
128+
$c->stash->{paged_link_type_group} = $lt_group;
129+
}
130+
131+
$loaded = 1;
132+
}
133+
134+
unless (defined $c->stash->{paged_link_type_group}) {
135+
my $types = $relationships->{subset}{$action};
136+
if (!defined $types && !$loaded) {
137+
$types = $relationships->{default};
138+
}
77139
if ($types) {
78140
$c->model('Relationship')->load_subset($types, $entity);
79141
}

0 commit comments

Comments
 (0)