X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/e2a464e9087120c7569976eb9a172a91d2ec0f09..d8f669aadc5f3d7241395abd6aa764406079d7d3:/src/components/chips/chips.tsx diff --git a/src/components/chips/chips.tsx b/src/components/chips/chips.tsx index 8f597de6..2a6fafc3 100644 --- a/src/components/chips/chips.tsx +++ b/src/components/chips/chips.tsx @@ -2,16 +2,28 @@ // // 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 { + 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 { values: Value[]; getLabel?: (value: Value) => string; filler?: React.ReactNode; + deletable?: boolean; + orderable?: boolean; onChange: (value: Value[]) => void; + clickable?: boolean; } type CssRules = 'root'; @@ -75,22 +87,31 @@ export const Chips = withStyles(styles)( DragSource(this.type, this.dragSpec, this.dragCollector), DropTarget(this.type, this.dropSpec, this.dropCollector), )( - ({ connectDragSource, connectDropTarget, isOver, value }: DraggableChipProps & CollectedProps) => - compose( + ({ connectDragSource, connectDropTarget, isOver, value }: DraggableChipProps & CollectedProps) => { + const connect = compose( connectDragSource, connectDropTarget, - )( + ); + + const chip = - - ) + ; + + return this.props.orderable + ? connect(chip) + : chip; + } ); deleteValue = (value: Value) => () => {