-
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MBS-8242: Link to specific relationship type docs from rel edits
This adds a link to the doc page(s) for the relationship type(s) involved in a relationship edit (add, edit or remove), and lists the type descriptions for a basic overview. It seems very useful to have direct links to the documentation (often including specific guidelines) directly in the place people need to vote on the changes from. We pass an array to allow multiple types in EditRelationship; we pass the rels through a Set to remove duplicates when EditRelationship does not change the rel type.
- Loading branch information
1 parent
8472078
commit 652523f
Showing
5 changed files
with
141 additions
and
49 deletions.
There are no files selected for viewing
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,72 @@ | ||
/* | ||
* @flow strict | ||
* 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 expand2react from '../../static/scripts/common/i18n/expand2react.js'; | ||
import HelpIcon from '../../static/scripts/edit/components/HelpIcon.js'; | ||
import getRelationshipLinkType | ||
from '../../static/scripts/edit/utility/getRelationshipLinkType.js'; | ||
|
||
type Props = { | ||
+relationships: $ReadOnlyArray<RelationshipT>, | ||
}; | ||
|
||
const RelationshipDocsTooltip = ({ | ||
relationships, | ||
}: Props): React$Element<'div'> | null => { | ||
const relationshipTypes = [...new Set( | ||
relationships.reduce((types: Array<LinkTypeT>, relationship) => { | ||
const type = getRelationshipLinkType(relationship); | ||
if (type && type.gid && type.name) { | ||
types.push(type); | ||
} | ||
return types; | ||
}, []), | ||
)]; | ||
|
||
if (!relationshipTypes?.length) { | ||
return null; | ||
} | ||
|
||
const helpContent = ( | ||
<> | ||
<p>{l('The following relationship types are used in this edit:')}</p> | ||
<dl> | ||
{relationshipTypes.map(relationshipType => ( | ||
<> | ||
<dt> | ||
{expand2react( | ||
'{doc_link|{name}}', | ||
{ | ||
doc_link: { | ||
href: '/relationship/' + relationshipType.gid, | ||
target: '_blank', | ||
}, | ||
name: relationshipType.name, | ||
}, | ||
)} | ||
</dt> | ||
<dd> | ||
{expand2react(l_relationships(relationshipType.description))} | ||
</dd> | ||
</> | ||
))} | ||
</dl> | ||
</> | ||
); | ||
|
||
return ( | ||
<div className="edit-help"> | ||
<HelpIcon | ||
content={helpContent} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RelationshipDocsTooltip; |
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
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