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
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';
20 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
26 color: theme.customs.colors.yellow700
30 interface CollectionPanelDataProps {
31 item: CollectionResource;
34 interface CollectionPanelActionProps {
35 onItemRouteChange: (collectionId: string) => void;
36 onContextMenu: (event: React.MouseEvent<HTMLElement>, item: CollectionResource) => void;
39 type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps
40 & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
42 export const CollectionPanel = withStyles(styles)(
43 connect((state: RootState) => ({ item: state.collectionPanel.item }))(
44 class extends React.Component<CollectionPanelProps> {
47 const { classes, item, onContextMenu } = this.props;
49 <Card className={classes.card}>
51 avatar={ <CollectionIcon className={classes.iconHeader} /> }
54 aria-label="More options"
55 onClick={event => onContextMenu(event, item)}>
59 title={item && item.name } />
61 <Grid container direction="column">
63 <DetailsAttribute label='Collection UUID' value={item && item.uuid} />
64 <DetailsAttribute label='Content size' value='54 MB' />
65 <DetailsAttribute label='Owner' value={item && item.ownerUuid} />
71 <Card className={classes.card}>
72 <CardHeader title="Tags" />
74 <Grid container direction="column">
82 <Card className={classes.card}>
83 <CardHeader title="Files" />
85 <Grid container direction="column">
95 componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) {
96 if (!item || match.params.id !== item.uuid) {
97 onItemRouteChange(match.params.id);