// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; import { StyleRulesCallback, WithStyles, withStyles, Card, CardHeader, IconButton, CardContent, Grid, Chip } 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 { 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' | 'label' | 'value'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ card: { marginBottom: theme.spacing.unit * 2 }, iconHeader: { fontSize: '1.875rem', color: theme.customs.colors.yellow700 }, tag: { 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' } }); interface CollectionPanelDataProps { item: CollectionResource; tags: TagResource[]; } interface CollectionPanelActionProps { onItemRouteChange: (collectionId: string) => void; onContextMenu: (event: React.MouseEvent, item: CollectionResource) => void; } type CollectionPanelProps = CollectionPanelDataProps & CollectionPanelActionProps & 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 { render() { const { classes, item, tags, onContextMenu } = this.props; return
} action={ onContextMenu(event, item)}> } title={item && item.name } subheader={item && item.description} /> { 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); } } } ) ); const renderTagLabel = (tag: TagResource) => { const { properties } = tag; return `${properties.key}: ${properties.value}`; };