Skip to content

Commit

Permalink
Add display placeholder for EAA edits in production
Browse files Browse the repository at this point in the history
If you were to submit any of the new EAA edits on the beta server once it's
deployed there, and then try to load any of those edits in production (whether
directly or via an edit listing), then it would cause an ISE in production.

Pulling all of the display code for these new edit types would basically mean
having to merge a very large chunk of the event-art-archive branch, as they
depend heavily on changes to the `Data::` and `Entity::` layers.

This patch just adds a placeholder component, `BetaOnlyEdit`, which links to
the edit on the beta server (saying that it can only be viewed there
temporarily).
  • Loading branch information
mwiencek committed May 23, 2024
1 parent 77b53c0 commit 63c2c27
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/MusicBrainz/Server/Constants.pm
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ Readonly our $EDIT_EVENT_ADD_ANNOTATION => 154;
Readonly our $EDIT_EVENT_ADD_ALIAS => 155;
Readonly our $EDIT_EVENT_DELETE_ALIAS => 156;
Readonly our $EDIT_EVENT_EDIT_ALIAS => 157;
Readonly our $EDIT_EVENT_ADD_EVENT_ART => 158;
Readonly our $EDIT_EVENT_REMOVE_EVENT_ART => 159;
Readonly our $EDIT_EVENT_EDIT_EVENT_ART => 1510;
Readonly our $EDIT_EVENT_REORDER_EVENT_ART => 1511;

Readonly our $EDIT_GENRE_CREATE => 160;
Readonly our $EDIT_GENRE_EDIT => 161;
Expand Down
25 changes: 25 additions & 0 deletions lib/MusicBrainz/Server/Edit/Event/AddEventArt.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package MusicBrainz::Server::Edit::Event::AddEventArt;
use Moose;
use namespace::autoclean;

use MusicBrainz::Server::Constants qw( $EDIT_EVENT_ADD_EVENT_ART );
use MusicBrainz::Server::Translation qw( N_lp );

extends 'MusicBrainz::Server::Edit';

sub edit_kind { 'add' }
sub edit_name { N_lp('Add event art', 'singular, edit type') }
sub edit_template { 'AddEventArt' }
sub edit_type { $EDIT_EVENT_ADD_EVENT_ART }

1;

=head1 COPYRIGHT AND LICENSE
Copyright (C) 2023 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
=cut
25 changes: 25 additions & 0 deletions lib/MusicBrainz/Server/Edit/Event/EditEventArt.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package MusicBrainz::Server::Edit::Event::EditEventArt;
use Moose;
use namespace::autoclean;

use MusicBrainz::Server::Constants qw( $EDIT_EVENT_EDIT_EVENT_ART );
use MusicBrainz::Server::Translation qw( N_lp );

extends 'MusicBrainz::Server::Edit';

sub edit_kind { 'edit' }
sub edit_name { N_lp('Edit event art', 'singular, edit type') }
sub edit_template { 'EditEventArt' }
sub edit_type { $EDIT_EVENT_EDIT_EVENT_ART }

1;

=head1 COPYRIGHT AND LICENSE
Copyright (C) 2023 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
=cut
25 changes: 25 additions & 0 deletions lib/MusicBrainz/Server/Edit/Event/RemoveEventArt.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package MusicBrainz::Server::Edit::Event::RemoveEventArt;
use Moose;
use namespace::autoclean;

use MusicBrainz::Server::Constants qw( $EDIT_EVENT_REMOVE_EVENT_ART );
use MusicBrainz::Server::Translation qw( N_lp );

extends 'MusicBrainz::Server::Edit';

sub edit_kind { 'remove' }
sub edit_name { N_lp('Remove event art', 'singular, edit type') }
sub edit_template { 'RemoveEventArt' }
sub edit_type { $EDIT_EVENT_REMOVE_EVENT_ART }

1;

=head1 COPYRIGHT AND LICENSE
Copyright (C) 2023 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
=cut
25 changes: 25 additions & 0 deletions lib/MusicBrainz/Server/Edit/Event/ReorderEventArt.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package MusicBrainz::Server::Edit::Event::ReorderEventArt;
use Moose;
use namespace::autoclean;

use MusicBrainz::Server::Constants qw( $EDIT_EVENT_REORDER_EVENT_ART );
use MusicBrainz::Server::Translation qw( N_lp );

extends 'MusicBrainz::Server::Edit';

sub edit_kind { 'other' }
sub edit_name { N_lp('Reorder event art', 'plural, edit type') }
sub edit_template { 'ReorderEventArt' }
sub edit_type { $EDIT_EVENT_REORDER_EVENT_ART }

1;

=head1 COPYRIGHT AND LICENSE
Copyright (C) 2023 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
=cut
4 changes: 4 additions & 0 deletions lib/MusicBrainz/Server/EditRegistry.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ my @CLASSES = qw(
MusicBrainz::Server::Edit::Area::EditAlias
MusicBrainz::Server::Edit::Area::Merge
MusicBrainz::Server::Edit::Event::AddAlias
MusicBrainz::Server::Edit::Event::AddEventArt
MusicBrainz::Server::Edit::Event::DeleteAlias
MusicBrainz::Server::Edit::Event::EditEventArt
MusicBrainz::Server::Edit::Event::AddAnnotation
MusicBrainz::Server::Edit::Event::Create
MusicBrainz::Server::Edit::Event::Delete
MusicBrainz::Server::Edit::Event::Edit
MusicBrainz::Server::Edit::Event::EditAlias
MusicBrainz::Server::Edit::Event::Merge
MusicBrainz::Server::Edit::Event::RemoveEventArt
MusicBrainz::Server::Edit::Event::ReorderEventArt
MusicBrainz::Server::Edit::Genre::AddAlias
MusicBrainz::Server::Edit::Genre::AddAnnotation
MusicBrainz::Server::Edit::Genre::Create
Expand Down
52 changes: 52 additions & 0 deletions root/edit/details/BetaOnlyEdit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* @flow strict
* Copyright (C) 2024 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 {SanitizedCatalystContext} from '../../context.mjs';
import DBDefs from '../../static/scripts/common/DBDefs.mjs';

component BetaOnlyEdit(edit: EditT) {
const $c = React.useContext(SanitizedCatalystContext);
const editId = edit.id;
if (
!DBDefs.IS_BETA &&
nonEmpty(DBDefs.BETA_REDIRECT_HOSTNAME) &&
editId != null
) {
const betaUri = new URL($c.req.uri);
betaUri.host = DBDefs.BETA_REDIRECT_HOSTNAME;
betaUri.pathname = '/edit/' + encodeURIComponent(String(editId));
return (
<p>
{exp.l(
`This edit can currently only be viewed on the
{beta|beta server}.`,
{
beta: {
href: betaUri.toString(),
target: '_blank',
},
},
)}
</p>
);
}
return (
/*
* This shouldn't happen except in development or if a
* misconfiguration exists.
*/
<p>
{'This edit cannot currently be displayed.'}
</p>
);
}

export default BetaOnlyEdit;
9 changes: 9 additions & 0 deletions root/edit/utility/getEditDetailsElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import AddRemoveAlias from '../details/AddRemoveAlias.js';
import AddSeries from '../details/AddSeries.js';
import AddStandaloneRecording from '../details/AddStandaloneRecording.js';
import AddWork from '../details/AddWork.js';
import BetaOnlyEdit from '../details/BetaOnlyEdit.js';
import ChangeReleaseQuality from '../details/ChangeReleaseQuality.js';
import ChangeWikiDoc from '../details/ChangeWikiDoc.js';
import EditAlias from '../details/EditAlias.js';
Expand Down Expand Up @@ -141,6 +142,8 @@ export default function getEditDetailsElement(
return <AddArtist edit={edit} />;
case EDIT_TYPES.EDIT_RELEASE_ADD_COVER_ART:
return <AddCoverArt edit={edit} />;
case EDIT_TYPES.EDIT_EVENT_ADD_EVENT_ART:
return <BetaOnlyEdit edit={edit} />;
case EDIT_TYPES.EDIT_MEDIUM_ADD_DISCID:
return <AddDiscId edit={edit} />;
case EDIT_TYPES.EDIT_EVENT_CREATE:
Expand Down Expand Up @@ -229,6 +232,8 @@ export default function getEditDetailsElement(
return <EditBarcodes edit={edit} />;
case EDIT_TYPES.EDIT_RELEASE_EDIT_COVER_ART:
return <EditCoverArt edit={edit} />;
case EDIT_TYPES.EDIT_EVENT_EDIT_EVENT_ART:
return <BetaOnlyEdit edit={edit} />;
case EDIT_TYPES.EDIT_EVENT_EDIT:
return <EditEvent edit={edit} />;
case EDIT_TYPES.EDIT_GENRE_EDIT:
Expand Down Expand Up @@ -290,6 +295,8 @@ export default function getEditDetailsElement(
return <MoveDiscId edit={edit} />;
case EDIT_TYPES.EDIT_RELEASE_REMOVE_COVER_ART:
return <RemoveCoverArt edit={edit} />;
case EDIT_TYPES.EDIT_EVENT_REMOVE_EVENT_ART:
return <BetaOnlyEdit edit={edit} />;
case EDIT_TYPES.EDIT_MEDIUM_REMOVE_DISCID:
return <RemoveDiscId edit={edit} />;
case EDIT_TYPES.EDIT_AREA_DELETE:
Expand Down Expand Up @@ -321,6 +328,8 @@ export default function getEditDetailsElement(
return <RemoveReleaseLabel edit={edit} />;
case EDIT_TYPES.EDIT_RELEASE_REORDER_COVER_ART:
return <ReorderCoverArt edit={edit} />;
case EDIT_TYPES.EDIT_EVENT_REORDER_EVENT_ART:
return <BetaOnlyEdit edit={edit} />;
case EDIT_TYPES.EDIT_RELEASE_REORDER_MEDIUMS:
return <ReorderMediums edit={edit} />;
case EDIT_TYPES.EDIT_RELATIONSHIPS_REORDER:
Expand Down
6 changes: 6 additions & 0 deletions root/static/scripts/common/constants/editTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ export const EDIT_EVENT_ADD_ANNOTATION: EDIT_EVENT_ADD_ANNOTATION_T = 154;
export const EDIT_EVENT_ADD_ALIAS: EDIT_EVENT_ADD_ALIAS_T = 155;
export const EDIT_EVENT_DELETE_ALIAS: EDIT_EVENT_DELETE_ALIAS_T = 156;
export const EDIT_EVENT_EDIT_ALIAS: EDIT_EVENT_EDIT_ALIAS_T = 157;
export const EDIT_EVENT_ADD_EVENT_ART: EDIT_EVENT_ADD_EVENT_ART_T = 158;
export const EDIT_EVENT_REMOVE_EVENT_ART:
EDIT_EVENT_REMOVE_EVENT_ART_T = 159;
export const EDIT_EVENT_EDIT_EVENT_ART: EDIT_EVENT_EDIT_EVENT_ART_T = 1510;
export const EDIT_EVENT_REORDER_EVENT_ART:
EDIT_EVENT_REORDER_EVENT_ART_T = 1511;

export const EDIT_GENRE_CREATE: EDIT_GENRE_CREATE_T = 160;
export const EDIT_GENRE_EDIT: EDIT_GENRE_EDIT_T = 161;
Expand Down
4 changes: 4 additions & 0 deletions root/types/edit_type_ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ declare type EDIT_EVENT_ADD_ANNOTATION_T = 154;
declare type EDIT_EVENT_ADD_ALIAS_T = 155;
declare type EDIT_EVENT_DELETE_ALIAS_T = 156;
declare type EDIT_EVENT_EDIT_ALIAS_T = 157;
declare type EDIT_EVENT_ADD_EVENT_ART_T = 158;
declare type EDIT_EVENT_REMOVE_EVENT_ART_T = 159;
declare type EDIT_EVENT_EDIT_EVENT_ART_T = 1510;
declare type EDIT_EVENT_REORDER_EVENT_ART_T = 1511;

declare type EDIT_GENRE_CREATE_T = 160;
declare type EDIT_GENRE_EDIT_T = 161;
Expand Down

0 comments on commit 63c2c27

Please sign in to comment.