Card.tsx 2.14 KB
Newer Older
1 2 3 4 5 6 7 8
import * as React from 'react';
import { translate } from 'react-i18next';

import DescriptorList from 'model/catalog/DescriptorList';
import { DescriptorListLink, ExternalLink } from 'ui/catalog/Links';
import { Properties, PropertiesItem } from 'ui/common/Properties';

import Card, { CardHeader, CardContent } from 'ui/common/Card';
Matija Obreza's avatar
Matija Obreza committed
9
import Markdown from 'ui/common/markdown';
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
import CropChips from 'crop/ui/c/CropChips';

const DescriptorListCard = ({ descriptorList, className, t }: { descriptorList: DescriptorList, className: string, t: any }) => {
  if (descriptorList) {
    return (
      <Card className={ className }>
        <CardHeader title={ (
          <DescriptorListLink to={ descriptorList }>
            { descriptorList.title ?
              <Markdown basic source={ descriptorList.title }/>
              :
              t('descriptorlists.public.c.card.untitled')
            }
          </DescriptorListLink>
        ) }/>
        <CardContent>
          <Markdown className="mb-20" firstParagraph source={ descriptorList.description }/>
          <Properties>
            { descriptorList.crop &&
            <PropertiesItem title={ t('descriptorlists.public.common.crop') }>
              <CropChips crops={ [descriptorList.crop] }/>
            </PropertiesItem> }
            { descriptorList.publisher ?
              <PropertiesItem title={ t('descriptorlists.public.common.publisher') }>{ descriptorList.publisher }</PropertiesItem>
              :
              <PropertiesItem title={ t('descriptorlists.public.common.partner') }>{ descriptorList.owner.shortName }</PropertiesItem>
            }
            { descriptorList.url &&
            <PropertiesItem title={ t('descriptorlists.public.common.url') }>
              { <ExternalLink link={ descriptorList.url }>{ descriptorList.url }</ExternalLink> }
            </PropertiesItem>
            }
            <PropertiesItem title={ t('descriptorlists.public.common.version') }>
              { descriptorList.versionTag }
            </PropertiesItem>
          </Properties>
        </CardContent>
      </Card>
    );
  } else {
    return null;
  }
};

export default translate()(DescriptorListCard);