mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
move purgatory asset warning and hide most metadata (#287)
* move purgatory asset warning, hide most metadata * move copy, less metadata * refactor * move copy * delay fix
This commit is contained in:
parent
f843641a45
commit
5824d35ef7
10
content/purgatory.json
Normal file
10
content/purgatory.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"asset": {
|
||||
"title": "Data Set In Purgatory",
|
||||
"description": "Except for removing liquidity, no further actions are permitted on this data set and it will not be returned in any search. For more details go to [list-purgatory](https://github.com/oceanprotocol/list-purgatory)."
|
||||
},
|
||||
"account": {
|
||||
"title": "Account In Purgatory",
|
||||
"description": "No further actions are permitted by this account. For more details go to [list-purgatory](https://github.com/oceanprotocol/list-purgatory)."
|
||||
}
|
||||
}
|
@ -6,7 +6,24 @@ import styles from './App.module.css'
|
||||
import { useSiteMetadata } from '../hooks/useSiteMetadata'
|
||||
import { useOcean } from '@oceanprotocol/react'
|
||||
import Alert from './atoms/Alert'
|
||||
import { PageProps } from 'gatsby'
|
||||
import { graphql, PageProps, useStaticQuery } from 'gatsby'
|
||||
|
||||
const contentQuery = graphql`
|
||||
query AppQuery {
|
||||
purgatory: allFile(filter: { relativePath: { eq: "purgatory.json" } }) {
|
||||
edges {
|
||||
node {
|
||||
childContentJson {
|
||||
account {
|
||||
title
|
||||
description
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export default function App({
|
||||
children,
|
||||
@ -14,6 +31,9 @@ export default function App({
|
||||
}: {
|
||||
children: ReactElement
|
||||
}): ReactElement {
|
||||
const data = useStaticQuery(contentQuery)
|
||||
const purgatory = data.purgatory.edges[0].node.childContentJson.account
|
||||
|
||||
const { warning } = useSiteMetadata()
|
||||
const {
|
||||
isInPurgatory: isAccountInPurgatory,
|
||||
@ -29,11 +49,11 @@ export default function App({
|
||||
<Alert text={warning} state="info" />
|
||||
)}
|
||||
|
||||
{isAccountInPurgatory && accountPurgatory && (
|
||||
{isAccountInPurgatory && (
|
||||
<Alert
|
||||
title="Account In Purgatory"
|
||||
badge={`Reason: ${accountPurgatory.reason}`}
|
||||
text="No further actions are permitted by this account. For more details go to [list-purgatory](https://github.com/oceanprotocol/list-purgatory)."
|
||||
title={purgatory.title}
|
||||
badge={`Reason: ${accountPurgatory?.reason}`}
|
||||
text={purgatory.description}
|
||||
state="error"
|
||||
/>
|
||||
)}
|
||||
|
@ -8,17 +8,21 @@ import Publisher from '../../atoms/Publisher'
|
||||
|
||||
export default function MetaFull({
|
||||
ddo,
|
||||
metadata
|
||||
metadata,
|
||||
isInPurgatory
|
||||
}: {
|
||||
ddo: DDO
|
||||
metadata: MetadataMarket
|
||||
isInPurgatory: boolean
|
||||
}): ReactElement {
|
||||
const { id, publicKey } = ddo
|
||||
const { dateCreated, datePublished } = metadata.main
|
||||
|
||||
return (
|
||||
<div className={styles.metaFull}>
|
||||
{!isInPurgatory && (
|
||||
<MetaItem title="Data Author" content={metadata?.main.author} />
|
||||
)}
|
||||
<MetaItem
|
||||
title="Owner"
|
||||
content={<Publisher account={publicKey[0].owner} />}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { MetadataMarket } from '../../../@types/MetaData'
|
||||
import React, { ReactElement, useEffect, useState } from 'react'
|
||||
import { Link } from 'gatsby'
|
||||
import { graphql, Link, useStaticQuery } from 'gatsby'
|
||||
import Markdown from '../../atoms/Markdown'
|
||||
import MetaFull from './MetaFull'
|
||||
import MetaSecondary from './MetaSecondary'
|
||||
@ -14,6 +14,7 @@ import EtherscanLink from '../../atoms/EtherscanLink'
|
||||
import Bookmark from './Bookmark'
|
||||
import Publisher from '../../atoms/Publisher'
|
||||
import { useAsset } from '../../../providers/Asset'
|
||||
import Alert from '../../atoms/Alert'
|
||||
|
||||
export interface AssetContentProps {
|
||||
metadata: MetadataMarket
|
||||
@ -21,13 +22,33 @@ export interface AssetContentProps {
|
||||
path?: string
|
||||
}
|
||||
|
||||
const contentQuery = graphql`
|
||||
query AssetContentQuery {
|
||||
purgatory: allFile(filter: { relativePath: { eq: "purgatory.json" } }) {
|
||||
edges {
|
||||
node {
|
||||
childContentJson {
|
||||
asset {
|
||||
title
|
||||
description
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export default function AssetContent({
|
||||
metadata,
|
||||
ddo
|
||||
}: AssetContentProps): ReactElement {
|
||||
const data = useStaticQuery(contentQuery)
|
||||
const content = data.purgatory.edges[0].node.childContentJson.asset
|
||||
|
||||
const { debug } = useUserPreferences()
|
||||
const { accountId, networkId } = useOcean()
|
||||
const { owner } = useAsset()
|
||||
const { owner, isInPurgatory, purgatoryData } = useAsset()
|
||||
const { dtSymbol, dtName } = usePricing(ddo)
|
||||
const [showPricing, setShowPricing] = useState(false)
|
||||
const { price } = useAsset()
|
||||
@ -67,24 +88,29 @@ export default function AssetContent({
|
||||
Published By <Publisher account={owner} />
|
||||
</aside>
|
||||
|
||||
{isInPurgatory ? (
|
||||
<Alert
|
||||
title={content.title}
|
||||
badge={`Reason: ${purgatoryData?.reason}`}
|
||||
text={content.description}
|
||||
state="error"
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<Markdown
|
||||
className={styles.description}
|
||||
text={metadata?.additionalInformation?.description || ''}
|
||||
/>
|
||||
|
||||
<MetaSecondary metadata={metadata} />
|
||||
</>
|
||||
)}
|
||||
|
||||
<MetaFull ddo={ddo} metadata={metadata} />
|
||||
|
||||
<div className={styles.buttonGroup}>
|
||||
{/* <EditAction
|
||||
<MetaFull
|
||||
ddo={ddo}
|
||||
ocean={ocean}
|
||||
account={account}
|
||||
refetchMetadata={refetchMetadata}
|
||||
/> */}
|
||||
{/* <DeleteAction ddo={ddo} /> */}
|
||||
</div>
|
||||
metadata={metadata}
|
||||
isInPurgatory={isInPurgatory}
|
||||
/>
|
||||
|
||||
{debug === true && (
|
||||
<pre>
|
||||
|
@ -12,7 +12,7 @@ export default function PageTemplateAssetDetails({
|
||||
}: {
|
||||
uri: string
|
||||
}): ReactElement {
|
||||
const { isInPurgatory, purgatoryData } = useAsset()
|
||||
const { isInPurgatory } = useAsset()
|
||||
const [metadata, setMetadata] = useState<MetadataMarket>()
|
||||
const [title, setTitle] = useState<string>()
|
||||
const { ddo, error } = useAsset()
|
||||
@ -24,20 +24,12 @@ export default function PageTemplateAssetDetails({
|
||||
}
|
||||
|
||||
const { attributes } = ddo.findServiceByType('metadata')
|
||||
setTitle(attributes.main.name)
|
||||
setTitle(isInPurgatory ? '' : attributes.main.name)
|
||||
setMetadata((attributes as unknown) as MetadataMarket)
|
||||
}, [ddo, error])
|
||||
}, [ddo, error, isInPurgatory])
|
||||
|
||||
return ddo && metadata ? (
|
||||
<>
|
||||
{isInPurgatory && purgatoryData && (
|
||||
<Alert
|
||||
title="Data Set In Purgatory"
|
||||
badge={`Reason: ${purgatoryData.reason}`}
|
||||
text="Except for removing liquidity, no further actions are permitted on this data set and it will not be returned in any search. For more details go to [list-purgatory](https://github.com/oceanprotocol/list-purgatory)."
|
||||
state="error"
|
||||
/>
|
||||
)}
|
||||
<Page title={title} uri={uri}>
|
||||
<Router basepath="/asset">
|
||||
<AssetContent
|
||||
|
@ -150,6 +150,7 @@ function AssetProvider({
|
||||
setMetadata(attributes)
|
||||
setTitle(attributes?.main.name)
|
||||
setOwner(ddo.publicKey[0].owner)
|
||||
setIsInPurgatory(ddo.isInPurgatory === 'true')
|
||||
|
||||
await setPurgatory(ddo.id)
|
||||
await refreshPrice()
|
||||
|
Loading…
Reference in New Issue
Block a user