Skip to content

Commit

Permalink
Add BetaOnlyEdit placeholder for edit types in beta testing
Browse files Browse the repository at this point in the history
This is a prerequisite step for IMG-84 / PR metabrainz#3150.

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 adds a placeholder component, `BetaOnlyEdit`, which can be used to
link these EAA edits to the beta server (saying that they can only be viewed
there temporarily).

In a subsequent commit I will add in the machinery to actually make use of this
component for the EAA edits specifically. It may also be useful for other new
edit types we introduce in the future.
  • Loading branch information
mwiencek committed May 23, 2024
1 parent 77b53c0 commit a8e12fd
Showing 1 changed file with 52 additions and 0 deletions.
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;

0 comments on commit a8e12fd

Please sign in to comment.