X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/ec9331a8435c9844efe3ba018f6c0d0c3f96d573..394ebdfd13fe40a7096f484c46a353d2537f4c9a:/src/components/chips/chips.tsx

diff --git a/src/components/chips/chips.tsx b/src/components/chips/chips.tsx
index 36cf2412..c4724d1b 100644
--- a/src/components/chips/chips.tsx
+++ b/src/components/chips/chips.tsx
@@ -2,10 +2,19 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
+import React from 'react';
 import { Chip, Grid, StyleRulesCallback, withStyles } from '@material-ui/core';
-import { DragSource, DragSourceSpec, DragSourceCollector, ConnectDragSource, DropTarget, DropTargetSpec, DropTargetCollector, ConnectDropTarget } from 'react-dnd';
-import { compose, noop } from 'lodash/fp';
+import {
+    DragSource,
+    DragSourceSpec,
+    DragSourceCollector,
+    ConnectDragSource,
+    DropTarget,
+    DropTargetSpec,
+    DropTargetCollector,
+    ConnectDropTarget
+} from 'react-dnd';
+import { compose } from 'lodash/fp';
 import { WithStyles } from '@material-ui/core/styles';
 interface ChipsProps<Value> {
     values: Value[];
@@ -14,6 +23,7 @@ interface ChipsProps<Value> {
     deletable?: boolean;
     orderable?: boolean;
     onChange: (value: Value[]) => void;
+    clickable?: boolean;
 }
 
 type CssRules = 'root';
@@ -28,15 +38,18 @@ export const Chips = withStyles(styles)(
         render() {
             const { values, filler } = this.props;
             return <Grid container spacing={8} className={this.props.classes.root}>
-                {values.map(this.renderChip)}
+                {values && values.map(this.renderChip)}
                 {filler && <Grid item xs>{filler}</Grid>}
             </Grid>;
         }
 
-        renderChip = (value: Value, index: number) =>
-            <Grid item key={index}>
-                <this.chip {...{ value }} />
+        renderChip = (value: Value, index: number) => {
+            const { deletable, getLabel } = this.props;
+            return <Grid item key={index}>
+                <Chip onDelete={deletable ? this.deleteValue(value) : undefined}
+                    label={getLabel !== undefined ? getLabel(value) : value} />
             </Grid>
+        }
 
         type = 'chip';
 
@@ -90,6 +103,7 @@ export const Chips = withStyles(styles)(
                             onDelete={this.props.deletable
                                 ? this.deleteValue(value)
                                 : undefined}
+                            clickable={this.props.clickable}
                             label={this.props.getLabel ?
                                 this.props.getLabel(value)
                                 : typeof value === 'object'
@@ -121,4 +135,4 @@ interface CollectedProps {
 
 interface DraggableChipProps<Value> {
     value: Value;
-}
\ No newline at end of file
+}
