diff --git a/content/publish/form.json b/content/publish/form.json index 7e2c85c89..6556d6473 100644 --- a/content/publish/form.json +++ b/content/publish/form.json @@ -141,15 +141,6 @@ "options": ["Forever", "1 day", "1 week", "1 month", "1 year"], "sortOptions": false, "required": true - }, - { - "name": "computeOptions", - "label": "Compute Environment", - "type": "radio", - "options": [ - "populated from computeEnvironmentDefaults in Publish/_constants & computeEnvironmentOptions in Publish/Services/" - ], - "required": true } ] }, diff --git a/src/components/Publish/Metadata/index.tsx b/src/components/Publish/Metadata/index.tsx index 46fd34f0b..3fd8e2c37 100644 --- a/src/components/Publish/Metadata/index.tsx +++ b/src/components/Publish/Metadata/index.tsx @@ -1,7 +1,7 @@ import { BoxSelectionOption } from '@shared/FormFields/BoxSelection' import Input from '@shared/FormInput' import { Field, useFormikContext } from 'formik' -import React, { ReactElement } from 'react' +import React, { ReactElement, useEffect } from 'react' import content from '../../../../content/publish/form.json' import { FormPublishData } from '../_types' import { getFieldContent } from '../_utils' @@ -17,7 +17,7 @@ const assetTypeOptionsTitles = getFieldContent( export default function MetadataFields(): ReactElement { // connect with Form state, use for conditional field rendering - const { values } = useFormikContext() + const { values, setFieldValue } = useFormikContext() // BoxSelection component is not a Formik component // so we need to handle checked state manually. @@ -45,6 +45,17 @@ export default function MetadataFields(): ReactElement { checked: values.metadata.dockerImage === `${preset.image}:${preset.tag}` })) + useEffect(() => { + setFieldValue( + 'services[0].access', + values.metadata.type === 'algorithm' ? 'compute' : 'access' + ) + setFieldValue( + 'services[0].algorithmPrivacy', + values.metadata.type === 'algorithm' + ) + }, [values.metadata.type]) + dockerImageOptions.push({ name: 'custom', title: 'Custom', checked: false }) return ( diff --git a/src/components/Publish/Services/index.tsx b/src/components/Publish/Services/index.tsx index a85ea7671..2262eaa31 100644 --- a/src/components/Publish/Services/index.tsx +++ b/src/components/Publish/Services/index.tsx @@ -43,7 +43,11 @@ export default function ServicesFields(): ReactElement { // Auto-change access type based on algo privacy boolean. // Could be also done later in transformPublishFormToDdo(). useEffect(() => { - if (!values.services[0].algorithmPrivacy) return + if ( + values.services[0].algorithmPrivacy === null || + values.services[0].algorithmPrivacy === undefined + ) + return setFieldValue( 'services[0].access', diff --git a/src/components/Publish/_constants.tsx b/src/components/Publish/_constants.tsx index c231eed3b..42b1ecb14 100644 --- a/src/components/Publish/_constants.tsx +++ b/src/components/Publish/_constants.tsx @@ -70,7 +70,7 @@ export const initialValues: FormPublishData = { links: [{ url: '' }], dataTokenOptions: { name: '', symbol: '' }, timeout: '', - access: '', + access: 'access', providerUrl: { url: 'https://provider.mainnet.oceanprotocol.com', valid: true