add sample file to edit metadata form (#419)

* add sample file to edit metada form

* bump oceanjs to 0.11.2

* retrigger checks

* added updated package-lock.json

* bump react hooks to 0.5.4

* bump ocean.js to 0.11.4 and react hooks to 0.5.5
This commit is contained in:
Bogdan Fazakas 2021-03-09 18:52:40 +02:00 committed by GitHub
parent a137177be6
commit a4f4de84fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7676 additions and 8935 deletions

View File

@ -20,6 +20,13 @@
"rows": 10,
"required": true
},
{
"name": "links",
"label": "Sample file",
"placeholder": "e.g. https://file.com/samplefile.json",
"help": "Please provide a URL to a sample of your data set file. This file should reveal the data structure of your data set, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing.",
"type": "files"
},
{
"name": "timeout",
"label": "Timeout",

16583
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -27,8 +27,8 @@
"@coingecko/cryptoformat": "^0.4.2",
"@loadable/component": "^5.14.1",
"@oceanprotocol/art": "^3.0.0",
"@oceanprotocol/lib": "^0.10.1",
"@oceanprotocol/react": "^0.5.1",
"@oceanprotocol/lib": "^0.11.4",
"@oceanprotocol/react": "^0.5.5",
"@oceanprotocol/typographies": "^0.1.0",
"@portis/web3": "^3.0.3",
"@sindresorhus/slugify": "^1.0.0",

View File

@ -24,6 +24,13 @@ export interface PriceOptionsMarket extends PriceOptions {
swapFee: number
}
export interface MetadataEditForm {
name: string
description: string
timeout: string
links?: string | EditableMetadataLinks[]
}
export interface MetadataPublishForm {
// ---- required fields ----
name: string

View File

@ -1,7 +1,7 @@
import { useOcean } from '@oceanprotocol/react'
import { Formik } from 'formik'
import React, { ReactElement, useState } from 'react'
import { MetadataPublishForm } from '../../../../@types/MetaData'
import { MetadataEditForm } from '../../../../@types/MetaData'
import {
validationSchema,
getInitialValues
@ -66,14 +66,15 @@ export default function Edit({
const hasFeedback = error || success
async function handleSubmit(
values: Partial<MetadataPublishForm>,
values: Partial<MetadataEditForm>,
resetForm: () => void
) {
try {
// Construct new DDO with new values
const ddoEditedMetdata = await ocean.assets.editMetadata(ddo, {
title: values.name,
description: values.description
description: values.description,
links: typeof values.links !== 'string' ? values.links : []
})
if (!ddoEditedMetdata) {

View File

@ -1,5 +1,6 @@
import { MetadataMarket, MetadataPublishForm } from '../@types/MetaData'
import { secondsToString } from '../utils/metadata'
import { EditableMetadataLinks } from '@oceanprotocol/lib'
import * as Yup from 'yup'
export const validationSchema = Yup.object().shape({
@ -7,6 +8,7 @@ export const validationSchema = Yup.object().shape({
.min(4, (param) => `Title must be at least ${param.min} characters`)
.required('Required'),
description: Yup.string().required('Required').min(10),
links: Yup.array<EditableMetadataLinks[]>().nullable(),
timeout: Yup.string().required('Required')
})
@ -17,6 +19,7 @@ export function getInitialValues(
return {
name: metadata.main.name,
description: metadata.additionalInformation.description,
links: metadata.additionalInformation.links,
timeout: secondsToString(timeout)
}
}