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';
import { snackbarActions } from '~/store/snackbar/snackbar-actions';
interface CollectionPanelDataProps {
item: CollectionResource;
- tags: TagResource[];
}
type CollectionPanelProps = CollectionPanelDataProps & DispatchProp
connect((state: RootState, props: RouteComponentProps<{ id: string }>) => {
const collection = getResource(props.match.params.id)(state.resources);
return {
- item: collection,
- tags: state.collectionPanel.tags
+ item: collection
};
})(
class extends React.Component<CollectionPanelProps> {
render() {
- const { classes, item, tags } = this.props;
+ const { classes, item } = this.props;
return <div>
<Card className={classes.card}>
<CardHeader
<Grid item xs={12}><CollectionTagForm /></Grid>
<Grid item xs={12}>
{
- tags.map(tag => {
- return <Chip key={tag.etag} className={classes.tag}
- onDelete={this.handleDelete(tag.uuid)}
- label={renderTagLabel(tag)} />;
+ Object.keys(item.properties).map( key => {
+ return <Chip key={key} className={classes.tag}
+ onDelete={this.handleDelete(key)}
+ label={`${key}: ${item.properties[key]}`} />;
})
}
</Grid>
this.props.dispatch<any>(openContextMenu(event, resource));
}
- handleDelete = (uuid: string) => () => {
- this.props.dispatch<any>(deleteCollectionTag(uuid));
+ handleDelete = (key: string) => () => {
+ this.props.dispatch<any>(deleteCollectionTag(key));
}
onCopy = () => {
}
)
);
-
-const renderTagLabel = (tag: TagResource) => {
- const { properties } = tag;
- return `${properties.key}: ${properties.value}`;
-};