15856: Adds a conditional warning icon on the breadcrumbs and collection panel.
[arvados.git] / src / views / collection-panel / collection-panel.tsx
index 58dd940494d18e5654f005a9277f2ebf64ddb10e..4e3d5acd9aa37baa9c766660f2785333971fa8b2 100644 (file)
@@ -5,7 +5,7 @@
 import * as React from 'react';
 import {
     StyleRulesCallback, WithStyles, withStyles, Card,
-    CardHeader, IconButton, CardContent, Grid, Chip, Tooltip
+    CardHeader, IconButton, CardContent, Grid, Tooltip
 } from '@material-ui/core';
 import { connect, DispatchProp } from "react-redux";
 import { RouteComponentProps } from 'react-router';
@@ -24,6 +24,9 @@ import { formatFileSize } from "~/common/formatters";
 import { getResourceData } from "~/store/resources-data/resources-data";
 import { ResourceData } from "~/store/resources-data/resources-data-reducer";
 import { openDetailsPanel } from '~/store/details-panel/details-panel-action';
+import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
+import { PropertyChipComponent } from '~/views-components/resource-properties-form/property-chip';
+import { IllegalNamingWarning } from '~/components/warning/warning';
 
 type CssRules = 'card' | 'iconHeader' | 'tag' | 'label' | 'value' | 'link';
 
@@ -64,11 +67,11 @@ type CollectionPanelProps = CollectionPanelDataProps & DispatchProp
     & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
 
 export const CollectionPanel = withStyles(styles)(
-    connect((state: RootState, props: RouteComponentProps<{ id: string }>) => {
-        const item = getResource(props.match.params.id)(state.resources);
-        const data = getResourceData(props.match.params.id)(state.resourcesData);
-        return { item, data };
-    })(
+        connect((state: RootState, props: RouteComponentProps<{ id: string }>) => {
+            const item = getResource(props.match.params.id)(state.resources);
+            const data = getResourceData(props.match.params.id)(state.resourcesData);
+            return { item, data };
+        })(
         class extends React.Component<CollectionPanelProps> {
 
             render() {
@@ -91,7 +94,7 @@ export const CollectionPanel = withStyles(styles)(
                                         </IconButton>
                                     </Tooltip>
                                 }
-                                title={item && item.name}
+                                title={item && <span><IllegalNamingWarning name={item.name}/>{item.name}</span>}
                                 titleTypographyProps={this.titleProps}
                                 subheader={item && item.description}
                                 subheaderTypographyProps={this.titleProps} />
@@ -128,13 +131,12 @@ export const CollectionPanel = withStyles(styles)(
                                         <CollectionTagForm />
                                     </Grid>
                                     <Grid item xs={12}>
-                                        {
-                                            Object.keys(item.properties).map(k => {
-                                                return <Chip key={k} className={classes.tag}
-                                                    onDelete={this.handleDelete(k)}
-                                                    label={`${k}: ${item.properties[k]}`} />;
-                                            })
-                                        }
+                                        {Object.keys(item.properties).map(k =>
+                                            <PropertyChipComponent
+                                                key={k} className={classes.tag}
+                                                onDelete={this.handleDelete(k)}
+                                                propKey={k} propValue={item.properties[k]} />
+                                        )}
                                     </Grid>
                                 </Grid>
                             </CardContent>
@@ -161,6 +163,13 @@ export const CollectionPanel = withStyles(styles)(
                 this.props.dispatch<any>(openContextMenu(event, resource));
             }
 
+            onCopy = (message: string) =>
+                this.props.dispatch(snackbarActions.OPEN_SNACKBAR({
+                    message,
+                    hideDuration: 2000,
+                    kind: SnackbarKind.SUCCESS
+                }))
+
             handleDelete = (key: string) => () => {
                 this.props.dispatch<any>(deleteCollectionTag(key));
             }