mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Add datatoken to algo publish form (#531)
* datatoken added to algo publish form * init datatoken option with non empty values * remove hacks * use nonempty data token initial values Co-authored-by: claudia.holhos <claudia.holhos@hpm.ro> Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
This commit is contained in:
parent
b89fcc99da
commit
c0157dff21
@ -56,6 +56,13 @@
|
||||
"sortOptions": false,
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "dataTokenOptions",
|
||||
"label": "Datatoken Name & Symbol",
|
||||
"type": "datatoken",
|
||||
"help": "The datatoken for this algorithm will be created with this name & symbol.",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "entrypoint",
|
||||
"label": "Entrypoint",
|
||||
|
1
src/@types/MetaData.d.ts
vendored
1
src/@types/MetaData.d.ts
vendored
@ -49,6 +49,7 @@ export interface MetadataPublishFormAlgorithm {
|
||||
dockerImage: string
|
||||
algorithmPrivacy: boolean
|
||||
timeout: string
|
||||
dataTokenOptions: DataTokenOptions
|
||||
termsAndConditions: boolean
|
||||
// ---- optional fields ----
|
||||
image: string
|
||||
|
@ -135,6 +135,11 @@ export function MetadataAlgorithmPreview({
|
||||
<h2 className={styles.previewTitle}>Preview</h2>
|
||||
<header>
|
||||
{values.name && <h3 className={styles.title}>{values.name}</h3>}
|
||||
{values.dataTokenOptions?.name && (
|
||||
<p
|
||||
className={styles.datatoken}
|
||||
>{`${values.dataTokenOptions.name} — ${values.dataTokenOptions.symbol}`}</p>
|
||||
)}
|
||||
{values.description && <Description description={values.description} />}
|
||||
|
||||
<div className={styles.asset}>
|
||||
|
@ -62,12 +62,11 @@ export default function FormPublish(): ReactElement {
|
||||
const [selectedDockerImage, setSelectedDockerImage] = useState<string>(
|
||||
initialValues.dockerImage
|
||||
)
|
||||
|
||||
// reset form validation on every mount
|
||||
useEffect(() => {
|
||||
setErrors({})
|
||||
setTouched({})
|
||||
|
||||
// setSubmitting(false)
|
||||
}, [setErrors, setTouched])
|
||||
|
||||
function handleImageSelectChange(imageSelected: string) {
|
||||
|
@ -95,9 +95,22 @@ export default function PublishPage({
|
||||
const [publishType, setPublishType] = useState<MetadataMain['type']>(
|
||||
'dataset'
|
||||
)
|
||||
|
||||
const hasFeedback = isLoading || error || success
|
||||
|
||||
const emptyAlgoDT = Object.values(algoInitialValues.dataTokenOptions).every(
|
||||
(value) => value === ''
|
||||
)
|
||||
const emptyDatasetDT = Object.values(
|
||||
datasetInitialValues.dataTokenOptions
|
||||
).every((value) => value === '')
|
||||
|
||||
if (emptyAlgoDT) {
|
||||
algoInitialValues.dataTokenOptions = datasetInitialValues.dataTokenOptions
|
||||
} else {
|
||||
if (emptyDatasetDT)
|
||||
datasetInitialValues.dataTokenOptions = algoInitialValues.dataTokenOptions
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
publishType === 'dataset'
|
||||
? setTitle('Publishing Data Set')
|
||||
@ -166,12 +179,12 @@ export default function PublishPage({
|
||||
: true
|
||||
try {
|
||||
if (validDockerImage) {
|
||||
Logger.log('Publish Algorithm with ', metadata)
|
||||
Logger.log('Publish algorithm with ', metadata, values.dataTokenOptions)
|
||||
|
||||
const ddo = await publish(
|
||||
(metadata as unknown) as Metadata,
|
||||
values.algorithmPrivacy === true ? 'compute' : 'access',
|
||||
undefined,
|
||||
values.dataTokenOptions,
|
||||
timeout
|
||||
)
|
||||
|
||||
|
@ -11,6 +11,12 @@ export const validationSchema: Yup.SchemaOf<MetadataPublishFormAlgorithm> = Yup.
|
||||
description: Yup.string().min(10).required('Required'),
|
||||
files: Yup.array<FileMetadata>().required('Required').nullable(),
|
||||
timeout: Yup.string().required('Required'),
|
||||
dataTokenOptions: Yup.object()
|
||||
.shape({
|
||||
name: Yup.string(),
|
||||
symbol: Yup.string()
|
||||
})
|
||||
.required('Required'),
|
||||
dockerImage: Yup.string()
|
||||
.matches(/node:latest|python:latest|custom image/g, {
|
||||
excludeEmptyString: true
|
||||
@ -31,6 +37,10 @@ export const validationSchema: Yup.SchemaOf<MetadataPublishFormAlgorithm> = Yup.
|
||||
export const initialValues: Partial<MetadataPublishFormAlgorithm> = {
|
||||
name: '',
|
||||
author: '',
|
||||
dataTokenOptions: {
|
||||
name: '',
|
||||
symbol: ''
|
||||
},
|
||||
dockerImage: 'node:latest',
|
||||
image: 'node',
|
||||
containerTag: 'latest',
|
||||
|
Loading…
Reference in New Issue
Block a user