From a8e12fd3f5873d61863b416b74f2434133a117bc Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Thu, 23 May 2024 07:44:55 -0500 Subject: [PATCH] Add `BetaOnlyEdit` placeholder for edit types in beta testing This is a prerequisite step for IMG-84 / PR #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. --- root/edit/details/BetaOnlyEdit.js | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 root/edit/details/BetaOnlyEdit.js diff --git a/root/edit/details/BetaOnlyEdit.js b/root/edit/details/BetaOnlyEdit.js new file mode 100644 index 00000000000..49e85e7fbd1 --- /dev/null +++ b/root/edit/details/BetaOnlyEdit.js @@ -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 ( +

+ {exp.l( + `This edit can currently only be viewed on the + {beta|beta server}.`, + { + beta: { + href: betaUri.toString(), + target: '_blank', + }, + }, + )} +

+ ); + } + return ( + /* + * This shouldn't happen except in development or if a + * misconfiguration exists. + */ +

+ {'This edit cannot currently be displayed.'} +

+ ); +} + +export default BetaOnlyEdit;