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 { useSiteMetadata } from '../hooks/useSiteMetadata'
|
||||||
import { useOcean } from '@oceanprotocol/react'
|
import { useOcean } from '@oceanprotocol/react'
|
||||||
import Alert from './atoms/Alert'
|
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({
|
export default function App({
|
||||||
children,
|
children,
|
||||||
@ -14,6 +31,9 @@ export default function App({
|
|||||||
}: {
|
}: {
|
||||||
children: ReactElement
|
children: ReactElement
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
|
const data = useStaticQuery(contentQuery)
|
||||||
|
const purgatory = data.purgatory.edges[0].node.childContentJson.account
|
||||||
|
|
||||||
const { warning } = useSiteMetadata()
|
const { warning } = useSiteMetadata()
|
||||||
const {
|
const {
|
||||||
isInPurgatory: isAccountInPurgatory,
|
isInPurgatory: isAccountInPurgatory,
|
||||||
@ -29,11 +49,11 @@ export default function App({
|
|||||||
<Alert text={warning} state="info" />
|
<Alert text={warning} state="info" />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isAccountInPurgatory && accountPurgatory && (
|
{isAccountInPurgatory && (
|
||||||
<Alert
|
<Alert
|
||||||
title="Account In Purgatory"
|
title={purgatory.title}
|
||||||
badge={`Reason: ${accountPurgatory.reason}`}
|
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)."
|
text={purgatory.description}
|
||||||
state="error"
|
state="error"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -8,17 +8,21 @@ import Publisher from '../../atoms/Publisher'
|
|||||||
|
|
||||||
export default function MetaFull({
|
export default function MetaFull({
|
||||||
ddo,
|
ddo,
|
||||||
metadata
|
metadata,
|
||||||
|
isInPurgatory
|
||||||
}: {
|
}: {
|
||||||
ddo: DDO
|
ddo: DDO
|
||||||
metadata: MetadataMarket
|
metadata: MetadataMarket
|
||||||
|
isInPurgatory: boolean
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { id, publicKey } = ddo
|
const { id, publicKey } = ddo
|
||||||
const { dateCreated, datePublished } = metadata.main
|
const { dateCreated, datePublished } = metadata.main
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.metaFull}>
|
<div className={styles.metaFull}>
|
||||||
<MetaItem title="Data Author" content={metadata?.main.author} />
|
{!isInPurgatory && (
|
||||||
|
<MetaItem title="Data Author" content={metadata?.main.author} />
|
||||||
|
)}
|
||||||
<MetaItem
|
<MetaItem
|
||||||
title="Owner"
|
title="Owner"
|
||||||
content={<Publisher account={publicKey[0].owner} />}
|
content={<Publisher account={publicKey[0].owner} />}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { MetadataMarket } from '../../../@types/MetaData'
|
import { MetadataMarket } from '../../../@types/MetaData'
|
||||||
import React, { ReactElement, useEffect, useState } from 'react'
|
import React, { ReactElement, useEffect, useState } from 'react'
|
||||||
import { Link } from 'gatsby'
|
import { graphql, Link, useStaticQuery } from 'gatsby'
|
||||||
import Markdown from '../../atoms/Markdown'
|
import Markdown from '../../atoms/Markdown'
|
||||||
import MetaFull from './MetaFull'
|
import MetaFull from './MetaFull'
|
||||||
import MetaSecondary from './MetaSecondary'
|
import MetaSecondary from './MetaSecondary'
|
||||||
@ -14,6 +14,7 @@ import EtherscanLink from '../../atoms/EtherscanLink'
|
|||||||
import Bookmark from './Bookmark'
|
import Bookmark from './Bookmark'
|
||||||
import Publisher from '../../atoms/Publisher'
|
import Publisher from '../../atoms/Publisher'
|
||||||
import { useAsset } from '../../../providers/Asset'
|
import { useAsset } from '../../../providers/Asset'
|
||||||
|
import Alert from '../../atoms/Alert'
|
||||||
|
|
||||||
export interface AssetContentProps {
|
export interface AssetContentProps {
|
||||||
metadata: MetadataMarket
|
metadata: MetadataMarket
|
||||||
@ -21,13 +22,33 @@ export interface AssetContentProps {
|
|||||||
path?: string
|
path?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const contentQuery = graphql`
|
||||||
|
query AssetContentQuery {
|
||||||
|
purgatory: allFile(filter: { relativePath: { eq: "purgatory.json" } }) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
childContentJson {
|
||||||
|
asset {
|
||||||
|
title
|
||||||
|
description
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
export default function AssetContent({
|
export default function AssetContent({
|
||||||
metadata,
|
metadata,
|
||||||
ddo
|
ddo
|
||||||
}: AssetContentProps): ReactElement {
|
}: AssetContentProps): ReactElement {
|
||||||
|
const data = useStaticQuery(contentQuery)
|
||||||
|
const content = data.purgatory.edges[0].node.childContentJson.asset
|
||||||
|
|
||||||
const { debug } = useUserPreferences()
|
const { debug } = useUserPreferences()
|
||||||
const { accountId, networkId } = useOcean()
|
const { accountId, networkId } = useOcean()
|
||||||
const { owner } = useAsset()
|
const { owner, isInPurgatory, purgatoryData } = useAsset()
|
||||||
const { dtSymbol, dtName } = usePricing(ddo)
|
const { dtSymbol, dtName } = usePricing(ddo)
|
||||||
const [showPricing, setShowPricing] = useState(false)
|
const [showPricing, setShowPricing] = useState(false)
|
||||||
const { price } = useAsset()
|
const { price } = useAsset()
|
||||||
@ -67,25 +88,30 @@ export default function AssetContent({
|
|||||||
Published By <Publisher account={owner} />
|
Published By <Publisher account={owner} />
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<Markdown
|
{isInPurgatory ? (
|
||||||
className={styles.description}
|
<Alert
|
||||||
text={metadata?.additionalInformation?.description || ''}
|
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}
|
||||||
|
isInPurgatory={isInPurgatory}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<MetaSecondary metadata={metadata} />
|
|
||||||
|
|
||||||
<MetaFull ddo={ddo} metadata={metadata} />
|
|
||||||
|
|
||||||
<div className={styles.buttonGroup}>
|
|
||||||
{/* <EditAction
|
|
||||||
ddo={ddo}
|
|
||||||
ocean={ocean}
|
|
||||||
account={account}
|
|
||||||
refetchMetadata={refetchMetadata}
|
|
||||||
/> */}
|
|
||||||
{/* <DeleteAction ddo={ddo} /> */}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{debug === true && (
|
{debug === true && (
|
||||||
<pre>
|
<pre>
|
||||||
<code>{JSON.stringify(ddo, null, 2)}</code>
|
<code>{JSON.stringify(ddo, null, 2)}</code>
|
||||||
|
@ -12,7 +12,7 @@ export default function PageTemplateAssetDetails({
|
|||||||
}: {
|
}: {
|
||||||
uri: string
|
uri: string
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { isInPurgatory, purgatoryData } = useAsset()
|
const { isInPurgatory } = useAsset()
|
||||||
const [metadata, setMetadata] = useState<MetadataMarket>()
|
const [metadata, setMetadata] = useState<MetadataMarket>()
|
||||||
const [title, setTitle] = useState<string>()
|
const [title, setTitle] = useState<string>()
|
||||||
const { ddo, error } = useAsset()
|
const { ddo, error } = useAsset()
|
||||||
@ -24,20 +24,12 @@ export default function PageTemplateAssetDetails({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { attributes } = ddo.findServiceByType('metadata')
|
const { attributes } = ddo.findServiceByType('metadata')
|
||||||
setTitle(attributes.main.name)
|
setTitle(isInPurgatory ? '' : attributes.main.name)
|
||||||
setMetadata((attributes as unknown) as MetadataMarket)
|
setMetadata((attributes as unknown) as MetadataMarket)
|
||||||
}, [ddo, error])
|
}, [ddo, error, isInPurgatory])
|
||||||
|
|
||||||
return ddo && metadata ? (
|
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}>
|
<Page title={title} uri={uri}>
|
||||||
<Router basepath="/asset">
|
<Router basepath="/asset">
|
||||||
<AssetContent
|
<AssetContent
|
||||||
|
@ -150,6 +150,7 @@ function AssetProvider({
|
|||||||
setMetadata(attributes)
|
setMetadata(attributes)
|
||||||
setTitle(attributes?.main.name)
|
setTitle(attributes?.main.name)
|
||||||
setOwner(ddo.publicKey[0].owner)
|
setOwner(ddo.publicKey[0].owner)
|
||||||
|
setIsInPurgatory(ddo.isInPurgatory === 'true')
|
||||||
|
|
||||||
await setPurgatory(ddo.id)
|
await setPurgatory(ddo.id)
|
||||||
await refreshPrice()
|
await refreshPrice()
|
||||||
|
Loading…
Reference in New Issue
Block a user