X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/ccc52fb9e9a880f8b8e9b15b09c2ebd513575bd4..25aa8a7c81609525d300f38bc5b7d2344c4e1cdf:/src/views/collection-panel/collection-panel.tsx?ds=sidebyside diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx index 1e5fb5e8..374cb951 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -3,180 +3,129 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { - StyleRulesCallback, WithStyles, withStyles, Card, CardHeader, IconButton, - CardContent, Grid, MenuItem, Menu, ListItemIcon, ListItemText, Typography +import { + StyleRulesCallback, WithStyles, withStyles, Card, + CardHeader, IconButton, CardContent, Grid, Chip } 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, ShareIcon, RenameIcon, AddFavoriteIcon, MoveToIcon, - CopyIcon, ProvenanceGraphIcon, DetailsIcon, AdvancedIcon, RemoveIcon -} from '../../components/icon/icon'; -import { DetailsAttribute } from '../../components/details-attribute/details-attribute'; -import { CollectionResource } from '../../models/collection'; - -type CssRules = 'card' | 'iconHeader'; +import { ArvadosTheme } from '~/common/custom-theme'; +import { RootState } from '~/store/store'; +import { MoreOptionsIcon, CollectionIcon, CopyIcon } from '~/components/icon/icon'; +import { DetailsAttribute } from '~/components/details-attribute/details-attribute'; +import { CollectionResource } from '~/models/collection'; +import { CollectionPanelFiles } from '~/views-components/collection-panel-files/collection-panel-files'; +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' | 'tag' | 'copyIcon' | 'value'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ card: { - marginBottom: '20px' + marginBottom: theme.spacing.unit * 2 }, iconHeader: { fontSize: '1.875rem', color: theme.customs.colors.yellow700 - } -}); - -const MENU_OPTIONS = [ - { - title: 'Edit collection', - icon: RenameIcon - }, - { - title: 'Share', - icon: ShareIcon - }, - { - title: 'Move to', - icon: MoveToIcon - }, - { - title: 'Add to favorites', - icon: AddFavoriteIcon - }, - { - title: 'Copy to project', - icon: CopyIcon }, - { - title: 'View details', - icon: DetailsIcon + tag: { + marginRight: theme.spacing.unit, + marginBottom: theme.spacing.unit }, - { - title: 'Provenance graph', - icon: ProvenanceGraphIcon + copyIcon: { + marginLeft: theme.spacing.unit, + fontSize: '1.125rem', + color: theme.palette.grey["500"], + cursor: 'pointer' }, - { - title: 'Advanced', - icon: AdvancedIcon - }, - { - title: 'Remove', - icon: RemoveIcon + value: { + textTransform: 'none' } -]; +}); interface CollectionPanelDataProps { item: CollectionResource; + tags: TagResource[]; } interface CollectionPanelActionProps { onItemRouteChange: (collectionId: string) => void; + onContextMenu: (event: React.MouseEvent, item: CollectionResource) => void; } -type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps +type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps & DispatchProp & WithStyles & RouteComponentProps<{ id: string }>; -export const CollectionPanel = withStyles(styles)( - connect((state: RootState) => ({ item: state.collectionPanel.item }))( - class extends React.Component { - - state = { - anchorEl: undefined, - open: false - }; - showMenu = (event: any) => { - this.setState({ anchorEl: event.currentTarget, open: true }); - } - - closeMenu = () => { - this.setState({ anchorEl: undefined, open: false }); - } - - displayMenuAction = () => { - return - - ; - } +export const CollectionPanel = withStyles(styles)( + connect((state: RootState) => ({ + item: state.collectionPanel.item, + tags: state.collectionPanel.tags + }))( + class extends React.Component { render() { - const { anchorEl, open } = this.state; - const { classes, item } = this.props; + const { classes, item, tags, onContextMenu } = this.props; return
- } - action={ + action={ + onClick={event => onContextMenu(event, item)}> - + } - title={item && item.name } /> + title={item && item.name } + subheader={item && item.description} /> - - {MENU_OPTIONS.map((option) => ( - - - - - - {option.title} - - }/> - - ))} - - - - - - - - - - - - - - - Tags + + + + + + + + - + - - Tags + + + { + tags.map(tag => { + return ; + }) + } +
+ +
; } + handleDelete = (uuid: string) => () => { + this.props.dispatch(deleteCollectionTag(uuid)); + } + componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) { if (!item || match.params.id !== item.uuid) { onItemRouteChange(match.params.id); @@ -185,4 +134,9 @@ export const CollectionPanel = withStyles(styles)( } ) -); \ No newline at end of file +); + +const renderTagLabel = (tag: TagResource) => { + const { properties } = tag; + return `${properties.key}: ${properties.value}`; +};