-
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MBS-11599: Allow adding URL relationships to genre pages
Not implementing a full relationship editor yet since that has no easy React implementation and mwiencek is working on that for all entities, by which point it should be trivial to also extend it to genres. In the meantime, being able to link genres to Wikidata, Rate Your Music and whatnot seems like a great first step. We do need a "mock" relationship editor section for hidden inputs to be attached to, though, so one is added.
- Loading branch information
1 parent
5484c0e
commit 0824d5f
Showing
17 changed files
with
191 additions
and
73 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
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
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* @flow | ||
* Copyright (C) 2019 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 EnterEdit from '../../../../components/EnterEdit'; | ||
import EnterEditNote from '../../../../components/EnterEditNote'; | ||
import FormRowTextLong from '../../../../components/FormRowTextLong'; | ||
import type {GenreFormT} from '../../../../genre/types'; | ||
import {createExternalLinksEditor} from '../../edit/externalLinks'; | ||
import {exportTypeInfo} from '../../relationship-editor/common/viewModel'; | ||
import {prepareSubmission} from '../../relationship-editor/generic'; | ||
|
||
type Props = { | ||
+$c: CatalystContextT, | ||
+attrInfo: LinkAttrTypeOptionsT, | ||
+form: GenreFormT, | ||
+sourceEntity: GenreT | {entityType: 'genre'}, | ||
+typeInfo: LinkTypeOptionsT, | ||
}; | ||
|
||
const GenreEditForm = ({ | ||
$c, | ||
attrInfo, | ||
form, | ||
sourceEntity, | ||
typeInfo, | ||
}: Props): React.Element<'form'> => { | ||
const externalLinksEditorContainerRef = React.useRef(null); | ||
|
||
const handleSubmit = () => { | ||
console.log('preparing submission'); | ||
prepareSubmission('edit-genre'); | ||
}; | ||
|
||
React.useEffect(() => { | ||
exportTypeInfo(typeInfo, attrInfo); | ||
invariant(externalLinksEditorContainerRef.current != null); | ||
createExternalLinksEditor({ | ||
mountPoint: externalLinksEditorContainerRef.current, | ||
sourceData: sourceEntity, | ||
}); | ||
}, [attrInfo, sourceEntity, typeInfo]); | ||
|
||
return ( | ||
<form | ||
action={$c.req.uri} | ||
className="edit-genre" | ||
method="post" | ||
onSubmit={handleSubmit} | ||
> | ||
<div className="half-width"> | ||
<fieldset> | ||
<legend>{l('Genre details')}</legend> | ||
<FormRowTextLong | ||
field={form.field.name} | ||
label={addColonText(l('Name'))} | ||
required | ||
uncontrolled | ||
/> | ||
<FormRowTextLong | ||
field={form.field.comment} | ||
label={addColonText(l('Disambiguation'))} | ||
uncontrolled | ||
/> | ||
</fieldset> | ||
|
||
<div data-form-name="edit-genre" id="relationship-editor" /> | ||
|
||
<fieldset> | ||
<legend>{l('External Links')}</legend> | ||
<div | ||
id="external-links-editor-container" | ||
ref={externalLinksEditorContainerRef} | ||
/> | ||
</fieldset> | ||
|
||
<EnterEditNote field={form.field.edit_note} /> | ||
<EnterEdit form={form} /> | ||
</div> | ||
</form> | ||
); | ||
}; | ||
|
||
export default (hydrate<Props>( | ||
'div.genre-edit-form', | ||
GenreEditForm, | ||
): React.AbstractComponent<Props, void>); |
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
Oops, something went wrong.