X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3ee31ce16470660d90fb870e048c2de9fcde6e47..919738cdda7a99c61164ccac5754fe939c25fb6b:/src/views/collection-panel/collection-panel.tsx

diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index b55e50c0b0..aac5661e14 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -5,30 +5,48 @@
 import * as React from 'react';
 import { 
     StyleRulesCallback, WithStyles, withStyles, Card, 
-    CardHeader, IconButton, CardContent, Grid
+    CardHeader, IconButton, CardContent, Grid, Chip, TextField, Button
 } from '@material-ui/core';
-import { connect } from 'react-redux';
+import { connect, DispatchProp } from "react-redux";
 import { RouteComponentProps } from 'react-router';
 import { ArvadosTheme } from '../../common/custom-theme';
 import { RootState } from '../../store/store';
-import { MoreOptionsIcon, CollectionIcon } from '../../components/icon/icon';
+import { MoreOptionsIcon, CollectionIcon, CopyIcon } from '../../components/icon/icon';
 import { DetailsAttribute } from '../../components/details-attribute/details-attribute';
 import { CollectionResource } from '../../models/collection';
+import * as CopyToClipboard from 'react-copy-to-clipboard';
+import { TagResource } from '../../models/tag';
+import { CollectionTagForm } from './collection-tag-form';
+import { deleteCollectionTag } from '../../store/collection-panel/collection-panel-action';
 
-type CssRules = 'card' | 'iconHeader';
+type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'value';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     card: {
-        marginBottom: '20px'
+        marginBottom: theme.spacing.unit * 2
     },
     iconHeader: {
         fontSize: '1.875rem',
         color: theme.customs.colors.yellow700
+    },
+    tag: {
+        marginRight: theme.spacing.unit,
+        marginBottom: theme.spacing.unit
+    },
+    copyIcon: {
+        marginLeft: theme.spacing.unit,
+        fontSize: '1.125rem',
+        color: theme.palette.grey["500"],
+        cursor: 'pointer'
+    },
+    value: {
+        textTransform: 'none'
     }
 });
 
 interface CollectionPanelDataProps {
     item: CollectionResource;
+    tags: TagResource[];
 }
 
 interface CollectionPanelActionProps {
@@ -36,15 +54,19 @@ interface CollectionPanelActionProps {
     onContextMenu: (event: React.MouseEvent<HTMLElement>, item: CollectionResource) => void;
 }
 
-type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps 
+type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps & DispatchProp
                             & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
 
+
 export const CollectionPanel = withStyles(styles)(
-    connect((state: RootState) => ({ item: state.collectionPanel.item }))(
+    connect((state: RootState) => ({ 
+        item: state.collectionPanel.item, 
+        tags: state.collectionPanel.tags 
+    }))(
         class extends React.Component<CollectionPanelProps> { 
 
             render() {
-                const { classes, item, onContextMenu } = this.props;
+                const { classes, item, tags, onContextMenu } = this.props;
                 return <div>
                         <Card className={classes.card}>
                             <CardHeader 
@@ -56,13 +78,21 @@ export const CollectionPanel = withStyles(styles)(
                                         <MoreOptionsIcon />
                                     </IconButton> 
                                 }
-                                title={item && item.name } />
+                                title={item && item.name } 
+                                subheader={item && item.description} />
                             <CardContent>
                                 <Grid container direction="column">
                                     <Grid item xs={6}>
-                                    <DetailsAttribute label='Collection UUID' value={item && item.uuid} />
-                                        <DetailsAttribute label='Content size' value='54 MB' />
-                                    <DetailsAttribute label='Owner' value={item && item.ownerUuid} />
+                                    <DetailsAttribute classValue={classes.value} 
+                                            label='Collection UUID' 
+                                            value={item && item.uuid}>
+                                        <CopyToClipboard text={item && item.uuid}>
+                                            <CopyIcon className={classes.copyIcon} />
+                                        </CopyToClipboard>
+                                    </DetailsAttribute>
+                                    <DetailsAttribute label='Number of files' value='14' />
+                                    <DetailsAttribute label='Content size' value='54 MB' />
+                                    <DetailsAttribute classValue={classes.value} label='Owner' value={item && item.ownerUuid} />
                                     </Grid>
                                 </Grid>
                             </CardContent>
@@ -72,8 +102,15 @@ export const CollectionPanel = withStyles(styles)(
                             <CardHeader title="Tags" />
                             <CardContent>
                                 <Grid container direction="column">
-                                    <Grid item xs={4}>
-                                        Tags
+                                    <Grid item xs={12}><CollectionTagForm /></Grid>
+                                    <Grid item xs={12}>
+                                        {
+                                            tags.map(tag => {
+                                                return <Chip key={tag.etag} className={classes.tag}
+                                                    onDelete={this.handleDelete(tag.uuid)}
+                                                    label={renderTagLabel(tag)}  />;
+                                            })
+                                        }
                                     </Grid>
                                 </Grid>
                             </CardContent>
@@ -84,7 +121,7 @@ export const CollectionPanel = withStyles(styles)(
                             <CardContent>
                                 <Grid container direction="column">
                                     <Grid item xs={4}>
-                                        Tags
+                                        Files
                                     </Grid>
                                 </Grid>
                             </CardContent>
@@ -92,6 +129,10 @@ export const CollectionPanel = withStyles(styles)(
                     </div>;
             }
 
+            handleDelete = (uuid: string) => () => {
+                this.props.dispatch<any>(deleteCollectionTag(uuid));
+            }
+
             componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) {
                 if (!item || match.params.id !== item.uuid) {
                     onItemRouteChange(match.params.id);
@@ -100,4 +141,9 @@ export const CollectionPanel = withStyles(styles)(
 
         }
     )
-);
\ No newline at end of file
+);
+
+const renderTagLabel = (tag: TagResource) => {
+    const { properties } = tag;
+    return `${properties.key}: ${properties.value}`;
+};
\ No newline at end of file
