-
-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MBS-12622: Show if URL rel has pending edits in links editor
We now show a special icon on the (non-URL) relationship editor if a relationship that can be changed has (previous) pending edits. This adds the same icon to the URL editor, where nothing was being shown currently. This should help avoid unnecessary URL removals when someone is already setting it as ended, for example. The externalLinks code does slightly odd things to entity/relationship data to put them into state, so flow typing here is pretty messy - unsure if it can be improved without a proper refactoring of the externalLinks component though.
- Loading branch information
1 parent
f33fc20
commit 4046247
Showing
4 changed files
with
112 additions
and
37 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
root/static/scripts/edit/components/RelationshipPendingEditsWarning.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* @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 openEditsForRelIconUrl | ||
from '../../../images/icons/open_edits_for_rel.png'; | ||
import type { | ||
RelationshipStateT, | ||
} from '../../relationship-editor/types.js'; | ||
import getOpenEditsLink | ||
from '../../relationship-editor/utility/getOpenEditsLink.js'; | ||
import type { | ||
LinkRelationshipT, | ||
} from '../externalLinks.js'; | ||
|
||
import Tooltip from './Tooltip.js'; | ||
|
||
|
||
type PropsT = { | ||
+relationship: LinkRelationshipT | RelationshipStateT, | ||
}; | ||
|
||
const RelationshipPendingEditsWarning = ({ | ||
relationship, | ||
}: PropsT): React$Element<typeof React.Fragment> | null => { | ||
const hasPendingEdits = relationship.editsPending; | ||
const openEditsLink = getOpenEditsLink(relationship); | ||
|
||
return hasPendingEdits && nonEmpty(openEditsLink) ? ( | ||
<> | ||
{' '} | ||
<Tooltip | ||
content={exp.l( | ||
'This relationship has {edit_search|pending edits}.', | ||
{edit_search: openEditsLink}, | ||
)} | ||
target={ | ||
<img | ||
alt={l('This relationship has pending edits.')} | ||
className="info" | ||
height={16} | ||
src={openEditsForRelIconUrl} | ||
style={{verticalAlign: 'middle'}} | ||
/> | ||
} | ||
/> | ||
</> | ||
) : null; | ||
}; | ||
|
||
export default RelationshipPendingEditsWarning; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters