diff --git a/src/components/organisms/AssetActions/index.tsx b/src/components/organisms/AssetActions/index.tsx index 3d1c38f12..cf2084ea4 100644 --- a/src/components/organisms/AssetActions/index.tsx +++ b/src/components/organisms/AssetActions/index.tsx @@ -3,7 +3,6 @@ import styles from './index.module.css' import Compute from './Compute' import Consume from './Consume' import { Logger } from '@oceanprotocol/lib' -import { ConfigHelperConfig } from '@oceanprotocol/lib/dist/node/utils/ConfigHelper' import Tabs from '../../atoms/Tabs' import { useOcean } from '@oceanprotocol/react' import compareAsBN from '../../../utils/compareAsBN' diff --git a/src/components/pages/Publish/PublishType.module.css b/src/components/pages/Publish/PublishType.module.css deleted file mode 100644 index 5f7809068..000000000 --- a/src/components/pages/Publish/PublishType.module.css +++ /dev/null @@ -1,29 +0,0 @@ -.tabElement, -button.tabElement, -.tabElement:hover, -.tabElement:active, -.tabElement:focus { - border: 1px solid var(--border-color); - text-transform: uppercase; - border-radius: var(--border-radius); - margin-right: calc(var(--spacer) / 6); - margin-bottom: calc(var(--spacer) / 6); - color: var(--color-secondary); - background: var(--background-body); - - /* the only thing not possible to overwrite button style="text" with more specifity of selectors, so sledgehammer */ - padding: calc(var(--spacer) / 5) !important; -} - -.tabElement:hover, -.tabElement:focus { - color: var(--font-color-text); - background: inherit; - transform: none; -} - -.tabElement.selected { - color: var(--background-body); - background: var(--font-color-text); - border-color: var(--background-body); -} diff --git a/src/components/pages/Publish/PublishType.tsx b/src/components/pages/Publish/PublishType.tsx deleted file mode 100644 index 0bb8370d8..000000000 --- a/src/components/pages/Publish/PublishType.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import React, { ReactElement, useEffect } from 'react' -import styles from './PublishType.module.css' -import classNames from 'classnames/bind' -import Button from '../../atoms/Button' - -const cx = classNames.bind(styles) - -export const TypeOfPublish = { - dataset: 'dataset', - algorithm: 'algorithm' -} as const -type TypeOfPublish = typeof TypeOfPublish[keyof typeof TypeOfPublish] - -export function PublishType({ - type, - setType -}: { - type: string - setType: React.Dispatch> -}): ReactElement { - useEffect(() => { - setType(TypeOfPublish.dataset) - }, []) - - return ( -
- {Object.keys(TypeOfPublish).map((key, index) => { - const tabElement = cx({ - [styles.selected]: key === type, - [styles.tabElement]: true - }) - return ( - - ) - })} -
- ) -} diff --git a/src/components/pages/Publish/index.module.css b/src/components/pages/Publish/index.module.css index 4a6d8a9df..162f5a277 100644 --- a/src/components/pages/Publish/index.module.css +++ b/src/components/pages/Publish/index.module.css @@ -1,3 +1,8 @@ +.tabs div[class*='tabContent'] { + padding-left: 0; + padding-right: 0; +} + .grid { display: grid; gap: calc(var(--spacer) * 1.5); diff --git a/src/components/pages/Publish/index.tsx b/src/components/pages/Publish/index.tsx index accbdd865..bb8cd99f9 100644 --- a/src/components/pages/Publish/index.tsx +++ b/src/components/pages/Publish/index.tsx @@ -4,9 +4,8 @@ import { usePublish, useOcean } from '@oceanprotocol/react' import styles from './index.module.css' import FormPublish from './FormPublish' import FormAlgoPublish from './FormAlgoPublish' -import { PublishType, TypeOfPublish } from './PublishType' import Web3Feedback from '../../molecules/Wallet/Feedback' -import { FormContent } from '../../../@types/Form' +import Tabs from '../../atoms/Tabs' import { initialValues, validationSchema } from '../../../models/FormPublish' import { initialValues as initialValuesAlgorithm, @@ -27,15 +26,42 @@ import { MetadataPublishFormAlgorithm } from '../../../@types/MetaData' import { useUserPreferences } from '../../../providers/UserPreferences' -import { Logger, Metadata } from '@oceanprotocol/lib' +import { Logger, Metadata, MetadataMain } from '@oceanprotocol/lib' import { Persist } from '../../atoms/FormikPersist' import Debug from './Debug' import Alert from '../../atoms/Alert' import MetadataFeedback from '../../molecules/MetadataFeedback' -import Button from '../../atoms/Button' const formName = 'ocean-publish-form' +function TabContent({ + publishType, + values +}: { + publishType: MetadataMain['type'] + values: + | Partial + | Partial +}) { + return ( +
+ {publishType === 'dataset' ? : } + + +
+ ) +} + export default function PublishPage({ content }: { @@ -48,12 +74,12 @@ export default function PublishPage({ const [error, setError] = useState() const [title, setTitle] = useState() const [did, setDid] = useState() - const [publishType, setPublishType] = useState() + const [publishType, setPublishType] = useState() const hasFeedback = isLoading || error || success useEffect(() => { - publishType === TypeOfPublish.dataset + publishType === 'dataset' ? setTitle('Publishing Data Set') : setTitle('Publishing Algorithm') }, [publishType]) @@ -137,73 +163,74 @@ export default function PublishPage({ return isInPurgatory && purgatoryData ? null : ( { // move user's focus to top of screen window.scrollTo({ top: 0, left: 0, behavior: 'smooth' }) // kick off publishing - publishType === TypeOfPublish.dataset + publishType === 'dataset' ? await handleSubmit(values, resetForm) : await handleAlgorithmSubmit(values, resetForm) }} > - {({ values }) => ( - <> - + {({ values }) => { + const tabs = [ + { + title: 'Data Set', + content: + }, + { + title: 'Algorithm', + content: + } + ] - {hasFeedback ? ( - - ) : ( - <> - - + + + {hasFeedback ? ( + -
- {publishType === TypeOfPublish.dataset ? ( - - ) : ( - - )} + ) : ( + <> + - -
- - )} +
+ + setPublishType( + title.toLowerCase().replace(' ', '') as any + ) + } + /> +
+ + )} - {debug === true && } - - )} + {debug === true && } + + ) + }}
) }