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 { CollectionPanelFiles } from '../../views-components/collection-panel-files/collection-panel-files';
18 import * as CopyToClipboard from 'react-copy-to-clipboard';
20 type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon';
22 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
28 color: theme.customs.colors.yellow700
31 marginRight: theme.spacing.unit
34 marginLeft: theme.spacing.unit,
40 interface CollectionPanelDataProps {
41 item: CollectionResource;
44 interface CollectionPanelActionProps {
45 onItemRouteChange: (collectionId: string) => void;
46 onContextMenu: (event: React.MouseEvent<HTMLElement>, item: CollectionResource) => void;
49 type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps
50 & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
53 export const CollectionPanel = withStyles(styles)(
54 connect((state: RootState) => ({ item: state.collectionPanel.item! }))(
55 class extends React.Component<CollectionPanelProps> {
58 const { classes, item, onContextMenu } = this.props;
60 <Card className={classes.card}>
62 avatar={ <CollectionIcon className={classes.iconHeader} /> }
65 aria-label="More options"
66 onClick={event => onContextMenu(event, item)}>
70 title={item && item.name }
71 subheader={item && item.description} />
73 <Grid container direction="column">
75 <DetailsAttribute label='Collection UUID' value={item && item.uuid}>
76 <CopyToClipboard text={item && item.uuid}>
77 <CopyIcon className={classes.copyIcon} />
80 <DetailsAttribute label='Content size' value='54 MB' />
81 <DetailsAttribute label='Owner' value={item && item.ownerUuid} />
87 <Card className={classes.card}>
88 <CardHeader title="Tags" />
90 <Grid container direction="column">
92 <Chip label="Tag 1" className={classes.tag}/>
93 <Chip label="Tag 2" className={classes.tag}/>
94 <Chip label="Tag 3" className={classes.tag}/>
99 <div className={classes.card}>
100 <CollectionPanelFiles/>
105 componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) {
106 if (!item || match.params.id !== item.uuid) {
107 onItemRouteChange(match.params.id);