mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
wrapping publish in permissions wrapper
This commit is contained in:
parent
f74ec8dce5
commit
440afbdc05
@ -94,8 +94,8 @@ function SectionQueryResult({
|
||||
|
||||
export default function HomePage(): ReactElement {
|
||||
return (
|
||||
<>
|
||||
<Permission eventType="browse">
|
||||
<Permission eventType="browse">
|
||||
<>
|
||||
<Container narrow className={styles.searchWrap}>
|
||||
<SearchBar size="large" />
|
||||
</Container>
|
||||
@ -127,7 +127,7 @@ export default function HomePage(): ReactElement {
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</Permission>
|
||||
</>
|
||||
</>
|
||||
</Permission>
|
||||
)
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import React, { ReactElement, useState, useEffect } from 'react'
|
||||
import Permission from '../../organisms/Permission'
|
||||
import { Formik, FormikState } from 'formik'
|
||||
import { usePublish } from '../../../hooks/usePublish'
|
||||
import styles from './index.module.css'
|
||||
@ -216,86 +217,92 @@ export default function PublishPage({
|
||||
}
|
||||
|
||||
return isInPurgatory && purgatoryData ? null : (
|
||||
<Formik
|
||||
initialValues={
|
||||
publishType === 'dataset' ? datasetInitialValues : algoInitialValues
|
||||
}
|
||||
initialStatus="empty"
|
||||
validationSchema={
|
||||
publishType === 'dataset' ? validationSchema : validationSchemaAlgorithm
|
||||
}
|
||||
onSubmit={async (values, { resetForm }) => {
|
||||
// move user's focus to top of screen
|
||||
window.scrollTo({ top: 0, left: 0, behavior: 'smooth' })
|
||||
// kick off publishing
|
||||
publishType === 'dataset'
|
||||
? await handleSubmit(values, resetForm)
|
||||
: await handleAlgorithmSubmit(values, resetForm)
|
||||
}}
|
||||
enableReinitialize
|
||||
>
|
||||
{({ values }) => {
|
||||
const tabs = [
|
||||
{
|
||||
title: 'Data Set',
|
||||
content: <TabContent values={values} publishType={publishType} />
|
||||
},
|
||||
{
|
||||
title: 'Algorithm',
|
||||
content: <TabContent values={values} publishType={publishType} />
|
||||
}
|
||||
]
|
||||
<Permission eventType="publish">
|
||||
<Formik
|
||||
initialValues={
|
||||
publishType === 'dataset' ? datasetInitialValues : algoInitialValues
|
||||
}
|
||||
initialStatus="empty"
|
||||
validationSchema={
|
||||
publishType === 'dataset'
|
||||
? validationSchema
|
||||
: validationSchemaAlgorithm
|
||||
}
|
||||
onSubmit={async (values, { resetForm }) => {
|
||||
// move user's focus to top of screen
|
||||
window.scrollTo({ top: 0, left: 0, behavior: 'smooth' })
|
||||
// kick off publishing
|
||||
publishType === 'dataset'
|
||||
? await handleSubmit(values, resetForm)
|
||||
: await handleAlgorithmSubmit(values, resetForm)
|
||||
}}
|
||||
enableReinitialize
|
||||
>
|
||||
{({ values }) => {
|
||||
const tabs = [
|
||||
{
|
||||
title: 'Data Set',
|
||||
content: <TabContent values={values} publishType={publishType} />
|
||||
},
|
||||
{
|
||||
title: 'Algorithm',
|
||||
content: <TabContent values={values} publishType={publishType} />
|
||||
}
|
||||
]
|
||||
|
||||
return (
|
||||
<>
|
||||
<Persist
|
||||
name={
|
||||
publishType === 'dataset'
|
||||
? formNameDatasets
|
||||
: formNameAlgorithms
|
||||
}
|
||||
ignoreFields={['isSubmitting']}
|
||||
/>
|
||||
|
||||
{hasFeedback ? (
|
||||
<MetadataFeedback
|
||||
title={title}
|
||||
error={error}
|
||||
success={success}
|
||||
loading={publishStepText}
|
||||
setError={setError}
|
||||
successAction={{
|
||||
name: `Go to ${
|
||||
publishType === 'dataset' ? 'data set' : 'algorithm'
|
||||
} →`,
|
||||
to: `/asset/${did}`
|
||||
}}
|
||||
return (
|
||||
<>
|
||||
<Persist
|
||||
name={
|
||||
publishType === 'dataset'
|
||||
? formNameDatasets
|
||||
: formNameAlgorithms
|
||||
}
|
||||
ignoreFields={['isSubmitting']}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<Alert
|
||||
text={content.warning}
|
||||
state="info"
|
||||
className={styles.alert}
|
||||
/>
|
||||
|
||||
<Tabs
|
||||
className={styles.tabs}
|
||||
items={tabs}
|
||||
handleTabChange={(title) => {
|
||||
setPublishType(title.toLowerCase().replace(' ', '') as any)
|
||||
title === 'Algorithm'
|
||||
? setdatasetInitialValues(values)
|
||||
: setAlgoInitialValues(values)
|
||||
{hasFeedback ? (
|
||||
<MetadataFeedback
|
||||
title={title}
|
||||
error={error}
|
||||
success={success}
|
||||
loading={publishStepText}
|
||||
setError={setError}
|
||||
successAction={{
|
||||
name: `Go to ${
|
||||
publishType === 'dataset' ? 'data set' : 'algorithm'
|
||||
} →`,
|
||||
to: `/asset/${did}`
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
) : (
|
||||
<>
|
||||
<Alert
|
||||
text={content.warning}
|
||||
state="info"
|
||||
className={styles.alert}
|
||||
/>
|
||||
|
||||
{debug === true && <Debug values={values} />}
|
||||
</>
|
||||
)
|
||||
}}
|
||||
</Formik>
|
||||
<Tabs
|
||||
className={styles.tabs}
|
||||
items={tabs}
|
||||
handleTabChange={(title) => {
|
||||
setPublishType(
|
||||
title.toLowerCase().replace(' ', '') as any
|
||||
)
|
||||
title === 'Algorithm'
|
||||
? setdatasetInitialValues(values)
|
||||
: setAlgoInitialValues(values)
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{debug === true && <Debug values={values} />}
|
||||
</>
|
||||
)
|
||||
}}
|
||||
</Formik>
|
||||
</Permission>
|
||||
)
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ export default async function rbacRequest(eventType: string): Promise<boolean> {
|
||||
eventType,
|
||||
credentials: {
|
||||
token:
|
||||
'1eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJDWVdQTTJLY1NKUjJtV0o2ZFBqZTVKVmZ5YTZnZXdhVElVZDBabUoyWndFIn0.eyJleHAiOjE2MjE1MjAxNzcsImlhdCI6MTYyMTUxOTU3NywianRpIjoiZWFhZjQ2NmQtY2NhNy00MDlkLWEzNGItNzA1N2I2MjQ4NDFhIiwia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