1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { Card, CardHeader, WithStyles, withStyles, Typography, CardContent } from '@material-ui/core';
7 import { StyleRulesCallback } from '@material-ui/core';
8 import { ArvadosTheme } from 'common/custom-theme';
9 import { RootState } from 'store/store';
10 import { connect } from 'react-redux';
11 import { getResource } from 'store/resources/resources';
12 import { MultiselectToolbar } from 'components/multiselect-toolbar/MultiselectToolbar';
13 import { DetailsAttribute } from 'components/details-attribute/details-attribute';
14 import { RichTextEditorLink } from 'components/rich-text-editor-link/rich-text-editor-link';
15 import { getPropertyChip } from '../resource-properties-form/property-chip';
16 import { ProjectResource } from 'models/project';
17 import { GroupClass } from 'models/group';
18 import { ResourceWithName } from 'views-components/data-explorer/renderers';
19 import { formatDate } from 'common/formatters';
20 import { resourceLabel } from 'common/labels';
21 import { ResourceKind } from 'models/resource';
23 type CssRules = 'root' | 'fadeout' | 'cardcontent' | 'attribute' | 'tag';
25 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
35 WebkitMaskImage: '-webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,1)), to(rgba(0,0,0,0)))',
42 marginBottom: '0.5rem',
48 const mapStateToProps = (state: RootState) => {
49 const currentRoute = state.router.location?.pathname.split('/') || [];
50 const currentItemUuid = currentRoute[currentRoute.length - 1];
51 const currentResource = getResource(currentItemUuid)(state.resources);
57 type DetailsCardProps = {
58 currentResource: ProjectResource;
61 export const ProjectDetailsCard = connect(mapStateToProps)(
62 withStyles(styles)((props: DetailsCardProps & WithStyles<CssRules>) => {
63 const { classes, currentResource } = props;
64 const { name, description, uuid } = currentResource;
66 <Card className={classes.root}>
67 {console.log(currentResource)}
80 <Typography className={classes.fadeout}>{description.replace(/<[^>]*>/g, '')}</Typography>
82 title={`Description of ${name}`}
84 label='Show full description'
91 action={<MultiselectToolbar inputSelectedUuid={uuid} />}
93 <CardContent className={classes.cardcontent}>
96 className={classes.attribute}
100 value={currentResource.groupClass === GroupClass.FILTER ? 'Filter group' : resourceLabel(ResourceKind.PROJECT)}
105 className={classes.attribute}
109 linkToUuid={currentResource.ownerUuid}
110 uuidEnhancer={(uuid: string) => <ResourceWithName uuid={uuid} />}
115 className={classes.attribute}
118 label='Last modified'
119 value={formatDate(currentResource.modifiedAt)}
124 className={classes.attribute}
128 value={formatDate(currentResource.createdAt)}
133 className={classes.attribute}
137 linkToUuid={currentResource.uuid}
138 value={currentResource.uuid}
143 className={classes.attribute}
145 {Object.keys(currentResource.properties).map((k) =>
146 Array.isArray(currentResource.properties[k])
147 ? currentResource.properties[k].map((v: string) => getPropertyChip(k, v, undefined, classes.tag))
148 : getPropertyChip(k, currentResource.properties[k], undefined, classes.tag)