From 0fb4e630c1ca94bfa2219619e47e6bc53a0d0bb2 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 4 Nov 2021 11:14:48 +0100 Subject: [PATCH] metadata tweaks --- src/components/Publish/Navigation/index.tsx | 8 ++++-- src/components/Publish/_constants.tsx | 32 ++++++++++----------- src/components/Publish/_types.ts | 3 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/components/Publish/Navigation/index.tsx b/src/components/Publish/Navigation/index.tsx index 004170cb3..efd590a93 100644 --- a/src/components/Publish/Navigation/index.tsx +++ b/src/components/Publish/Navigation/index.tsx @@ -5,8 +5,12 @@ import { wizardSteps } from '../_constants' import styles from './index.module.css' export default function Navigation(): ReactElement { - const { values, setFieldValue }: FormikContextType = - useFormikContext() + const { + values, + errors, + touched, + setFieldValue + }: FormikContextType = useFormikContext() function handleStepClick(step: number) { setFieldValue('step', step) diff --git a/src/components/Publish/_constants.tsx b/src/components/Publish/_constants.tsx index a62b39e47..93b2df13a 100644 --- a/src/components/Publish/_constants.tsx +++ b/src/components/Publish/_constants.tsx @@ -34,8 +34,8 @@ export const wizardSteps: StepContent[] = [ export const initialValues: Partial = { step: 1, - type: 'dataset', metadata: { + type: 'dataset', name: '', author: '', description: '', @@ -69,6 +69,9 @@ export const initialValues: Partial = { } const validationMetadata = { + type: Yup.string() + .matches(/dataset|algorithm/g, { excludeEmptyString: true }) + .required('Required'), name: Yup.string() .min(4, (param) => `Title must be at least ${param.min} characters`) .required('Required'), @@ -85,16 +88,11 @@ const validationService = { .required('Enter a valid URL and click "ADD FILE"') .nullable(), links: Yup.array().nullable(), - dataTokenOptions: Yup.object() - .shape({ - name: Yup.string(), - symbol: Yup.string() - }) - .required('Required'), + dataTokenOptions: Yup.object().shape({ + name: Yup.string(), + symbol: Yup.string() + }), timeout: Yup.string().required('Required'), - type: Yup.string() - .matches(/Dataset|Algorithm/g, { excludeEmptyString: true }) - .required('Required'), access: Yup.string() .matches(/Compute|Download/g, { excludeEmptyString: true }) .required('Required'), @@ -123,13 +121,13 @@ const validationPricing = { .nullable() } -export const validationSchema: Yup.SchemaOf = Yup.object() - .shape({ - metadata: Yup.object().shape(validationMetadata), - services: Yup.array().of(Yup.object().shape(validationService)), - pricing: Yup.object().shape(validationPricing) - }) - .defined() +// export const validationSchema: Yup.SchemaOf = +export const validationSchema: Yup.SchemaOf = Yup.object().shape({ + step: Yup.number(), + metadata: Yup.object().shape(validationMetadata), + services: Yup.array().of(Yup.object().shape(validationService)), + pricing: Yup.object().shape(validationPricing) +}) // export const validationSchemaAlgo: Yup.SchemaOf = // Yup.object() diff --git a/src/components/Publish/_types.ts b/src/components/Publish/_types.ts index d2f8c43c1..91657128a 100644 --- a/src/components/Publish/_types.ts +++ b/src/components/Publish/_types.ts @@ -16,9 +16,8 @@ export interface FormPublishService { export interface FormPublishData { step: number - steps: number - type: 'dataset' | 'algorithm' metadata: { + type: 'dataset' | 'algorithm' | string name: string description: string author: string