Skip to content

Commit

Permalink
Merge branch 'master' into beta
Browse files Browse the repository at this point in the history
* master:
  Update POT files using the production database
  Update stylistic to 2.12.0
  Update eslint to 9.16.0
  Update stylistic to 2.11.0
  Update stylistic to 2.10.1
  Update eslint to 9.15.0
  Update to eslint 9.14.0
  Update eslint-plugin-react to 7.37.2
  Update to eslint 9.13.0
  Update eslint-plugin-react-hooks to 5.0.0
  List and disable TS @Stylistic rules
  List and disable @stylistic/indent-binary-ops
  Add new @stylistic/curly-newline rule
  Group all @Stylistic rules
  Update @stylistic/eslint to 2.9.0
  Update rules as per eslint 9.12.0
  Update to eslint 9.12.0
  Update eslint-plugin-react to 7.37.1
  Restore now working no-named-as-default rules
  Update eslint-plugin-import to 2.31.0
  Update hermes-parser to 0.24.0
  Update eslint to v8.57.1
  Update eslint-plugin-react to 7.36.1
  Update eslint-plugin-react to 7.35.2
  Update hermes packages
  Update @babel packages
  Implement import/no-mutable-exports eslint rule
  Update eslint-plugin-import to 2.30.0
  MBS-12792: Hide ratings by spammer users (#2786)
  Mitigate flakiness in MBS-2604 test
  Log error to sentry if dates are dropped
  MBS-9063: Add tests
  MBS-9063: Ignore dates in Perl layer when editing rel types without them
  MBS-9063: Ignore dates in rels editor for rel types without them
  MBS-13858: Make email Message-Id unique (#3427)
  MBS-13854: Reword release label edit failure message (#3425)
  MBS-13170: Handle Bluesky links (#3423)
  MBS-13795: Update 初音ミク Wiki database validation and cleanup
  MBS-13850: Accept and cleanup French Ticketmaster
  MBS-13850: Avoid breaking Peruvian Ticketmaster
  Don't load no-discid tracklists
  Use "tbl medium" class in more places
  MBS-12593: Convert cdtoc/attach_filter_release to React
  MBS-13795: rename sidebar to original Japanese
  MBS-13802: Always use "Created (in)" for characters (#3403)
  MBS-13837: Update JunoDownload favicon (#3419)
  MBS-13801: Remove limits on tag cloud subqueries (#3400)
  MBS-13825: Display primary alias for entities on edit display
  MBS-13780: Show primary alias for series
  MBS-13780: Show primary alias for release groups
  MBS-13780: Show primary aliases in merge queue
  MBS-13780: Show primary alias for releases
  MBS-13780: Show primary alias for recordings
  Load artist aliases for instrument artist tab
  MBS-13780: Show primary alias for places
  MBS-13780: Show primary alias for genres
  MBS-13780: Show primary alias for events
  Split load_aliases from load_related_info and use in more places
  Use existing $artist_model variable
  MBS-13780: Show primary alias for labels
  MBS-13780: Show primary alias for areas
  MBS-13780: Show primary alias for works
  MBS-13580: Show primary aliases on artist credits
  Do not load ACs in set_lengths_to_cdtoc
  Drop unneeded passedHover
  Don't try to load artist credits if not supported
  MBS-13818: Show primary aliases on related entities
  Add attribute current_language to Server and Context
  MBS-13571: Show primary aliases on subscription page
  MBS-13561: Show primary aliases on tag page
  Do not show primary aliases for instruments
  Extract alias properties to role
  Extract and generalize load_aliases
  • Loading branch information
reosarevok committed Dec 18, 2024
2 parents ffeeffe + e2c3c91 commit ae53ba3
Show file tree
Hide file tree
Showing 177 changed files with 3,230 additions and 1,981 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/root/static/images/leaflet/marker-shadow.png
/root/static/scripts/common/DBDefs-client.js
/root/static/scripts/common/DBDefs-client.mjs
/root/static/scripts/common/DBDefs-client-browser.mjs
/root/static/scripts/common/DBDefs.js
/root/static/scripts/common/DBDefs.mjs
/root/static/scripts/tests/typeInfo.js
Expand Down
289 changes: 155 additions & 134 deletions eslint.config.mjs

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions flow-typed/npm/knockout_v3.1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
* later version: http://www.gnu.org/licenses/gpl-2.0.txt
*/

/* eslint-disable ft-flow/sort-keys */

declare module 'knockout' {
declare type Observable<T> = {
// eslint-disable-next-line no-undef
[[call]]: (() => T) & ((T) => empty),
peek: () => T,
subscribe: (
Expand Down
1 change: 0 additions & 1 deletion flow-typed/npm/pg_v8.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ declare module 'pg' {
+host?: string,
};

// eslint-disable-next-line no-unused-vars
declare export type QueryConfig<+V = mixed> = {
+name?: string,
+text: string,
Expand Down
8 changes: 8 additions & 0 deletions lib/MusicBrainz/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ sub handle_unicode_encoding_exception {
$self->res->status(HTTP_BAD_REQUEST);
}

has current_language => (
is => 'rw',
isa => 'Str',
default => 'en',
);

# Set and unset translation language
sub with_translations {
my ($c, $code) = @_;
Expand All @@ -355,6 +361,8 @@ sub with_translations {
my $cookie_lang = Translation->instance->language_from_cookie($c->request->cookies->{lang});
$c->set_language_cookie($c->request->cookies->{lang}->value) if defined $c->request->cookies->{lang};
my $lang = Translation->instance->set_language($cookie_lang);
$c->current_language($lang);
$c->model('MB')->context->current_language($lang);
my $html_lang = $lang =~ s/_([A-Z0-9]{2,})/-\L$1/r;

$c->stash(
Expand Down
6 changes: 6 additions & 0 deletions lib/MusicBrainz/Server/Context.pm
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ has 'max_request_time' => (
isa => 'Maybe[Int]',
);

has current_language => (
is => 'rw',
isa => 'Str',
default => 'en',
);

has 'catalyst_context' => (
is => 'rw',
isa => 'Maybe[MusicBrainz::Server]',
Expand Down
5 changes: 5 additions & 0 deletions lib/MusicBrainz/Server/Controller/Area.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ after 'load' => sub {
my $area = $c->stash->{area};

$c->model('AreaType')->load($area);
$c->model('Area')->load_aliases($area);
$c->model('Area')->load_containment($area);
};

Expand Down Expand Up @@ -157,6 +158,7 @@ sub events : Chained('load')
$c->model('Area')->load(map { $_->{entity} } map { $_->all_places } @$events);
$c->model('Area')->load_containment(map { (map { $_->{entity} } $_->all_areas),
(map { $_->{entity}->area } $_->all_places) } @$events);
$c->model('Event')->load_aliases(@$events);
$c->model('Event')->load_meta(@$events);
$c->model('Event')->rating->load_user_ratings($c->user->id, @$events) if $c->user_exists;

Expand Down Expand Up @@ -188,6 +190,7 @@ sub labels : Chained('load')
$c->model('LabelType')->load(@$labels);
$c->model('Area')->load(@$labels);
$c->model('Area')->load_containment(map { $_->{area} } @$labels);
$c->model('Label')->load_aliases(@$labels);
$c->model('Label')->load_meta(@$labels);
if ($c->user_exists) {
$c->model('Label')->rating->load_user_ratings($c->user->id, @$labels);
Expand Down Expand Up @@ -261,6 +264,7 @@ sub places : Chained('load')
$c->model('PlaceType')->load(@$places);
$c->model('Area')->load(@$places);
$c->model('Area')->load_containment(map { $_->area } @$places);
$c->model('Place')->load_aliases(@$places);
$c->model('Place')->load_meta(@$places);
$c->model('Place')->rating->load_user_ratings($c->user->id, @$places) if $c->user_exists;

Expand Down Expand Up @@ -409,6 +413,7 @@ before qw( create edit ) => sub {
sub _merge_load_entities
{
my ($self, $c, @areas) = @_;
$c->model('Area')->load_aliases(@areas);
$c->model('Area')->load_containment(@areas);
$c->model('AreaType')->load(@areas);
}
Expand Down
9 changes: 7 additions & 2 deletions lib/MusicBrainz/Server/Controller/Artist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ after 'load' => sub
my $artist_model = $c->model('Artist');

unless ($returning_jsonld) {
$artist_model->load_aliases($artist);
$artist_model->load_meta($artist);

if ($c->user_exists) {
Expand All @@ -146,8 +147,7 @@ after 'load' => sub
}
}

my $lang = $c->stash->{current_language} // 'en';
$c->model('Artist')->load_related_info([$artist], $lang);
$artist_model->load_related_info($artist);
$c->model('ArtistType')->load(map { $_->target } @{ $artist->relationships_by_type('artist') });
$c->model('Area')->load_containment($artist->area, $artist->begin_area, $artist->end_area);
};
Expand Down Expand Up @@ -254,6 +254,7 @@ sub show : PathPart('') Chained('load')
);
});
$c->model('ArtistCredit')->load(@$recordings);
$c->model('Recording')->load_aliases(@$recordings);
$c->model('Recording')->load_meta(@$recordings);
$c->model('ISRC')->load_for_recordings(@$recordings);
if ($c->user_exists) {
Expand Down Expand Up @@ -410,6 +411,7 @@ sub works : Chained('load')
);
});
$c->model('Work')->load_related_info(@$works);
$c->model('Work')->load_aliases(@$works);
$c->model('Work')->load_meta(@$works);
$c->model('Work')->rating->load_user_ratings($c->user->id, @$works) if $c->user_exists;

Expand Down Expand Up @@ -475,6 +477,7 @@ sub recordings : Chained('load')
});
}

$c->model('Recording')->load_aliases(@$recordings);
$c->model('Recording')->load_meta(@$recordings);

my $release_group_appearances = $c->model('Recording')->appears_on($recordings, 10, 1);
Expand Down Expand Up @@ -532,6 +535,7 @@ sub events : Chained('load')
});
$c->model('Event')->load_related_info(@$events);
$c->model('Event')->load_areas(@$events);
$c->model('Event')->load_aliases(@$events);
$c->model('Event')->load_meta(@$events);
$c->model('Event')->rating->load_user_ratings($c->user->id, @$events) if $c->user_exists;

Expand Down Expand Up @@ -595,6 +599,7 @@ sub releases : Chained('load')

$c->model('ArtistCredit')->load(@$releases);
$c->model('Release')->load_related_info(@$releases);
$c->model('Release')->load_aliases(@$releases);
$c->model('Release')->load_meta(@$releases);
$c->stash(
current_view => 'Node',
Expand Down
66 changes: 52 additions & 14 deletions lib/MusicBrainz/Server/Controller/CDTOC.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use MusicBrainz::Server::Constants qw(
);
use MusicBrainz::Server::Entity::CDTOC;
use MusicBrainz::Server::Entity::Util::JSON qw( to_json_array );
use MusicBrainz::Server::Data::Utils qw( boolean_to_json );
use MusicBrainz::Server::Translation qw( l );
use MusicBrainz::Server::ControllerUtils::CDTOC qw( add_dash );
use MusicBrainz::Server::ControllerUtils::JSON qw( serialize_pager );
Expand Down Expand Up @@ -287,7 +288,8 @@ sub _attach_list {
});
$c->model('Release')->load_related_info(@$releases);

my @mediums = map { $_->all_mediums } @$releases;
my @mediums = grep { !$_->format || $_->format->has_discids }
map { $_->all_mediums } @$releases;
$c->model('Track')->load_for_mediums(@mediums);

my @tracks = map { $_->all_tracks } @mediums;
Expand Down Expand Up @@ -330,6 +332,7 @@ sub _attach_list {
}
elsif ($c->form_submitted_and_valid($search_release, $c->req->query_params)) {
my $query = $search_release->field('query')->value;
my $was_mbid_search = 0;
my ($mbid) = $query =~ m/(
[\da-f]{8} -
[\da-f]{4} -
Expand All @@ -339,7 +342,7 @@ sub _attach_list {
)/ax;
my $releases = $self->_load_paged($c, sub {
if (defined $mbid) {
$c->stash->{was_mbid_search} = 1;
$was_mbid_search = 1;
my $release = $c->model('Release')->get_by_gid($mbid);
return [] unless defined $release;
return [
Expand All @@ -356,7 +359,8 @@ sub _attach_list {

my @releases = map { $_->entity } @$releases;
$c->model('Release')->load_related_info(@releases);
my @mediums = map { $_->all_mediums } @releases;
my @mediums = grep { !$_->format || $_->format->has_discids }
map { $_->all_mediums } @releases;
$c->model('Track')->load_for_mediums(@mediums);

my @tracks = map { $_->all_tracks } @mediums;
Expand All @@ -366,12 +370,27 @@ sub _attach_list {
my @rgs = $c->model('ReleaseGroup')->load(@releases);
$c->model('ReleaseGroup')->load_meta(@rgs);

my $sorted_releases = [sort_by {
$_->entity->release_group
? $_->entity->release_group->gid
: ''
} @$releases];

my %props = (
action => 'add',
form => $search_release->TO_JSON,
cdToc => $cdtoc->TO_JSON,
pager => serialize_pager($c->stash->{pager}),
results => to_json_array($sorted_releases),
tocString => $c->stash->{toc},
wasMbidSearch => boolean_to_json($was_mbid_search),
);

$c->stash(
template => 'cdtoc/attach_filter_release.tt',
cdtoc_action => 'add',
results => [sort_by { $_->entity->release_group ? $_->entity->release_group->gid : '' } @$releases],
current_view => 'Node',
component_path => 'cdtoc/AttachCDTocToRelease.js',
component_props => \%props,
);
$c->detach;
}
else {
my $cdstub = $c->model('CDStub')->get_by_discid($cdtoc->discid);
Expand Down Expand Up @@ -489,10 +508,12 @@ sub move : Local Edit
else {
my $search_release = $c->form( query_release => 'Search::Query',
name => 'filter-release' );
$c->stash( template => 'cdtoc/move_search.tt' );

my %props;

if ($c->form_submitted_and_valid($search_release, $c->req->query_params)) {
my $query = $search_release->field('query')->value;
my $was_mbid_search = 0;
my ($mbid) = $query =~ m/(
[\da-f]{8} -
[\da-f]{4} -
Expand All @@ -503,7 +524,7 @@ sub move : Local Edit

my $releases = $self->_load_paged($c, sub {
if (defined $mbid) {
$c->stash->{was_mbid_search} = 1;
$was_mbid_search = 1;
my $release = $c->model('Release')->get_by_gid($mbid);
return [] unless defined $release;
return [
Expand All @@ -527,13 +548,30 @@ sub move : Local Edit
$c->model('Recording')->load(map { $_->all_tracks } @mediums);
my @rgs = $c->model('ReleaseGroup')->load(@releases);
$c->model('ReleaseGroup')->load_meta(@rgs);
$c->stash(
template => 'cdtoc/attach_filter_release.tt',
cdtoc_action => 'move',
results => $releases,

%props = (
action => 'move',
cdToc => $cdtoc->TO_JSON,
form => $search_release->TO_JSON,
pager => serialize_pager($c->stash->{pager}),
results => to_json_array($releases),
tocString => $medium_cdtoc->id,
wasMbidSearch => boolean_to_json($was_mbid_search),
);
} else {
%props = (
action => 'move',
cdToc => $cdtoc->TO_JSON,
form => $search_release->TO_JSON,
tocString => $medium_cdtoc->id,
);
$c->detach;
}

$c->stash(
current_view => 'Node',
component_path => 'cdtoc/AttachCDTocToRelease.js',
component_props => \%props,
);
}
}

Expand Down
11 changes: 5 additions & 6 deletions lib/MusicBrainz/Server/Controller/Collection.pm
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,11 @@ sub show : Chained('load') PathPart('') {
});

if ($model->can('load_related_info')) {
if ($entity_type eq 'artist') {
my $lang = $c->stash->{current_language} // 'en';
$model->load_related_info($entities, $lang);
} else {
$model->load_related_info(@$entities);
}
$model->load_related_info(@$entities);
}

if ($model->can('load_aliases')) {
$model->load_aliases(@$entities);
}

if ($model->can('load_meta')) {
Expand Down
2 changes: 2 additions & 0 deletions lib/MusicBrainz/Server/Controller/Event.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ after 'load' => sub {
my $event = $c->stash->{event};

my $event_model = $c->model('Event');
$event_model->load_aliases($event);
$event_model->load_meta($event);
if ($c->user_exists) {
$event_model->rating->load_user_ratings($c->user->id, $event);
Expand Down Expand Up @@ -114,6 +115,7 @@ sub show : PathPart('') Chained('load') {

sub _merge_load_entities {
my ($self, $c, @events) = @_;
$c->model('Event')->load_aliases(@events);
$c->model('Event')->load_related_info(@events);
}

Expand Down
3 changes: 3 additions & 0 deletions lib/MusicBrainz/Server/Controller/Genre.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ after 'load' => sub {
my ($self, $c) = @_;
my $entity_name = $self->{entity_name};
my $entity = $c->stash->{ $entity_name };
$c->model('Genre')->load_aliases($entity);

$c->stash(
can_delete => $c->model('Genre')->can_delete($entity->id),
);
Expand Down Expand Up @@ -102,6 +104,7 @@ sub list : Path('/genres') Args(0) {
my ($self, $c) = @_;

my @genres = $c->model('Genre')->get_all;
$c->model('Genre')->load_aliases(@genres);
my $coll = $c->get_collator();
my @sorted_genres = sort_by { $coll->getSortKey($_->name) } @genres;

Expand Down
3 changes: 3 additions & 0 deletions lib/MusicBrainz/Server/Controller/Instrument.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ sub artists : Chained('load') {
$instrument_credits_and_rel_types{$item->{artist}->gid} = \@credits_and_rel_types if @credits_and_rel_types;
}

$c->model('Artist')->load_aliases(@artists);
$c->model('Artist')->load_meta(@artists);
$c->model('ArtistType')->load(@artists);
$c->model('Gender')->load(@artists);
Expand Down Expand Up @@ -112,6 +113,7 @@ sub recordings : Chained('load') {
$instrument_credits_and_rel_types{$item->{recording}->gid} = \@credits_and_rel_types if @credits_and_rel_types;
}

$c->model('Recording')->load_aliases(@recordings);
$c->model('Recording')->load_meta(@recordings);

if ($c->user_exists) {
Expand Down Expand Up @@ -152,6 +154,7 @@ sub releases : Chained('load') {
}

$c->model('ArtistCredit')->load(@releases);
$c->model('Release')->load_aliases(@releases);
$c->model('Release')->load_related_info(@releases);

my %props = (
Expand Down
3 changes: 3 additions & 0 deletions lib/MusicBrainz/Server/Controller/Label.pm
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ after 'load' => sub
my $label_model = $c->model('Label');

unless ($returning_jsonld) {
$label_model->load_aliases($label);
$label_model->load_meta($label);

if ($c->user_exists) {
Expand Down Expand Up @@ -129,6 +130,7 @@ sub show : PathPart('') Chained('load')

$c->model('ArtistCredit')->load(@$releases);
$c->model('Release')->load_release_events(@$releases);
$c->model('Release')->load_aliases(@$releases);
$c->model('Release')->load_meta(@$releases);
$c->model('Medium')->load_for_releases(@$releases);
$c->model('MediumFormat')->load(map { $_->all_mediums } @$releases);
Expand Down Expand Up @@ -197,6 +199,7 @@ after [qw( show collections details tags ratings aliases subscribers relationshi
sub _merge_load_entities
{
my ($self, $c, @labels) = @_;
$c->model('Label')->load_aliases(@labels);
$c->model('LabelType')->load(@labels);
$c->model('Area')->load(@labels);
}
Expand Down
Loading

0 comments on commit ae53ba3

Please sign in to comment.