X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f7cdbfa28c3867076fe25feb5d89b62592a9bf81..4e3dc54aa0b5b240f81ed8af89cccc6b47202a19:/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 271fb8bc..348b548b 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -3,39 +3,53 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { - StyleRulesCallback, WithStyles, withStyles, Card, - CardHeader, IconButton, CardContent, Grid, Chip, TextField, Button +import { + StyleRulesCallback, WithStyles, withStyles, Card, + CardHeader, IconButton, CardContent, Grid, Chip, Tooltip } from '@material-ui/core'; 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, CopyIcon } from '../../components/icon/icon'; -import { DetailsAttribute } from '../../components/details-attribute/details-attribute'; -import { CollectionResource } from '../../models/collection'; +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 { createCollectionTag } from '../../store/collection-panel/collection-panel-action'; -import { TagResource } from '../../models/tag'; +import { TagResource } from '~/models/tag'; +import { CollectionTagForm } from './collection-tag-form'; +import { deleteCollectionTag } from '~/store/collection-panel/collection-panel-action'; +import { snackbarActions } from '~/store/snackbar/snackbar-actions'; +import { getResource } from '~/store/resources/resources'; +import { contextMenuActions, openContextMenu } from '~/store/context-menu/context-menu-actions'; +import { ContextMenuKind } from '~/views-components/context-menu/context-menu'; -type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon'; +type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'label' | 'value'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ card: { - marginBottom: '20px' + marginBottom: theme.spacing.unit * 2 }, iconHeader: { fontSize: '1.875rem', color: theme.customs.colors.yellow700 }, tag: { - marginRight: theme.spacing.unit + marginRight: theme.spacing.unit, + marginBottom: theme.spacing.unit }, copyIcon: { marginLeft: theme.spacing.unit, fontSize: '1.125rem', color: theme.palette.grey["500"], cursor: 'pointer' + }, + label: { + fontSize: '0.875rem' + }, + value: { + textTransform: 'none', + fontSize: '0.875rem' } }); @@ -44,94 +58,101 @@ interface CollectionPanelDataProps { tags: TagResource[]; } -interface CollectionPanelActionProps { - onItemRouteChange: (collectionId: string) => void; - onContextMenu: (event: React.MouseEvent, item: CollectionResource) => void; -} - -type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps & DispatchProp - & WithStyles & RouteComponentProps<{ id: string }>; +type CollectionPanelProps = CollectionPanelDataProps & DispatchProp + & WithStyles & RouteComponentProps<{ id: string }>; export const CollectionPanel = withStyles(styles)( - connect((state: RootState) => ({ - item: state.collectionPanel.item, - tags: state.collectionPanel.tags - }))( - class extends React.Component { + connect((state: RootState, props: RouteComponentProps<{ id: string }>) => { + const collection = getResource(props.match.params.id)(state.resources); + return { + item: collection, + tags: state.collectionPanel.tags + }; + })( + class extends React.Component { render() { - const { classes, item, tags, onContextMenu } = this.props; + const { classes, item, tags } = this.props; return
- - } - action={ - onContextMenu(event, item)}> - - - } - title={item && item.name } - subheader={item && item.description} /> - - - - - - - + + } + action={ + + + + } + title={item && item.name} + subheader={item && item.description} /> + + + + + + this.onCopy()}> + + + - - - + + + - - + + + - - - - - - {/* Temporarty button to add new tag */} - - - - { - tags.map(tag => { - return ; - }) - } - + + + + + + + { + tags.map(tag => { + return ; + }) + } - - + + + +
+ +
+
; + } - - - - - - Tags - - - - - ; + handleContextMenu = (event: React.MouseEvent) => { + const { uuid, name, description } = this.props.item; + const resource = { + uuid, + name, + description, + kind: ContextMenuKind.COLLECTION + }; + this.props.dispatch(openContextMenu(event, resource)); } - // Temporary method to add new tag - addTag = () => { - this.props.dispatch(createCollectionTag(this.props.item.uuid, { key: 'test', value: 'value for tag'})); + handleDelete = (uuid: string) => () => { + this.props.dispatch(deleteCollectionTag(uuid)); } - componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) { - if (!item || match.params.id !== item.uuid) { - onItemRouteChange(match.params.id); - } + onCopy = () => { + this.props.dispatch(snackbarActions.OPEN_SNACKBAR({ + message: "Uuid has been copied", + hideDuration: 2000 + })); } } @@ -141,4 +162,4 @@ export const CollectionPanel = withStyles(styles)( const renderTagLabel = (tag: TagResource) => { const { properties } = tag; return `${properties.key}: ${properties.value}`; -}; \ No newline at end of file +};