1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
7 StyleRulesCallback, WithStyles, withStyles, Card,
8 CardHeader, IconButton, CardContent, Grid, Chip
9 } from '@material-ui/core';
10 import { connect } from 'react-redux';
11 import { RouteComponentProps } from 'react-router';
12 import { ArvadosTheme } from '../../common/custom-theme';
13 import { RootState } from '../../store/store';
14 import { MoreOptionsIcon, CollectionIcon, CopyIcon } from '../../components/icon/icon';
15 import { DetailsAttribute } from '../../components/details-attribute/details-attribute';
16 import { CollectionResource } from '../../models/collection';
17 import * as CopyToClipboard from 'react-copy-to-clipboard';
19 type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon';
21 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
27 color: theme.customs.colors.yellow700
30 marginRight: theme.spacing.unit
33 marginLeft: theme.spacing.unit,
39 interface CollectionPanelDataProps {
40 item: CollectionResource;
43 interface CollectionPanelActionProps {
44 onItemRouteChange: (collectionId: string) => void;
45 onContextMenu: (event: React.MouseEvent<HTMLElement>, item: CollectionResource) => void;
48 type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps
49 & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
52 export const CollectionPanel = withStyles(styles)(
53 connect((state: RootState) => ({ item: state.collectionPanel.item }))(
54 class extends React.Component<CollectionPanelProps> {
57 const { classes, item, onContextMenu } = this.props;
59 <Card className={classes.card}>
61 avatar={ <CollectionIcon className={classes.iconHeader} /> }
64 aria-label="More options"
65 onClick={event => onContextMenu(event, item)}>
69 title={item && item.name }
70 subheader={item && item.description} />
72 <Grid container direction="column">
74 <DetailsAttribute label='Collection UUID' value={item && item.uuid}>
75 <CopyToClipboard text={item && item.uuid}>
76 <CopyIcon className={classes.copyIcon} />
79 <DetailsAttribute label='Content size' value='54 MB' />
80 <DetailsAttribute label='Owner' value={item && item.ownerUuid} />
86 <Card className={classes.card}>
87 <CardHeader title="Tags" />
89 <Grid container direction="column">
91 <Chip label="Tag 1" className={classes.tag}/>
92 <Chip label="Tag 2" className={classes.tag}/>
93 <Chip label="Tag 3" className={classes.tag}/>
99 <Card className={classes.card}>
100 <CardHeader title="Files" />
102 <Grid container direction="column">
112 componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) {
113 if (!item || match.params.id !== item.uuid) {
114 onItemRouteChange(match.params.id);