1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01: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.", "help": "Provide the tag for your Docker image.",
"required": false "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", "name": "entrypoint",
"label": "Entrypoint", "label": "Entrypoint",

View File

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

View File

@ -100,7 +100,9 @@ export default function FormPublish(): ReactElement {
field: FormFieldProps field: FormFieldProps
) { ) {
const value = 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') { if (field.name === 'dockerImage') {
setSelectedDockerImage(e.target.value) setSelectedDockerImage(e.target.value)
handleImageSelectChange(e.target.value) handleImageSelectChange(e.target.value)

View File

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

View File

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