From c4e71173bae546f4cfc8c55fd96c0aef09324951 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 12 Sep 2019 11:11:47 +0200 Subject: [PATCH] fix error output on asset details loading --- .../templates/Asset/AssetDetails.tsx | 168 ++++++++---------- .../src/components/templates/Asset/index.tsx | 5 +- 2 files changed, 79 insertions(+), 94 deletions(-) diff --git a/client/src/components/templates/Asset/AssetDetails.tsx b/client/src/components/templates/Asset/AssetDetails.tsx index 371d29e..ac9881a 100644 --- a/client/src/components/templates/Asset/AssetDetails.tsx +++ b/client/src/components/templates/Asset/AssetDetails.tsx @@ -21,103 +21,87 @@ export function datafilesLine(files: File[]) { return {files.length} data files } -export default class AssetDetails extends PureComponent { - public render() { - const { metadata, ddo } = this.props - const { base } = metadata +const Pricing = ({ price }: { price: string }) => ( +
  • + + Price + + + {price === '0' ? 0 : Web3.utils.fromWei(price.toString())} OCEAN + +
  • +) - return ( - <> - - - {base.description && ( - - )} - - - -
    -

    - Fixed Metadata -

    -
      -
    • - - Author - - - {base.author} - -
    • -
    • - - License - - - {base.license} - -
    • -
    • - - DID - - - {ddo.id} - -
    • - {allowPricing ? ( -
    • - - Price - - - {base.price === '0' - ? 0 - : Web3.utils.fromWei( - base.price.toString() - )}{' '} - OCEAN - -
    • - ) : null} -
    + {base.files && datafilesLine(base.files)}
    + - - - ) - } + )} + + + +
    +

    + Fixed Metadata +

    +
      +
    • + + Author + + {base.author} +
    • +
    • + + License + + {base.license} +
    • +
    • + + DID + + + {ddo.id} + +
    • + {allowPricing ? : null} +
    +
    + + + + ) } diff --git a/client/src/components/templates/Asset/index.tsx b/client/src/components/templates/Asset/index.tsx index f196668..5b10e2d 100644 --- a/client/src/components/templates/Asset/index.tsx +++ b/client/src/components/templates/Asset/index.tsx @@ -54,12 +54,13 @@ class Asset extends Component { public render() { const { metadata, ddo, error } = this.state const isLoading = metadata.base.name === '' + const hasError = error !== '' - return isLoading ? ( + return isLoading && !hasError ? (
    - ) : error !== '' ? ( + ) : hasError ? (
    {error}
    ) : (