Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MBS-10397: Convert Edit Event edit to React
- Loading branch information
1 parent
36940d2
commit 5bba8a5
Showing
4 changed files
with
122 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* @flow | ||
* Copyright (C) 2020 Anirudh Jain | ||
* | ||
* 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 EntityLink from '../../static/scripts/common/components/EntityLink'; | ||
import Diff from '../../static/scripts/edit/components/edit/Diff'; | ||
import FullChangeDiff from | ||
'../../static/scripts/edit/components/edit/FullChangeDiff'; | ||
import yesNo from '../../static/scripts/common/utility/yesNo'; | ||
import formatDate from '../../static/scripts/common/utility/formatDate'; | ||
|
||
type EditEventProps = { | ||
+display_data: { | ||
+begin_date?: CompT<PartialDateT | null>, | ||
+cancelled?: CompT<boolean>, | ||
+comment?: CompT<string | null>, | ||
+end_date?: CompT<PartialDateT | null>, | ||
+event: EventT, | ||
+name?: CompT<string>, | ||
+setlist?: CompT<string | null>, | ||
+time?: CompT<string | null>, | ||
+type?: CompT<EventT | null>, | ||
}, | ||
}; | ||
|
||
const EditEvent = ({edit}: {+edit: EditEventProps}) => { | ||
const display = edit.display_data; | ||
const name = display.name; | ||
const comment = display.comment; | ||
const cancelled = display.cancelled; | ||
const type = display.type; | ||
const beginDate = display.begin_date; | ||
const endDate = display.end_date; | ||
const time = display.time; | ||
const setlist = display.setlist; | ||
return ( | ||
<table className="details edit-event"> | ||
<tr> | ||
<th>{addColonText(l('Event'))}</th> | ||
<td colSpan="2"><EntityLink entity={display.event} /></td> | ||
</tr> | ||
{name ? ( | ||
<Diff | ||
label={addColonText(l('Name'))} | ||
newText={name.new} | ||
oldText={name.old} | ||
split="\s+" | ||
/> | ||
) : null} | ||
{comment ? ( | ||
<Diff | ||
label={addColonText(l('Disambiguation'))} | ||
newText={comment.new ?? ''} | ||
oldText={comment.old ?? ''} | ||
split="\s+" | ||
/> | ||
) : null} | ||
{cancelled ? ( | ||
<FullChangeDiff | ||
label={addColonText(l('Cancelled'))} | ||
newContent={yesNo(cancelled.new)} | ||
oldContent={yesNo(cancelled.old)} | ||
/> | ||
) : null} | ||
{type ? ( | ||
<FullChangeDiff | ||
label={addColonText(l('Type'))} | ||
newContent={type.new?.name ?? ''} | ||
oldContent={type.old?.name ?? ''} | ||
/> | ||
) : null} | ||
{beginDate ? ( | ||
<Diff | ||
label={addColonText(l('Begin date'))} | ||
newText={formatDate(beginDate.new)} | ||
oldText={formatDate(beginDate.old)} | ||
split="-" | ||
/> | ||
) : null} | ||
{endDate ? ( | ||
<Diff | ||
label={addColonText(l('End date'))} | ||
newText={formatDate(endDate.new)} | ||
oldText={formatDate(endDate.old)} | ||
split="-" | ||
/> | ||
) : null} | ||
{time ? ( | ||
<FullChangeDiff | ||
label={addColonText(l('Time'))} | ||
newContent={time.new ?? ''} | ||
oldContent={time.old ?? ''} | ||
/> | ||
) : null} | ||
{setlist ? ( | ||
<Diff | ||
label={addColonText(l('Setlist'))} | ||
newText={setlist.new ?? ''} | ||
oldText={setlist.old ?? ''} | ||
split="\s+" | ||
/> | ||
) : null} | ||
</table> | ||
); | ||
}; | ||
|
||
export default EditEvent; |
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