diff --git a/content/pages/publishAlgo.json b/content/pages/publishAlgo.json index 4132cd889..28cb46dce 100644 --- a/content/pages/publishAlgo.json +++ b/content/pages/publishAlgo.json @@ -36,6 +36,13 @@ "options": ["NodeJS", "Python 3.7"], "required": true }, + { + "name": "algorithmPrivacy", + "label": "Algorithm Privacy", + "type": "checkbox", + "options": ["Keep my algorithm private"], + "required": false + }, { "name": "author", "label": "Author", diff --git a/src/@types/MetaData.d.ts b/src/@types/MetaData.d.ts index 80a585a28..9ae93bfca 100644 --- a/src/@types/MetaData.d.ts +++ b/src/@types/MetaData.d.ts @@ -46,6 +46,7 @@ export interface AlgorithmPublishForm { files: string | File[] author: string dockerImage: string + algorithmPrivacy: boolean termsAndConditions: boolean // ---- optional fields ---- tags?: string diff --git a/src/components/molecules/MetadataPreview.module.css b/src/components/molecules/MetadataPreview.module.css index 3cbb49b86..70cf4f43a 100644 --- a/src/components/molecules/MetadataPreview.module.css +++ b/src/components/molecules/MetadataPreview.module.css @@ -13,6 +13,13 @@ grid-template-columns: 1fr 1fr; } +.metaAlgorithm { + display: grid; + gap: var(--spacer); + grid-template-columns: 1fr 1fr; + margin-bottom: var(--spacer/2); +} + .previewTitle { font-size: var(--font-size-small); text-transform: uppercase; diff --git a/src/components/molecules/MetadataPreview.tsx b/src/components/molecules/MetadataPreview.tsx index 6b72f338f..d2330cd31 100644 --- a/src/components/molecules/MetadataPreview.tsx +++ b/src/components/molecules/MetadataPreview.tsx @@ -59,6 +59,8 @@ function MetaFull({ values }: { values: Partial }) { key.includes('links') || key.includes('termsAndConditions') || key.includes('dataTokenOptions') || + key.includes('dockerImage') || + key.includes('algorithmPrivacy') || value === undefined || value === '' ) @@ -146,7 +148,18 @@ export function MetadataAlgorithmPreview({ {values.tags && } - +
+ {values.dockerImage && ( + + )} + {values.algorithmPrivacy && ( + + )} +
) diff --git a/src/components/pages/Publish/FormAlgoPublish.tsx b/src/components/pages/Publish/FormAlgoPublish.tsx index 5307c6ff9..f8686db94 100644 --- a/src/components/pages/Publish/FormAlgoPublish.tsx +++ b/src/components/pages/Publish/FormAlgoPublish.tsx @@ -39,8 +39,12 @@ export default function FormPublish({ e: ChangeEvent, field: FormFieldProps ) { + const value = + field.type === 'checkbox' + ? !Boolean(JSON.parse(e.target.value)) + : e.target.value validateField(field.name) - setFieldValue(field.name, e.target.value) + setFieldValue(field.name, value) } const resetFormAndClearStorage = (e: FormEvent) => { diff --git a/src/components/pages/Publish/index.tsx b/src/components/pages/Publish/index.tsx index dd65b1531..33b8cb3ea 100644 --- a/src/components/pages/Publish/index.tsx +++ b/src/components/pages/Publish/index.tsx @@ -112,7 +112,10 @@ export default function PublishPage({ try { Logger.log('Publish Algorithm with ', metadata) - const ddo = await publish((metadata as unknown) as Metadata, 'access') + const ddo = await publish( + (metadata as unknown) as Metadata, + values.algorithmPrivacy === true ? 'compute' : 'access' + ) // Publish failed if (!ddo || publishError) { diff --git a/src/models/FormAlgoPublish.ts b/src/models/FormAlgoPublish.ts index 04c31d53b..9d9acf368 100644 --- a/src/models/FormAlgoPublish.ts +++ b/src/models/FormAlgoPublish.ts @@ -16,6 +16,7 @@ export const validationSchema: Yup.SchemaOf = Yup.object() author: Yup.string().required('Required'), termsAndConditions: Yup.boolean().required('Required'), // ---- optional fields ---- + algorithmPrivacy: Yup.boolean().nullable(), tags: Yup.string().nullable(), links: Yup.array().nullable() }) @@ -27,6 +28,7 @@ export const initialValues: Partial = { dockerImage: '', files: '', description: '', + algorithmPrivacy: false, termsAndConditions: false, tags: '' }