From 92547533a5315f9164d16377c1ab0a95eb2450a4 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 19 Feb 2021 16:08:47 +0200 Subject: [PATCH] refactor publish page content --- content/pages/form-algorithm.json | 88 ++++++++++++++++++ content/pages/form-dataset.json | 79 ++++++++++++++++ content/pages/index.json | 5 + content/pages/publish.json | 84 ----------------- content/pages/publishAlgo.json | 93 ------------------- .../pages/Publish/FormAlgoPublish.tsx | 37 +++++++- src/components/pages/Publish/FormPublish.tsx | 37 +++++++- src/components/pages/Publish/index.tsx | 10 +- src/pages/publish.tsx | 49 +--------- 9 files changed, 242 insertions(+), 240 deletions(-) create mode 100644 content/pages/form-algorithm.json create mode 100644 content/pages/form-dataset.json create mode 100644 content/pages/index.json delete mode 100644 content/pages/publish.json delete mode 100644 content/pages/publishAlgo.json diff --git a/content/pages/form-algorithm.json b/content/pages/form-algorithm.json new file mode 100644 index 000000000..b4cf7bac0 --- /dev/null +++ b/content/pages/form-algorithm.json @@ -0,0 +1,88 @@ +{ + "title": "Publish", + "data": [ + { + "name": "name", + "label": "Title", + "placeholder": "e.g. Shapes of Desert Plants", + "help": "Enter a concise title.", + "required": true + }, + { + "name": "description", + "label": "Description", + "help": "Add a thorough description with as much detail as possible. You can use [Markdown](https://daringfireball.net/projects/markdown/basics).", + "type": "textarea", + "required": true + }, + { + "name": "files", + "label": "File", + "placeholder": "e.g. https://file.com/file.json", + "help": "Please provide a URL to your algorith file. This URL will be stored encrypted after publishing.", + "type": "files", + "required": true + }, + { + "name": "dockerImage", + "label": "Docker Image", + "placeholder": "e.g. python3.7", + "help": "Please select a predefined image to run your algorithm.", + "type": "select", + "options": ["node:pre-defined", "python:pre-defined", "custom image"], + "required": true + }, + { + "name": "image", + "label": "Image URL", + "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", + "required": false + }, + { + "name": "version", + "label": "Version", + "placeholder": "e.g. 10", + "help": "Provide the version for your image.", + "disabled": true, + "required": false + }, + { + "name": "entrypoint", + "label": "Entrypoint", + "placeholder": "e.g. python $ALGO", + "help": "Provide the entrypoint for your algorithm.", + "disabled": true, + "required": false + }, + { + "name": "algorithmPrivacy", + "label": "Algorithm Privacy", + "type": "checkbox", + "options": ["Keep my algorithm private"], + "required": false + }, + { + "name": "author", + "label": "Author", + "placeholder": "e.g. Jelly McJellyfish", + "help": "Give proper attribution for your algorith.", + "required": true + }, + { + "name": "tags", + "label": "Tags", + "placeholder": "e.g. logistics, ai", + "help": "Separate tags with comma." + }, + { + "name": "termsAndConditions", + "label": "Terms & Conditions", + "type": "terms", + "options": ["I agree to these Terms and Conditions"], + "required": true + } + ], + "success": "Algorithm Published!" +} diff --git a/content/pages/form-dataset.json b/content/pages/form-dataset.json new file mode 100644 index 000000000..6f85d26e4 --- /dev/null +++ b/content/pages/form-dataset.json @@ -0,0 +1,79 @@ +{ + "title": "Publish", + "data": [ + { + "name": "name", + "label": "Title", + "placeholder": "e.g. Shapes of Desert Plants", + "help": "Enter a concise title.", + "required": true + }, + { + "name": "description", + "label": "Description", + "help": "Add a thorough description with as much detail as possible. You can use [Markdown](https://daringfireball.net/projects/markdown/basics).", + "type": "textarea", + "required": true + }, + { + "name": "files", + "label": "File", + "placeholder": "e.g. https://file.com/file.json", + "help": "Please provide a URL to your data set file. This URL will be stored encrypted after publishing.", + "type": "files", + "required": true + }, + { + "name": "links", + "label": "Sample file", + "placeholder": "e.g. https://file.com/samplefile.json", + "help": "Please provide a URL to a sample of your data set file. This file should reveal the data structure of your data set, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing.", + "type": "files" + }, + { + "name": "access", + "label": "Access Type", + "help": "Choose how you want your files to be accessible for the specified price.", + "type": "select", + "options": ["Download"], + "required": true + }, + { + "name": "timeout", + "label": "Timeout", + "help": "Define how long buyers should be able to download the data set again after the initial purchase.", + "type": "select", + "options": ["Forever", "1 day", "1 week", "1 month", "1 year"], + "sortOptions": false, + "required": true + }, + { + "name": "dataTokenOptions", + "label": "Datatoken Name & Symbol", + "type": "datatoken", + "help": "The datatoken for this data set will be created with this name & symbol.", + "required": true + }, + { + "name": "author", + "label": "Author", + "placeholder": "e.g. Jelly McJellyfish", + "help": "Give proper attribution for your data set.", + "required": true + }, + { + "name": "tags", + "label": "Tags", + "placeholder": "e.g. logistics, ai", + "help": "Separate tags with comma." + }, + { + "name": "termsAndConditions", + "label": "Terms & Conditions", + "type": "terms", + "options": ["I agree to these Terms and Conditions"], + "required": true + } + ], + "success": "Asset Created!" +} diff --git a/content/pages/index.json b/content/pages/index.json new file mode 100644 index 000000000..36b3947f0 --- /dev/null +++ b/content/pages/index.json @@ -0,0 +1,5 @@ +{ + "title": "Publish", + "description": "Highlight the important features of your data set to make it more discoverable and catch the interest of data consumers.", + "warning": "Given the beta status, publishing on Ropsten or Rinkeby first is strongly recommended. Please familiarize yourself with [the market](https://oceanprotocol.com/technology/marketplaces), [the risks](https://blog.oceanprotocol.com/on-staking-on-data-in-ocean-market-3d8e09eb0a13), and the [Terms of Use](/terms)." +} diff --git a/content/pages/publish.json b/content/pages/publish.json deleted file mode 100644 index 8da56c3a0..000000000 --- a/content/pages/publish.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "title": "Publish", - "description": "Highlight the important features of your data set to make it more discoverable and catch the interest of data consumers.", - "warning": "Given the beta status, publishing on Ropsten or Rinkeby first is strongly recommended. Please familiarize yourself with [the market](https://oceanprotocol.com/technology/marketplaces), [the risks](https://blog.oceanprotocol.com/on-staking-on-data-in-ocean-market-3d8e09eb0a13), and the [Terms of Use](/terms).", - "form": { - "title": "Publish", - "data": [ - { - "name": "name", - "label": "Title", - "placeholder": "e.g. Shapes of Desert Plants", - "help": "Enter a concise title.", - "required": true - }, - { - "name": "description", - "label": "Description", - "help": "Add a thorough description with as much detail as possible. You can use [Markdown](https://daringfireball.net/projects/markdown/basics).", - "type": "textarea", - "required": true - }, - { - "name": "files", - "label": "File", - "placeholder": "e.g. https://file.com/file.json", - "help": "Please provide a URL to your data set file. This URL will be stored encrypted after publishing.", - "type": "files", - "required": true - }, - { - "name": "links", - "label": "Sample file", - "placeholder": "e.g. https://file.com/samplefile.json", - "help": "Please provide a URL to a sample of your data set file. This file should reveal the data structure of your data set, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing.", - "type": "files" - }, - { - "name": "access", - "label": "Access Type", - "help": "Choose how you want your files to be accessible for the specified price.", - "type": "select", - "options": ["Download"], - "required": true - }, - { - "name": "timeout", - "label": "Timeout", - "help": "Define how long buyers should be able to download the data set again after the initial purchase.", - "type": "select", - "options": ["Forever", "1 day", "1 week", "1 month", "1 year"], - "sortOptions": false, - "required": true - }, - { - "name": "dataTokenOptions", - "label": "Datatoken Name & Symbol", - "type": "datatoken", - "help": "The datatoken for this data set will be created with this name & symbol.", - "required": true - }, - { - "name": "author", - "label": "Author", - "placeholder": "e.g. Jelly McJellyfish", - "help": "Give proper attribution for your data set.", - "required": true - }, - { - "name": "tags", - "label": "Tags", - "placeholder": "e.g. logistics, ai", - "help": "Separate tags with comma." - }, - { - "name": "termsAndConditions", - "label": "Terms & Conditions", - "type": "terms", - "options": ["I agree to these Terms and Conditions"], - "required": true - } - ], - "success": "Asset Created!" - } -} diff --git a/content/pages/publishAlgo.json b/content/pages/publishAlgo.json deleted file mode 100644 index 6cd0b2754..000000000 --- a/content/pages/publishAlgo.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "title": "Publish", - "description": "Highlight the important features of your algorith to make it more discoverable and catch the interest of data consumers.", - "warning": "Given the beta status, publishing on Ropsten or Rinkeby first is strongly recommended. Please familiarize yourself with [the market](https://oceanprotocol.com/technology/marketplaces), [the risks](https://blog.oceanprotocol.com/on-staking-on-data-in-ocean-market-3d8e09eb0a13), and the [Terms of Use](/terms).", - "form": { - "title": "Publish", - "data": [ - { - "name": "name", - "label": "Title", - "placeholder": "e.g. Shapes of Desert Plants", - "help": "Enter a concise title.", - "required": true - }, - { - "name": "description", - "label": "Description", - "help": "Add a thorough description with as much detail as possible. You can use [Markdown](https://daringfireball.net/projects/markdown/basics).", - "type": "textarea", - "required": true - }, - { - "name": "files", - "label": "File", - "placeholder": "e.g. https://file.com/file.json", - "help": "Please provide a URL to your algorith file. This URL will be stored encrypted after publishing.", - "type": "files", - "required": true - }, - { - "name": "dockerImage", - "label": "Docker Image", - "placeholder": "e.g. python3.7", - "help": "Please select a predefined image to run your algorithm.", - "type": "select", - "options": ["node:pre-defined", "python:pre-defined", "custom image"], - "required": true - }, - { - "name": "image", - "label": "Image URL", - "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", - "required": false - }, - { - "name": "version", - "label": "Version", - "placeholder": "e.g. 10", - "help": "Provide the version for your image.", - "disabled": true, - "required": false - }, - { - "name": "entrypoint", - "label": "Entrypoint", - "placeholder": "e.g. python $ALGO", - "help": "Provide the entrypoint for your algorithm.", - "disabled": true, - "required": false - }, - { - "name": "algorithmPrivacy", - "label": "Algorithm Privacy", - "type": "checkbox", - "options": ["Keep my algorithm private"], - "required": false - }, - { - "name": "author", - "label": "Author", - "placeholder": "e.g. Jelly McJellyfish", - "help": "Give proper attribution for your algorith.", - "required": true - }, - { - "name": "tags", - "label": "Tags", - "placeholder": "e.g. logistics, ai", - "help": "Separate tags with comma." - }, - { - "name": "termsAndConditions", - "label": "Terms & Conditions", - "type": "terms", - "options": ["I agree to these Terms and Conditions"], - "required": true - } - ], - "success": "Algorithm Published!" - } -} diff --git a/src/components/pages/Publish/FormAlgoPublish.tsx b/src/components/pages/Publish/FormAlgoPublish.tsx index 051d73423..61b56fbad 100644 --- a/src/components/pages/Publish/FormAlgoPublish.tsx +++ b/src/components/pages/Publish/FormAlgoPublish.tsx @@ -1,4 +1,5 @@ import React, { ReactElement, useEffect, FormEvent, ChangeEvent } from 'react' +import { useStaticQuery, graphql } from 'gatsby' import styles from './FormPublish.module.css' import { useOcean } from '@oceanprotocol/react' import { useFormikContext, Field, Form, FormikContextType } from 'formik' @@ -7,11 +8,37 @@ import Button from '../../atoms/Button' import { FormContent, FormFieldProps } from '../../../@types/Form' import { AlgorithmPublishForm } from '../../../@types/MetaData' -export default function FormPublish({ - content -}: { - content: FormContent -}): ReactElement { +const query = graphql` + query { + content: allFile( + filter: { relativePath: { eq: "pages/form-algorithm.json" } } + ) { + edges { + node { + childPagesJson { + title + data { + name + placeholder + label + help + type + required + disabled + sortOptions + options + } + warning + } + } + } + } + } +` + +export default function FormPublish({}: {}): ReactElement { + const data = useStaticQuery(query) + const content: FormContent = data.content.edges[0].node.childPagesJson const { ocean, account } = useOcean() const { status, diff --git a/src/components/pages/Publish/FormPublish.tsx b/src/components/pages/Publish/FormPublish.tsx index 80fe85c81..5ba4864a8 100644 --- a/src/components/pages/Publish/FormPublish.tsx +++ b/src/components/pages/Publish/FormPublish.tsx @@ -1,4 +1,5 @@ import React, { ReactElement, useEffect, FormEvent, ChangeEvent } from 'react' +import { useStaticQuery, graphql } from 'gatsby' import styles from './FormPublish.module.css' import { useOcean } from '@oceanprotocol/react' import { useFormikContext, Field, Form, FormikContextType } from 'formik' @@ -7,11 +8,37 @@ import Button from '../../atoms/Button' import { FormContent, FormFieldProps } from '../../../@types/Form' import { MetadataPublishForm } from '../../../@types/MetaData' -export default function FormPublish({ - content -}: { - content: FormContent -}): ReactElement { +const query = graphql` + query { + content: allFile( + filter: { relativePath: { eq: "pages/form-dataset.json" } } + ) { + edges { + node { + childPagesJson { + title + data { + name + placeholder + label + help + type + required + disabled + sortOptions + options + } + warning + } + } + } + } + } +` + +export default function FormPublish({}: {}): ReactElement { + const data = useStaticQuery(query) + const content: FormContent = data.content.edges[0].node.childPagesJson const { ocean, account } = useOcean() const { status, diff --git a/src/components/pages/Publish/index.tsx b/src/components/pages/Publish/index.tsx index 33b8cb3ea..42418ecb7 100644 --- a/src/components/pages/Publish/index.tsx +++ b/src/components/pages/Publish/index.tsx @@ -37,11 +37,9 @@ import Button from '../../atoms/Button' const formName = 'ocean-publish-form' export default function PublishPage({ - content, - contentAlgoPublish + content }: { - content: { warning: string; form: FormContent } - contentAlgoPublish: { warning: string; form: FormContent } + content: { warning: string } }): ReactElement { const { debug } = useUserPreferences() const { publish, publishError, isLoading, publishStepText } = usePublish() @@ -184,9 +182,9 @@ export default function PublishPage({ />
{publishType === TypeOfPublish.dataset ? ( - + ) : ( - + )}