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;