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 } from '../../components/icon/icon';
15 import { DetailsAttribute } from '../../components/details-attribute/details-attribute';
16 import { CollectionResource } from '../../models/collection';
18 type CssRules = 'card' | 'iconHeader' | 'tag';
20 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
26 color: theme.customs.colors.yellow700
29 marginRight: theme.spacing.unit
33 interface CollectionPanelDataProps {
34 item: CollectionResource;
37 interface CollectionPanelActionProps {
38 onItemRouteChange: (collectionId: string) => void;
39 onContextMenu: (event: React.MouseEvent<HTMLElement>, item: CollectionResource) => void;
42 type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps
43 & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
45 export const CollectionPanel = withStyles(styles)(
46 connect((state: RootState) => ({ item: state.collectionPanel.item }))(
47 class extends React.Component<CollectionPanelProps> {
50 const { classes, item, onContextMenu } = this.props;
52 <Card className={classes.card}>
54 avatar={ <CollectionIcon className={classes.iconHeader} /> }
57 aria-label="More options"
58 onClick={event => onContextMenu(event, item)}>
62 title={item && item.name } />
64 <Grid container direction="column">
66 <DetailsAttribute label='Collection UUID' value={item && item.uuid}>
69 <DetailsAttribute label='Content size' value='54 MB' />
70 <DetailsAttribute label='Owner' value={item && item.ownerUuid} />
76 <Card className={classes.card}>
77 <CardHeader title="Tags" />
79 <Grid container direction="column">
81 <Chip label="Tag 1" className={classes.tag}/>
82 <Chip label="Tag 2" className={classes.tag}/>
83 <Chip label="Tag 3" className={classes.tag}/>
89 <Card className={classes.card}>
90 <CardHeader title="Files" />
92 <Grid container direction="column">
102 componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) {
103 if (!item || match.params.id !== item.uuid) {
104 onItemRouteChange(match.params.id);