mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
disable aditional docker image fields for pre-defined containers
This commit is contained in:
parent
707045071a
commit
243283e434
@ -40,6 +40,7 @@
|
|||||||
"name": "image",
|
"name": "image",
|
||||||
"label": "Image URL",
|
"label": "Image URL",
|
||||||
"placeholder": "e.g. node or https://hub.docker.com/_/node",
|
"placeholder": "e.g. node or https://hub.docker.com/_/node",
|
||||||
|
"disabled": true,
|
||||||
"help": "Provide the name of a docker image or the full url if you have it hosted in a 3rd party repo",
|
"help": "Provide the name of a docker image or the full url if you have it hosted in a 3rd party repo",
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
@ -48,6 +49,7 @@
|
|||||||
"label": "Version",
|
"label": "Version",
|
||||||
"placeholder": "e.g. 10",
|
"placeholder": "e.g. 10",
|
||||||
"help": "Provide the version for your image.",
|
"help": "Provide the version for your image.",
|
||||||
|
"disabled": true,
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -55,6 +57,7 @@
|
|||||||
"label": "Entrypoint",
|
"label": "Entrypoint",
|
||||||
"placeholder": "e.g. python $ALGO",
|
"placeholder": "e.g. python $ALGO",
|
||||||
"help": "Provide the entrypoint for your algorithm.",
|
"help": "Provide the entrypoint for your algorithm.",
|
||||||
|
"disabled": true,
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
1
src/@types/Form.d.ts
vendored
1
src/@types/Form.d.ts
vendored
@ -5,6 +5,7 @@ export interface FormFieldProps {
|
|||||||
options?: string[]
|
options?: string[]
|
||||||
sortOptions?: boolean
|
sortOptions?: boolean
|
||||||
required?: boolean
|
required?: boolean
|
||||||
|
disabled?: boolean
|
||||||
help?: string
|
help?: string
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
pattern?: string
|
pattern?: string
|
||||||
|
@ -33,10 +33,17 @@ export default function FormPublish({
|
|||||||
// setSubmitting(false)
|
// setSubmitting(false)
|
||||||
}, [setErrors, setTouched])
|
}, [setErrors, setTouched])
|
||||||
|
|
||||||
|
function setDisableFlag(flag: boolean) {
|
||||||
|
content.data.forEach((field) => {
|
||||||
|
if (field.disabled !== null) field.disabled = flag
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function handleImageSelectChange(imageSelected: string) {
|
function handleImageSelectChange(imageSelected: string) {
|
||||||
switch (imageSelected) {
|
switch (imageSelected) {
|
||||||
case 'node:pre-defined': {
|
case 'node:pre-defined': {
|
||||||
setFieldValue('dockerImage', imageSelected)
|
setFieldValue('dockerImage', imageSelected)
|
||||||
|
setDisableFlag(true)
|
||||||
setFieldValue('image', 'node')
|
setFieldValue('image', 'node')
|
||||||
setFieldValue('version', '10')
|
setFieldValue('version', '10')
|
||||||
setFieldValue('entrypoint', 'node $ALGO')
|
setFieldValue('entrypoint', 'node $ALGO')
|
||||||
@ -44,6 +51,7 @@ export default function FormPublish({
|
|||||||
}
|
}
|
||||||
case 'python:pre-defined': {
|
case 'python:pre-defined': {
|
||||||
setFieldValue('dockerImage', imageSelected)
|
setFieldValue('dockerImage', imageSelected)
|
||||||
|
setDisableFlag(true)
|
||||||
setFieldValue('image', 'oceanprotocol/algo_dockers')
|
setFieldValue('image', 'oceanprotocol/algo_dockers')
|
||||||
setFieldValue('version', 'python-panda')
|
setFieldValue('version', 'python-panda')
|
||||||
setFieldValue('entrypoint', 'python $ALGO')
|
setFieldValue('entrypoint', 'python $ALGO')
|
||||||
@ -51,6 +59,7 @@ export default function FormPublish({
|
|||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
setFieldValue('dockerImage', imageSelected)
|
setFieldValue('dockerImage', imageSelected)
|
||||||
|
setDisableFlag(false)
|
||||||
setFieldValue('image', '')
|
setFieldValue('image', '')
|
||||||
setFieldValue('version', '')
|
setFieldValue('version', '')
|
||||||
setFieldValue('entrypoint', '')
|
setFieldValue('entrypoint', '')
|
||||||
@ -65,7 +74,6 @@ export default function FormPublish({
|
|||||||
e: ChangeEvent<HTMLInputElement>,
|
e: ChangeEvent<HTMLInputElement>,
|
||||||
field: FormFieldProps
|
field: FormFieldProps
|
||||||
) {
|
) {
|
||||||
console.log(field)
|
|
||||||
const value =
|
const value =
|
||||||
field.type === 'checkbox' ? !JSON.parse(e.target.value) : e.target.value
|
field.type === 'checkbox' ? !JSON.parse(e.target.value) : e.target.value
|
||||||
if (field.name === 'dockerImage') {
|
if (field.name === 'dockerImage') {
|
||||||
@ -93,6 +101,7 @@ export default function FormPublish({
|
|||||||
<Field
|
<Field
|
||||||
key={field.name}
|
key={field.name}
|
||||||
{...field}
|
{...field}
|
||||||
|
disabled={field.disabled}
|
||||||
component={Input}
|
component={Input}
|
||||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
handleFieldChange(e, field)
|
handleFieldChange(e, field)
|
||||||
|
@ -34,6 +34,7 @@ export const contentQuery = graphql`
|
|||||||
help
|
help
|
||||||
type
|
type
|
||||||
required
|
required
|
||||||
|
disabled
|
||||||
sortOptions
|
sortOptions
|
||||||
options
|
options
|
||||||
}
|
}
|
||||||
@ -61,6 +62,7 @@ export const contentQuery = graphql`
|
|||||||
help
|
help
|
||||||
type
|
type
|
||||||
required
|
required
|
||||||
|
disabled
|
||||||
sortOptions
|
sortOptions
|
||||||
options
|
options
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user