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

Feature/issue474 algorithms timeout (#483)

* timeout added for algorithm publish

* publish algorithm fixes

* set termsAndConditions fix

Co-authored-by: claudia.holhos <claudia.holhos@hpm.ro>
This commit is contained in:
claudiaHash 2021-04-08 20:01:00 +03:00 committed by GitHub
parent 1d13000772
commit ccfb381d9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 3 deletions

View File

@ -46,6 +46,16 @@
"help": "Provide the tag for your Docker image.",
"required": false
},
{
"name": "timeout",
"label": "Timeout",
"help": "Define how long buyers should be able to download the algorithm again after the initial purchase.",
"placeholder": "Forever",
"type": "select",
"options": ["Forever", "1 day", "1 week", "1 month", "1 year"],
"sortOptions": false,
"required": true
},
{
"name": "entrypoint",
"label": "Entrypoint",

View File

@ -48,6 +48,7 @@ export interface MetadataPublishFormAlgorithm {
author: string
dockerImage: string
algorithmPrivacy: boolean
timeout: string
termsAndConditions: boolean
// ---- optional fields ----
image: string

View File

@ -100,7 +100,9 @@ export default function FormPublish(): ReactElement {
field: FormFieldProps
) {
const value =
field.type === 'checkbox' ? !JSON.parse(e.target.value) : e.target.value
field.type === 'checkbox' || field.type === 'terms'
? !JSON.parse(e.target.value)
: e.target.value
if (field.name === 'dockerImage') {
setSelectedDockerImage(e.target.value)
handleImageSelectChange(e.target.value)

View File

@ -159,6 +159,7 @@ export default function PublishPage({
) => void
): Promise<void> {
const metadata = transformPublishAlgorithmFormToMetadata(values)
const timeout = mapTimeoutStringToSeconds(values.timeout)
const validDockerImage =
values.dockerImage === 'custom image'
? await validateDockerImage(values.image, values.containerTag)
@ -169,7 +170,9 @@ export default function PublishPage({
const ddo = await publish(
(metadata as unknown) as Metadata,
values.algorithmPrivacy === true ? 'compute' : 'access'
values.algorithmPrivacy === true ? 'compute' : 'access',
undefined,
timeout
)
// Publish failed

View File

@ -10,6 +10,7 @@ export const validationSchema: Yup.SchemaOf<MetadataPublishFormAlgorithm> = Yup.
.required('Required'),
description: Yup.string().min(10).required('Required'),
files: Yup.array<FileMetadata>().required('Required').nullable(),
timeout: Yup.string().required('Required'),
dockerImage: Yup.string()
.matches(/node:latest|python:latest|custom image/g, {
excludeEmptyString: true
@ -38,5 +39,6 @@ export const initialValues: Partial<MetadataPublishFormAlgorithm> = {
description: '',
algorithmPrivacy: false,
termsAndConditions: false,
tags: ''
tags: '',
timeout: 'Forever'
}