mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
disable checksum imput when fetched
This commit is contained in:
parent
af89fbbd01
commit
f2808b1dea
@ -8,12 +8,16 @@ import ImageInfo from './Info'
|
|||||||
import { getContainerChecksum } from '@utils/docker'
|
import { getContainerChecksum } from '@utils/docker'
|
||||||
|
|
||||||
export default function ContainerInput(props: InputProps): ReactElement {
|
export default function ContainerInput(props: InputProps): ReactElement {
|
||||||
const [field, meta, helpers] = useField(props.name)
|
const [field] = useField(props.name)
|
||||||
|
const [fieldChecksum, metaChecksum, helpersChecksum] = useField(
|
||||||
|
'metadata.dockerImageCustomChecksum'
|
||||||
|
)
|
||||||
|
|
||||||
|
const { values, setFieldError, setFieldValue } =
|
||||||
|
useFormikContext<FormPublishData>()
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const [isValid, setIsValid] = useState(false)
|
const [isValid, setIsValid] = useState(false)
|
||||||
const [checked, setChecked] = useState(false)
|
const [checked, setChecked] = useState(false)
|
||||||
const { values, setFieldError, setFieldValue } =
|
|
||||||
useFormikContext<FormPublishData>()
|
|
||||||
|
|
||||||
async function handleValidation(e: React.SyntheticEvent, container: string) {
|
async function handleValidation(e: React.SyntheticEvent, container: string) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@ -28,6 +32,7 @@ export default function ContainerInput(props: InputProps): ReactElement {
|
|||||||
const checksum = await getContainerChecksum(imageNname, tag)
|
const checksum = await getContainerChecksum(imageNname, tag)
|
||||||
if (checksum) {
|
if (checksum) {
|
||||||
setFieldValue('metadata.dockerImageCustomChecksum', checksum)
|
setFieldValue('metadata.dockerImageCustomChecksum', checksum)
|
||||||
|
helpersChecksum.setTouched(false)
|
||||||
setIsValid(true)
|
setIsValid(true)
|
||||||
}
|
}
|
||||||
setChecked(true)
|
setChecked(true)
|
||||||
@ -45,7 +50,7 @@ export default function ContainerInput(props: InputProps): ReactElement {
|
|||||||
setFieldValue('metadata.dockerImageCustomChecksum', '')
|
setFieldValue('metadata.dockerImageCustomChecksum', '')
|
||||||
setChecked(false)
|
setChecked(false)
|
||||||
setIsValid(false)
|
setIsValid(false)
|
||||||
helpers.setTouched(false)
|
helpersChecksum.setTouched(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { BoxSelectionOption } from '@shared/FormFields/BoxSelection'
|
import { BoxSelectionOption } from '@shared/FormFields/BoxSelection'
|
||||||
import Input from '@shared/FormInput'
|
import Input from '@shared/FormInput'
|
||||||
import { Field, useFormikContext } from 'formik'
|
import { Field, useField, useFormikContext } from 'formik'
|
||||||
import React, { ReactElement, useEffect } from 'react'
|
import React, { ReactElement, useEffect } from 'react'
|
||||||
import content from '../../../../content/publish/form.json'
|
import content from '../../../../content/publish/form.json'
|
||||||
import { FormPublishData } from '../_types'
|
import { FormPublishData } from '../_types'
|
||||||
@ -23,6 +23,8 @@ export default function MetadataFields(): ReactElement {
|
|||||||
// connect with Form state, use for conditional field rendering
|
// connect with Form state, use for conditional field rendering
|
||||||
const { values, setFieldValue } = useFormikContext<FormPublishData>()
|
const { values, setFieldValue } = useFormikContext<FormPublishData>()
|
||||||
|
|
||||||
|
const [field, meta] = useField('metadata.dockerImageCustomChecksum')
|
||||||
|
|
||||||
// BoxSelection component is not a Formik component
|
// BoxSelection component is not a Formik component
|
||||||
// so we need to handle checked state manually.
|
// so we need to handle checked state manually.
|
||||||
const assetTypeOptions: BoxSelectionOption[] = [
|
const assetTypeOptions: BoxSelectionOption[] = [
|
||||||
@ -129,6 +131,9 @@ export default function MetadataFields(): ReactElement {
|
|||||||
)}
|
)}
|
||||||
component={Input}
|
component={Input}
|
||||||
name="metadata.dockerImageCustomChecksum"
|
name="metadata.dockerImageCustomChecksum"
|
||||||
|
disabled={
|
||||||
|
values.metadata.dockerImageCustomChecksum && !meta.touched
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
{...getFieldContent(
|
{...getFieldContent(
|
||||||
|
Loading…
Reference in New Issue
Block a user