X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/c01f42311966c4d13413ee34dd6c97d5e5ac8b7f..1326c2ee2772e5e6191e49773bcb00840153e559:/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 99c4e00a..26ee1887 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -3,185 +3,166 @@ // 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, Tooltip } 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 { 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 { openContextMenu } from '~/store/context-menu/context-menu-actions'; +import { ContextMenuKind } from '~/views-components/context-menu/context-menu'; +import { formatFileSize } from "~/common/formatters"; +import { getResourceData } from "~/store/resources-data/resources-data"; +import { ResourceData } from "~/store/resources-data/resources-data-reducer"; + +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 - } -}); - -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 + tag: { + marginRight: theme.spacing.unit, + marginBottom: theme.spacing.unit }, - { - title: 'View details', - icon: DetailsIcon + copyIcon: { + marginLeft: theme.spacing.unit, + fontSize: '1.125rem', + color: theme.palette.grey["500"], + cursor: 'pointer' }, - { - title: 'Provenance graph', - icon: ProvenanceGraphIcon + label: { + fontSize: '0.875rem' }, - { - title: 'Advanced', - icon: AdvancedIcon - }, - { - title: 'Remove', - icon: RemoveIcon + value: { + textTransform: 'none', + fontSize: '0.875rem' } -]; +}); interface CollectionPanelDataProps { item: CollectionResource; + data: ResourceData; } -interface CollectionPanelActionProps { - onItemRouteChange: (collectionId: string) => void; -} +type CollectionPanelProps = CollectionPanelDataProps & DispatchProp + & WithStyles & RouteComponentProps<{ id: string }>; -type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps - & WithStyles & RouteComponentProps<{ id: string }>; export const CollectionPanel = withStyles(styles)( - connect((state: RootState) => ({ item: state.collectionPanel.item }))( - class extends React.Component { - - state = { - anchorEl: undefined - }; - - showMenu = (event: any) => { - this.setState({ anchorEl: event.currentTarget }); - } - - closeMenu = () => { - this.setState({ anchorEl: undefined }); - } - - displayMenuAction = () => { - return - - ; - } - + 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 { render() { - const { anchorEl } = this.state; - const { classes, item } = this.props; - return
+ const { classes, item, data } = this.props; + return item + ? <> - } - action={ - - - + } + action={ + + + + + } - title={item && item.name } /> + title={item && item.name} + subheader={item && item.description} /> - - {MENU_OPTIONS.map((option) => ( - - - - - - {option.title} - - }/> - - ))} - - - - + + + this.onCopy()}> + + + + + + + - + - - Tags + + - - - - - - - - - - Tags + + { + Object.keys(item.properties).map(k => { + return ; + }) + } -
; +
+ +
+ + : null; } - componentWillReceiveProps({ match, item, onItemRouteChange }: CollectionPanelProps) { - if (!item || match.params.id !== item.uuid) { - onItemRouteChange(match.params.id); - } + handleContextMenu = (event: React.MouseEvent) => { + const { uuid, ownerUuid, name, description, kind, isTrashed } = this.props.item; + const resource = { + uuid, + ownerUuid, + name, + description, + kind, + menuKind: isTrashed + ? ContextMenuKind.TRASHED_COLLECTION + : ContextMenuKind.COLLECTION + }; + this.props.dispatch(openContextMenu(event, resource)); } + handleDelete = (key: string) => () => { + this.props.dispatch(deleteCollectionTag(key)); + } + + onCopy = () => { + this.props.dispatch(snackbarActions.OPEN_SNACKBAR({ + message: "Uuid has been copied", + hideDuration: 2000 + })); + } } ) -); \ No newline at end of file +);