-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update metadata, the proper way (#292)
* prototype view switching * refactor, more UI * formik form setup & data flow * debug output, fixes, refactor * description preview refactor * publish/update date changes * output created & updated date at top of asset * use ddo.created & ddo.updated everywhere * stop pushing metadata.main.datePublished * owner check for edit link * all the feedback states and switching between them: loading, error, success * refactor feedback, one component for publish & edit * action & date output fixes * move all content, iterate form fields from it * UI updates * styling tweaks * ddo dataflow refactor, more useAsset usage * more useAsset usage * form actions styling * prepare edit history component * metadata output tweaks * copy * safeguard against profile urls without protocol defined * refetch ddo after edit Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * switch author for dataTokenOptions in metadata preview * refactor * copy * showPricing fix * validation: minimum characters for title & description * disable submit button when validation fails * form validation fixes * manually trigger onChange validation in publish & edit forms Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro>
- Loading branch information
1 parent
c57731c
commit 960c5b3
Showing
46 changed files
with
950 additions
and
438 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,25 @@ | ||
{ | ||
"description": "Update selected metadata of this data set. Updating metadata will create an on-chain transaction you have to approve in your wallet.", | ||
"form": { | ||
"success": "🎉 Successfully updated. 🎉", | ||
"successAction": "Close", | ||
"error": "Updating DDO failed.", | ||
"data": [ | ||
{ | ||
"name": "name", | ||
"label": "New Title", | ||
"placeholder": "e.g. Shapes of Desert Plants", | ||
"help": "Enter a concise title.", | ||
"required": true | ||
}, | ||
{ | ||
"name": "description", | ||
"label": "New Description", | ||
"help": "Add a thorough description with as much detail as possible. You can use [Markdown](https://daringfireball.net/projects/markdown/basics).", | ||
"type": "textarea", | ||
"rows": 10, | ||
"required": true | ||
} | ||
] | ||
} | ||
} |
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,18 @@ | ||
import React, { ReactElement } from 'react' | ||
|
||
export default function DebugOutput({ | ||
title, | ||
output | ||
}: { | ||
title: string | ||
output: any | ||
}): ReactElement { | ||
return ( | ||
<div> | ||
<h5>{title}</h5> | ||
<pre> | ||
<code>{JSON.stringify(output, null, 2)}</code> | ||
</pre> | ||
</div> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import Alert from '../atoms/Alert' | ||
import Button from '../atoms/Button' | ||
import Loader from '../atoms/Loader' | ||
import React, { ReactElement } from 'react' | ||
import styles from './MetadataFeedback.module.css' | ||
import SuccessConfetti from '../atoms/SuccessConfetti' | ||
|
||
interface Action { | ||
name: string | ||
onClick?: () => void | ||
to?: string | ||
} | ||
|
||
function ActionSuccess({ action }: { action: Action }) { | ||
const { name, onClick, to } = action | ||
|
||
return ( | ||
<Button | ||
style="primary" | ||
size="small" | ||
onClick={onClick || null} | ||
to={to || null} | ||
className={styles.action} | ||
> | ||
{name} | ||
</Button> | ||
) | ||
} | ||
|
||
function ActionError({ setError }: { setError: (error: string) => void }) { | ||
return ( | ||
<Button | ||
style="primary" | ||
size="small" | ||
className={styles.action} | ||
onClick={() => setError(undefined)} | ||
> | ||
Try Again | ||
</Button> | ||
) | ||
} | ||
|
||
export default function MetadataFeedback({ | ||
title, | ||
error, | ||
success, | ||
loading, | ||
successAction, | ||
setError | ||
}: { | ||
title: string | ||
error: string | ||
success: string | ||
loading?: string | ||
successAction: Action | ||
setError: (error: string) => void | ||
}): ReactElement { | ||
return ( | ||
<div className={styles.feedback}> | ||
<div className={styles.box}> | ||
<h3>{title}</h3> | ||
{error ? ( | ||
<> | ||
<Alert text={error} state="error" /> | ||
<ActionError setError={setError} /> | ||
</> | ||
) : success ? ( | ||
<SuccessConfetti | ||
success={success} | ||
action={<ActionSuccess action={successAction} />} | ||
/> | ||
) : ( | ||
<Loader message={loading} /> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} |
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.
960c5b3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: