1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

Keep algorithm private checkbox fixes (#1174)

* fix set access inside publish form

* added initial value for service access to fix continue button disabled

* removed compute environment options field

* removed compute options from form.json

* update access and algorithmPrivacy fields based on asset type

Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
This commit is contained in:
Norbi 2022-03-16 14:52:05 +02:00 committed by GitHub
parent f2ecf1666b
commit 822cec3753
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 13 deletions

View File

@ -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
}
]
},

View File

@ -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<FormPublishData>()
const { values, setFieldValue } = useFormikContext<FormPublishData>()
// 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 (

View File

@ -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',

View File

@ -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