diff --git a/root/static/scripts/edit/components/EntityPendingEditsWarning.js b/root/static/scripts/edit/components/EntityPendingEditsWarning.js new file mode 100644 index 00000000000..e1736c6b17a --- /dev/null +++ b/root/static/scripts/edit/components/EntityPendingEditsWarning.js @@ -0,0 +1,51 @@ +/* + * @flow strict-local + * 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 + */ + +import * as React from 'react'; + +import openEditsForEntityIconUrl + from '../../../images/icons/open_edits_for_entity.svg'; +import entityHref from '../../common/utility/entityHref.js'; + +import Tooltip from './Tooltip.js'; + + +type PropsT = { + +entity: CoreEntityT, +}; + +const EntityPendingEditsWarning = ({ + entity, +}: PropsT): React$Element | null => { + const hasPendingEdits = Boolean(entity.editsPending); + const openEditsLink = entityHref(entity, '/open_edits'); + + return hasPendingEdits && nonEmpty(openEditsLink) ? ( + <> + {' '} + + } + /> + + ) : null; +}; + +export default EntityPendingEditsWarning; diff --git a/root/static/scripts/edit/externalLinks.js b/root/static/scripts/edit/externalLinks.js index 82aebc89c0a..c9b2bfee84d 100644 --- a/root/static/scripts/edit/externalLinks.js +++ b/root/static/scripts/edit/externalLinks.js @@ -42,6 +42,8 @@ import {isMalware} from '../url/utility/isGreyedOut.js'; import ExternalLinkAttributeDialog from './components/ExternalLinkAttributeDialog.js'; import HelpIcon from './components/HelpIcon.js'; +import EntityPendingEditsWarning + from './components/EntityPendingEditsWarning.js'; import RelationshipPendingEditsWarning from './components/RelationshipPendingEditsWarning.js'; import RemoveButton from './components/RemoveButton.js'; @@ -928,7 +930,7 @@ export class _ExternalLinksEditor * The first element of tuple `item` is not the URL * when the URL is not submitted therefore isn't grouped. */ - const {url, rawUrl} = relationships[0]; + const {url, rawUrl, entity1} = relationships[0]; const isLastLink = index === linksByUrl.length - 1; const links = [...relationships]; const linkIndexes = []; @@ -1063,6 +1065,7 @@ export class _ExternalLinksEditor relationships={links} typeOptions={typeOptions} url={url} + urlEntity={entity1} urlMatchesType={urlMatchesType} validateLink={(link) => this.validateLink(link)} /> @@ -1306,6 +1309,7 @@ type LinkProps = { +relationships: $ReadOnlyArray, +typeOptions: $ReadOnlyArray, +url: string, + +urlEntity?: CoreEntityT, +urlMatchesType: boolean, +validateLink: (LinkRelationshipT | LinkStateT) => ErrorT | null, }; @@ -1448,6 +1452,9 @@ export class ExternalLink extends React.Component { {props.url} )} + {props.urlEntity ? ( + + ) : null} {props.url && props.duplicate !== null ? (
(({ const [sourceCredit, targetCredit] = backward ? [relationship.entity1_credit, relationship.entity0_credit] : [relationship.entity0_credit, relationship.entity1_credit]; - const targetHasPendingEdits = Boolean(target.editsPending); const isRemoved = relationship._status === REL_STATUS_REMOVE; const removeButtonId = 'remove-relationship-' + getRelationshipKey(relationship); @@ -281,26 +278,7 @@ const RelationshipItem = (React.memo(({ }) ) : targetDisplay} - {targetHasPendingEdits ? ( - <> - {' '} - - } - /> - - ) : null} + {datesAndAttributes}