mirror of
https://github.com/oceanprotocol/market.git
synced 2024-11-15 09:44:53 +01:00
safeguard against assets without attributes.additionalInformation
This commit is contained in:
parent
5b36da54d2
commit
cda52aef1c
@ -15,11 +15,7 @@ const AssetTeaser: React.FC<AssetTeaserProps> = ({
|
|||||||
ddo,
|
ddo,
|
||||||
metadata
|
metadata
|
||||||
}: AssetTeaserProps) => {
|
}: AssetTeaserProps) => {
|
||||||
// TODO: hacky safeguard should be replaced with search query to account for pagination
|
|
||||||
if (!metadata.additionalInformation) return null
|
|
||||||
|
|
||||||
const { name } = metadata.main
|
const { name } = metadata.main
|
||||||
const { description } = metadata.additionalInformation
|
|
||||||
const isCompute = Boolean(ddo.findServiceByType('compute'))
|
const isCompute = Boolean(ddo.findServiceByType('compute'))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -30,7 +26,7 @@ const AssetTeaser: React.FC<AssetTeaserProps> = ({
|
|||||||
|
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<Dotdotdot tagName="p" clamp={3}>
|
<Dotdotdot tagName="p" clamp={3}>
|
||||||
{description || ''}
|
{metadata?.additionalInformation?.description || ''}
|
||||||
</Dotdotdot>
|
</Dotdotdot>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import Tabs from '../../atoms/Tabs'
|
|||||||
import { useOcean, useMetadata } from '@oceanprotocol/react'
|
import { useOcean, useMetadata } from '@oceanprotocol/react'
|
||||||
import compareAsBN from '../../../utils/compareAsBN'
|
import compareAsBN from '../../../utils/compareAsBN'
|
||||||
import Pool from './Pool'
|
import Pool from './Pool'
|
||||||
|
import { AdditionalInformationMarket } from '../../../@types/MetaData'
|
||||||
|
|
||||||
export default function AssetActions({ ddo }: { ddo: DDO }): ReactElement {
|
export default function AssetActions({ ddo }: { ddo: DDO }): ReactElement {
|
||||||
const { balance } = useOcean()
|
const { balance } = useOcean()
|
||||||
@ -15,7 +16,6 @@ export default function AssetActions({ ddo }: { ddo: DDO }): ReactElement {
|
|||||||
|
|
||||||
const isCompute = Boolean(ddo.findServiceByType('compute'))
|
const isCompute = Boolean(ddo.findServiceByType('compute'))
|
||||||
const { attributes } = ddo.findServiceByType('metadata')
|
const { attributes } = ddo.findServiceByType('metadata')
|
||||||
const { priceType } = attributes.additionalInformation
|
|
||||||
|
|
||||||
// Check user balance against price
|
// Check user balance against price
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -44,7 +44,10 @@ export default function AssetActions({ ddo }: { ddo: DDO }): ReactElement {
|
|||||||
title: 'Use',
|
title: 'Use',
|
||||||
content: UseContent
|
content: UseContent
|
||||||
},
|
},
|
||||||
(!priceType || priceType === 'dynamic') && {
|
(!((attributes.additionalInformation as unknown) as AdditionalInformationMarket)
|
||||||
|
?.priceType ||
|
||||||
|
((attributes.additionalInformation as unknown) as AdditionalInformationMarket)
|
||||||
|
?.priceType === 'dynamic') && {
|
||||||
title: 'Pool',
|
title: 'Pool',
|
||||||
content: <Pool ddo={ddo} />
|
content: <Pool ddo={ddo} />
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ export default function MetaFull({
|
|||||||
const { ocean, accountId } = useOcean()
|
const { ocean, accountId } = useOcean()
|
||||||
const { id, dataToken } = ddo
|
const { id, dataToken } = ddo
|
||||||
const { dateCreated, datePublished, author, license } = metadata.main
|
const { dateCreated, datePublished, author, license } = metadata.main
|
||||||
const { categories, copyrightHolder } = metadata.additionalInformation
|
|
||||||
|
|
||||||
const [dtName, setDtName] = useState<string>()
|
const [dtName, setDtName] = useState<string>()
|
||||||
const [dtSymbol, setDtSymbol] = useState<string>()
|
const [dtSymbol, setDtSymbol] = useState<string>()
|
||||||
@ -38,9 +37,17 @@ export default function MetaFull({
|
|||||||
return (
|
return (
|
||||||
<div className={styles.metaFull}>
|
<div className={styles.metaFull}>
|
||||||
<MetaItem title="Author" content={author} />
|
<MetaItem title="Author" content={author} />
|
||||||
<MetaItem title="Copyright Holder" content={copyrightHolder} />
|
<MetaItem
|
||||||
|
title="Copyright Holder"
|
||||||
|
content={metadata?.additionalInformation?.copyrightHolder}
|
||||||
|
/>
|
||||||
<MetaItem title="License" content={license} />
|
<MetaItem title="License" content={license} />
|
||||||
{categories && <MetaItem title="Category" content={categories[0]} />}
|
{metadata?.additionalInformation?.categories && (
|
||||||
|
<MetaItem
|
||||||
|
title="Category"
|
||||||
|
content={metadata?.additionalInformation?.categories[0]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<MetaItem title="Data Created" content={<Time date={dateCreated} />} />
|
<MetaItem title="Data Created" content={<Time date={dateCreated} />} />
|
||||||
|
|
||||||
<MetaItem
|
<MetaItem
|
||||||
|
@ -10,19 +10,21 @@ export default function MetaSecondary({
|
|||||||
}: {
|
}: {
|
||||||
metadata: MetadataMarket
|
metadata: MetadataMarket
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { links, tags } = metadata.additionalInformation
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside className={styles.metaSecondary}>
|
<aside className={styles.metaSecondary}>
|
||||||
{tags && tags.length > 0 && <Tags items={tags} />}
|
{metadata?.additionalInformation?.tags &&
|
||||||
|
metadata?.additionalInformation?.tags.length > 0 && (
|
||||||
|
<Tags items={metadata?.additionalInformation?.tags} />
|
||||||
|
)}
|
||||||
|
|
||||||
{links && links.length && (
|
{metadata?.additionalInformation?.links &&
|
||||||
|
metadata?.additionalInformation?.links.length && (
|
||||||
<div className={styles.samples}>
|
<div className={styles.samples}>
|
||||||
<MetaItem
|
<MetaItem
|
||||||
title="Sample Data"
|
title="Sample Data"
|
||||||
content={
|
content={
|
||||||
<Button
|
<Button
|
||||||
href={links[0].url}
|
href={metadata?.additionalInformation?.links[0].url}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
download
|
download
|
||||||
|
@ -21,7 +21,6 @@ export default function AssetContent({
|
|||||||
ddo
|
ddo
|
||||||
}: AssetContentProps): ReactElement {
|
}: AssetContentProps): ReactElement {
|
||||||
const { datePublished } = metadata.main
|
const { datePublished } = metadata.main
|
||||||
const { description, categories } = metadata.additionalInformation
|
|
||||||
const { debug } = useUserPreferences()
|
const { debug } = useUserPreferences()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -29,16 +28,19 @@ export default function AssetContent({
|
|||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<aside className={styles.meta}>
|
<aside className={styles.meta}>
|
||||||
<p>{datePublished && <Time date={datePublished} />}</p>
|
<p>{datePublished && <Time date={datePublished} />}</p>
|
||||||
{categories && categories.length && (
|
{metadata?.additionalInformation?.categories &&
|
||||||
|
metadata?.additionalInformation?.categories?.length && (
|
||||||
<p>
|
<p>
|
||||||
<Link to={`/search?categories=["${categories[0]}"]`}>
|
<Link
|
||||||
{categories[0]}
|
to={`/search?categories=["${metadata?.additionalInformation?.categories[0]}"]`}
|
||||||
|
>
|
||||||
|
{metadata?.additionalInformation?.categories[0]}
|
||||||
</Link>
|
</Link>
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<Markdown text={description || ''} />
|
<Markdown text={metadata?.additionalInformation?.description || ''} />
|
||||||
|
|
||||||
<MetaSecondary metadata={metadata} />
|
<MetaSecondary metadata={metadata} />
|
||||||
|
|
||||||
|
@ -14,8 +14,7 @@ async function getLatestAssets(metadataStoreUri: string) {
|
|||||||
|
|
||||||
const result = await metadataStore.queryMetadata({
|
const result = await metadataStore.queryMetadata({
|
||||||
page: 1,
|
page: 1,
|
||||||
// TODO: hacky workaround because some assets pushed by external devs are faulty
|
// TODO: reduce assets here, once faulty assets pushed by external devs are removed
|
||||||
// See molecules/AssetTeaser.tsx
|
|
||||||
offset: 100,
|
offset: 100,
|
||||||
query: {},
|
query: {},
|
||||||
sort: { created: -1 }
|
sort: { created: -1 }
|
||||||
|
Loading…
Reference in New Issue
Block a user