Merge branch 'master' of git.curoverse.com:arvados-workbench2 into 14163-trash-loadin...
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Wed, 26 Sep 2018 13:37:39 +0000 (15:37 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Wed, 26 Sep 2018 13:37:39 +0000 (15:37 +0200)
refs #2
14163

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

13 files changed:
package.json
src/components/file-upload/file-upload.css [deleted file]
src/components/file-upload/file-upload.tsx
src/store/collection-panel/collection-panel-action.ts
src/store/collection-panel/collection-panel-reducer.ts
src/store/processes/process-command-actions.ts
src/views-components/process-command-dialog/process-command-dialog.tsx
src/views-components/progress/content-progress.tsx [deleted file]
src/views-components/progress/side-panel-progress.tsx [deleted file]
src/views-components/progress/workbench-progress.tsx [deleted file]
src/views-components/snackbar/snackbar.tsx
src/views/collection-panel/collection-panel.tsx
yarn.lock

index 620ff5a6d03a6d7d616ab9d32b0ec2f47c0530ac..811e4a07ae5dc53eeb56ed4105e03cbae6f05649 100644 (file)
@@ -9,6 +9,7 @@
     "@types/react-copy-to-clipboard": "4.2.6",
     "@types/react-dropzone": "4.2.2",
     "@types/redux-form": "7.4.5",
+    "@types/shell-quote": "1.6.0",
     "axios": "0.18.0",
     "classnames": "2.2.6",
     "lodash": "4.17.10",
@@ -25,6 +26,7 @@
     "react-transition-group": "2.4.0",
     "redux": "4.0.0",
     "redux-thunk": "2.3.0",
+    "shell-quote": "1.6.1",
     "unionize": "2.1.2",
     "uuid": "3.3.2"
   },
diff --git a/src/components/file-upload/file-upload.css b/src/components/file-upload/file-upload.css
deleted file mode 100644 (file)
index 0d74b89..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-.dropzone-border-left {
-    left: -1px;
-    top: -1px;
-    bottom: -1px;
-    width: 2px;
-    content: "";
-    position: absolute;
-    transform: scaleY(0);
-    transition: transform 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms;
-    pointer-events: none;
-    background-color: #6a1b9a;
-}
-
-.dropzone-border-right {
-    right: -1px;
-    top: -1px;
-    bottom: -1px;
-    width: 2px;
-    content: "";
-    position: absolute;
-    transform: scaleY(0);
-    transition: transform 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms;
-    pointer-events: none;
-    background-color: #6a1b9a;
-}
-
-.dropzone-border-top {
-    left: 0;
-    right: 0;
-    top: -1px;
-    height: 2px;
-    content: "";
-    position: absolute;
-    transform: scaleX(0);
-    transition: transform 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms;
-    pointer-events: none;
-    background-color: #6a1b9a;
-}
-
-.dropzone-border-bottom {
-    left: 0;
-    right: 0;
-    bottom: -1px;
-    height: 2px;
-    content: "";
-    position: absolute;
-    transform: scaleX(0);
-    transition: transform 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms;
-    pointer-events: none;
-    background-color: #6a1b9a;
-}
-
-.dropzone-border-left-active {
-    transform: scaleY(1);
-}
-
-.dropzone-border-right-active {
-    transform: scaleY(1);
-}
-
-.dropzone-border-top-active {
-    transform: scaleX(1);
-}
-
-.dropzone-border-bottom-active {
-    transform: scaleX(1);
-}
index 0f87b1e9e35a18b5417063759c70f06e35641531..41054df43f9da6c6d76fb446a118dc15781606bd 100644 (file)
@@ -17,10 +17,9 @@ import { CloudUploadIcon } from "../icon/icon";
 import { formatFileSize, formatProgress, formatUploadSpeed } from "~/common/formatters";
 import { UploadFile } from '~/store/file-uploader/file-uploader-actions';
 
-type CssRules = "root" | "dropzone" | "dropzoneWrapper" | "container" | "uploadIcon";
-
-import './file-upload.css';
-import { DOMElement, RefObject } from "react";
+type CssRules = "root" | "dropzone" | "dropzoneWrapper" | "container" | "uploadIcon"
+    | "dropzoneBorder" | "dropzoneBorderLeft" | "dropzoneBorderRight" | "dropzoneBorderTop" | "dropzoneBorderBottom"
+    | "dropzoneBorderHorzActive" | "dropzoneBorderVertActive";
 
 const styles: StyleRulesCallback<CssRules> = theme => ({
     root: {
@@ -36,6 +35,47 @@ const styles: StyleRulesCallback<CssRules> = theme => ({
         position: "relative",
         border: "1px solid rgba(0, 0, 0, 0.42)"
     },
+    dropzoneBorder: {
+        content: "",
+        position: "absolute",
+        transition: "transform 200ms cubic-bezier(0.0, 0, 0.2, 1) 0ms",
+        pointerEvents: "none",
+        backgroundColor: "#6a1b9a"
+    },
+    dropzoneBorderLeft: {
+        left: -1,
+        top: -1,
+        bottom: -1,
+        width: 2,
+        transform: "scaleY(0)",
+    },
+    dropzoneBorderRight: {
+        right: -1,
+        top: -1,
+        bottom: -1,
+        width: 2,
+        transform: "scaleY(0)",
+    },
+    dropzoneBorderTop: {
+        left: 0,
+        right: 0,
+        top: -1,
+        height: 2,
+        transform: "scaleX(0)",
+    },
+    dropzoneBorderBottom: {
+        left: 0,
+        right: 0,
+        bottom: -1,
+        height: 2,
+        transform: "scaleX(0)",
+    },
+    dropzoneBorderHorzActive: {
+        transform: "scaleY(1)"
+    },
+    dropzoneBorderVertActive: {
+        transform: "scaleX(1)"
+    },
     container: {
         height: "100%"
     },
@@ -67,13 +107,13 @@ export const FileUpload = withStyles(styles)(
         render() {
             const { classes, onDrop, disabled, files } = this.props;
             return <div className={"file-upload-dropzone " + classes.dropzoneWrapper}>
-                <div className={classnames("dropzone-border-left", { "dropzone-border-left-active": this.state.focused })}/>
-                <div className={classnames("dropzone-border-right", { "dropzone-border-right-active": this.state.focused })}/>
-                <div className={classnames("dropzone-border-top", { "dropzone-border-top-active": this.state.focused })}/>
-                <div className={classnames("dropzone-border-bottom", { "dropzone-border-bottom-active": this.state.focused })}/>
+                <div className={classnames(classes.dropzoneBorder, classes.dropzoneBorderLeft, { [classes.dropzoneBorderHorzActive]: this.state.focused })}/>
+                <div className={classnames(classes.dropzoneBorder, classes.dropzoneBorderRight, { [classes.dropzoneBorderHorzActive]: this.state.focused })}/>
+                <div className={classnames(classes.dropzoneBorder, classes.dropzoneBorderTop, { [classes.dropzoneBorderVertActive]: this.state.focused })}/>
+                <div className={classnames(classes.dropzoneBorder, classes.dropzoneBorderBottom, { [classes.dropzoneBorderVertActive]: this.state.focused })}/>
                 <Dropzone className={classes.dropzone}
                     onDrop={files => onDrop(files)}
-                    onClick={(e) => {
+                    onClick={() => {
                         const el = document.getElementsByClassName("file-upload-dropzone")[0];
                         const inputs = el.getElementsByTagName("input");
                         if (inputs.length > 0) {
index 97b6d49c7d25d154bd51471c94ef992fcb2d27f8..5e991619e77e3a405722ae3b30115b555c3e62af 100644 (file)
@@ -9,20 +9,14 @@ import { collectionPanelFilesAction } from "./collection-panel-files/collection-
 import { createTree } from "~/models/tree";
 import { RootState } from "../store";
 import { ServiceRepository } from "~/services/services";
-import { TagResource, TagProperty } from "~/models/tag";
+import { TagProperty } from "~/models/tag";
 import { snackbarActions } from "../snackbar/snackbar-actions";
 import { resourcesActions } from "~/store/resources/resources-actions";
 import { unionize, ofType, UnionOf } from '~/common/unionize';
 
 export const collectionPanelActions = unionize({
     LOAD_COLLECTION: ofType<{ uuid: string }>(),
-    LOAD_COLLECTION_SUCCESS: ofType<{ item: CollectionResource }>(),
-    LOAD_COLLECTION_TAGS: ofType<{ uuid: string }>(),
-    LOAD_COLLECTION_TAGS_SUCCESS: ofType<{ tags: TagResource[] }>(),
-    CREATE_COLLECTION_TAG: ofType<{ data: any }>(),
-    CREATE_COLLECTION_TAG_SUCCESS: ofType<{ tag: TagResource }>(),
-    DELETE_COLLECTION_TAG: ofType<{ uuid: string }>(),
-    DELETE_COLLECTION_TAG_SUCCESS: ofType<{ uuid: string }>()
+    LOAD_COLLECTION_SUCCESS: ofType<{ item: CollectionResource }>()
 });
 
 export type CollectionPanelAction = UnionOf<typeof collectionPanelActions>;
@@ -37,46 +31,41 @@ export const loadCollectionPanel = (uuid: string) =>
         dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: collection }));
         dispatch(resourcesActions.SET_RESOURCES([collection]));
         dispatch<any>(loadCollectionFiles(collection.uuid));
-        dispatch<any>(loadCollectionTags(collection.uuid));
         return collection;
     };
 
-export const loadCollectionTags = (uuid: string) =>
-    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        dispatch(collectionPanelActions.LOAD_COLLECTION_TAGS({ uuid }));
-        return services.tagService
-            .list(uuid)
-            .then(tags => {
-                dispatch(collectionPanelActions.LOAD_COLLECTION_TAGS_SUCCESS({ tags }));
-            });
-    };
-
-export const createCollectionTag = (data: TagProperty) =>
-    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        dispatch(collectionPanelActions.CREATE_COLLECTION_TAG({ data }));
+export const createCollectionTag = (data: TagProperty) => 
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const item = getState().collectionPanel.item;
         const uuid = item ? item.uuid : '';
-        return services.tagService
-            .create(uuid, data)
-            .then(tag => {
-                dispatch(collectionPanelActions.CREATE_COLLECTION_TAG_SUCCESS({ tag }));
-                dispatch(snackbarActions.OPEN_SNACKBAR({
-                    message: "Tag has been successfully added.",
-                    hideDuration: 2000
-                }));
-            });
+        try {
+            if (item) {
+                item.properties[data.key] = data.value;
+                const updatedCollection = await services.collectionService.update(uuid, item);
+                dispatch(resourcesActions.SET_RESOURCES([updatedCollection]));
+                dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Tag has been successfully added.", hideDuration: 2000 }));
+                return updatedCollection;
+            }
+            return;
+        } catch (e) {
+            return;
+        }
     };
 
-export const deleteCollectionTag = (uuid: string) =>
-    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        dispatch(collectionPanelActions.DELETE_COLLECTION_TAG({ uuid }));
-        return services.linkService
-            .delete(uuid)
-            .then(tag => {
-                dispatch(collectionPanelActions.DELETE_COLLECTION_TAG_SUCCESS({ uuid: tag.uuid }));
-                dispatch(snackbarActions.OPEN_SNACKBAR({
-                    message: "Tag has been successfully deleted.",
-                    hideDuration: 2000
-                }));
-            });
+export const deleteCollectionTag = (key: string) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const item = getState().collectionPanel.item;
+        const uuid = item ? item.uuid : '';
+        try {
+            if (item) {
+                delete item.properties[key];
+                const updatedCollection = await services.collectionService.update(uuid, item);
+                dispatch(resourcesActions.SET_RESOURCES([updatedCollection]));
+                dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Tag has been successfully deleted.", hideDuration: 2000 }));
+                return updatedCollection;
+            }
+            return;
+        } catch (e) {
+            return;
+        }
     };
index 2c3edf1a5afce13ec9059f523f042df3eef9751a..b4951b81826b14426b72e813eda7e93d14c2f8f6 100644 (file)
@@ -4,23 +4,17 @@
 
 import { collectionPanelActions, CollectionPanelAction } from "./collection-panel-action";
 import { CollectionResource } from "~/models/collection";
-import { TagResource } from "~/models/tag";
 
 export interface CollectionPanelState {
     item: CollectionResource | null;
-    tags: TagResource[];
 }
 
 const initialState = {
-    item: null,
-    tags: []
+    item: null
 };
 
 export const collectionPanelReducer = (state: CollectionPanelState = initialState, action: CollectionPanelAction) =>
     collectionPanelActions.match(action, {
         default: () => state,
         LOAD_COLLECTION_SUCCESS: ({ item }) => ({ ...state, item }),
-        LOAD_COLLECTION_TAGS_SUCCESS: ({ tags }) => ({...state, tags }),
-        CREATE_COLLECTION_TAG_SUCCESS: ({ tag }) => ({...state, tags: [...state.tags, tag] }),
-        DELETE_COLLECTION_TAG_SUCCESS: ({ uuid }) => ({...state, tags: state.tags.filter(tag => tag.uuid !== uuid) })
     });
index de55a2cb50be1796d444470654e76eaa03535059..6c765568aaf9ddd707ee283ffa4add5571199c24 100644 (file)
@@ -6,6 +6,7 @@ import { dialogActions } from '~/store/dialog/dialog-actions';
 import { RootState } from '../store';
 import { Dispatch } from 'redux';
 import { getProcess } from '~/store/processes/process';
+import { quote } from 'shell-quote';
 
 export const PROCESS_COMMAND_DIALOG_NAME = 'processCommandDialog';
 
@@ -19,7 +20,7 @@ export const openProcessCommandDialog = (processUuid: string) =>
         const process = getProcess(processUuid)(getState().resources);
         if (process) {
             const data: ProcessCommandDialogData = {
-                command: process.containerRequest.command.join(' '),
+                command: quote(process.containerRequest.command),
                 processName: process.containerRequest.name,
             };
             dispatch(dialogActions.OPEN_DIALOG({ id: PROCESS_COMMAND_DIALOG_NAME, data }));
index 4bde68d8be42776c5a2ca891d73db6ce712c9458..81022ea56fe982297d44be5d92ab9f20fbaa47bd 100644 (file)
@@ -3,20 +3,25 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from "react";
-import { Dialog, DialogTitle, DialogActions, Button, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
+import { Dialog, DialogTitle, DialogActions, Button, StyleRulesCallback, WithStyles, withStyles, Tooltip, IconButton, Grid, CardHeader } from '@material-ui/core';
 import { withDialog } from "~/store/dialog/with-dialog";
 import { PROCESS_COMMAND_DIALOG_NAME } from '~/store/processes/process-command-actions';
 import { WithDialogProps } from '~/store/dialog/with-dialog';
 import { ProcessCommandDialogData } from '~/store/processes/process-command-actions';
 import { DefaultCodeSnippet } from "~/components/default-code-snippet/default-code-snippet";
 import { compose } from 'redux';
+import * as CopyToClipboard from "react-copy-to-clipboard";
+import { CopyIcon } from '~/components/icon/icon';
 
-type CssRules = 'codeSnippet';
+type CssRules = 'codeSnippet' | 'copyToClipboard';
 
 const styles: StyleRulesCallback<CssRules> = theme => ({
     codeSnippet: {
         marginLeft: theme.spacing.unit * 3,
         marginRight: theme.spacing.unit * 3,
+    },
+    copyToClipboard: {
+        marginRight: theme.spacing.unit,
     }
 });
 
@@ -30,7 +35,17 @@ export const ProcessCommandDialog = compose(
             maxWidth="md"
             onClose={props.closeDialog}
             style={{ alignSelf: 'stretch' }}>
-            <DialogTitle>{`Command - ${props.data.processName}`}</DialogTitle>
+            <CardHeader
+                title={`Command - ${props.data.processName}`}
+                action={
+                    <Tooltip title="Copy to clipboard">
+                        <CopyToClipboard text={props.data.command}>
+                            <IconButton className={props.classes.copyToClipboard}>
+                                <CopyIcon />
+                            </IconButton>
+                        </CopyToClipboard>
+                    </Tooltip>
+                } />
             <DefaultCodeSnippet
                 className={props.classes.codeSnippet}
                 lines={[props.data.command]} />
diff --git a/src/views-components/progress/content-progress.tsx b/src/views-components/progress/content-progress.tsx
deleted file mode 100644 (file)
index fa2cad5..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// // Copyright (C) The Arvados Authors. All rights reserved.
-// //
-// // SPDX-License-Identifier: AGPL-3.0
-//
-// import * as React from 'react';
-// import { CircularProgress } from '@material-ui/core';
-// import { withProgress } from '~/store/progress-indicator/with-progress';
-// import { WithProgressStateProps } from '~/store/progress-indicator/with-progress';
-// import { ProgressIndicatorData } from '~/store/progress-indicator/progress-indicator-reducer';
-//
-// export const ContentProgress = withProgress(ProgressIndicatorData.CONTENT_PROGRESS)((props: WithProgressStateProps) =>
-//     props.started ? <CircularProgress /> : null
-// );
diff --git a/src/views-components/progress/side-panel-progress.tsx b/src/views-components/progress/side-panel-progress.tsx
deleted file mode 100644 (file)
index 2d832a5..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// // Copyright (C) The Arvados Authors. All rights reserved.
-// //
-// // SPDX-License-Identifier: AGPL-3.0
-//
-// import * as React from 'react';
-// import { CircularProgress } from '@material-ui/core';
-// import { withProgress } from '~/store/progress-indicator/with-progress';
-// import { WithProgressStateProps } from '~/store/progress-indicator/with-progress';
-// import { ProgressIndicatorData } from '~/store/progress-indicator/progress-indicator-reducer';
-//
-// export const SidePanelProgress = withProgress(ProgressIndicatorData.SIDE_PANEL_PROGRESS)((props: WithProgressStateProps) =>
-//     props.started ? <span style={{ display: 'flex', justifyContent: 'center', marginTop: "40px" }}><CircularProgress /></span> : null
-// );
diff --git a/src/views-components/progress/workbench-progress.tsx b/src/views-components/progress/workbench-progress.tsx
deleted file mode 100644 (file)
index 1fdd57c..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-// import * as React from 'react';
-// import { LinearProgress } from '@material-ui/core';
-// import { withProgress } from '~/store/progress-indicator/with-progress';
-// import { WithProgressStateProps } from '~/store/progress-indicator/with-progress';
-// import { ProgressIndicatorData } from '~/store/progress-indicator/progress-indicator-reducer';
-
-// export const WorkbenchProgress = withProgress(ProgressIndicatorData.WORKBENCH_PROGRESS)(
-//     (props: WithProgressStateProps) =>
-//         props.started ? <LinearProgress color="secondary" /> : null
-// );
index 7449e1e2f82027afeb870a834031dc584df6390d..03fe57e4782fb91062665e47079b0c618daa0a92 100644 (file)
@@ -5,7 +5,7 @@
 import * as React from "react";
 import { connect } from "react-redux";
 import { RootState } from "~/store/store";
-import MaterialSnackbar, { SnackbarProps } from "@material-ui/core/Snackbar";
+import MaterialSnackbar, { SnackbarOrigin } from "@material-ui/core/Snackbar";
 import { Dispatch } from "redux";
 import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions";
 import IconButton from '@material-ui/core/IconButton';
@@ -20,7 +20,20 @@ import { ArvadosTheme } from "~/common/custom-theme";
 import { amber, green } from "@material-ui/core/colors";
 import * as classNames from 'classnames';
 
-const mapStateToProps = (state: RootState): SnackbarProps & ArvadosSnackbarProps => {
+interface SnackbarDataProps {
+    anchorOrigin?: SnackbarOrigin;
+    autoHideDuration?: number;
+    open: boolean;
+    message?: React.ReactElement<any>;
+    kind: SnackbarKind;
+}
+
+interface SnackbarEventProps {
+    onClose?: (event: React.SyntheticEvent<any>, reason: string) => void;
+    onExited: () => void;
+}
+
+const mapStateToProps = (state: RootState): SnackbarDataProps => {
     const messages = state.snackbar.messages;
     return {
         anchorOrigin: { vertical: "bottom", horizontal: "right" },
@@ -31,7 +44,7 @@ const mapStateToProps = (state: RootState): SnackbarProps & ArvadosSnackbarProps
     };
 };
 
-const mapDispatchToProps = (dispatch: Dispatch) => ({
+const mapDispatchToProps = (dispatch: Dispatch): SnackbarEventProps => ({
     onClose: (event: any, reason: string) => {
         if (reason !== "clickaway") {
             dispatch(snackbarActions.CLOSE_SNACKBAR());
@@ -42,10 +55,6 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
     }
 });
 
-const ArvadosSnackbar = (props: any) => <MaterialSnackbar {...props}>
-    <ArvadosSnackbarContent {...props}/>
-</MaterialSnackbar>;
-
 type CssRules = "success" | "error" | "info" | "warning" | "icon" | "iconVariant" | "message";
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
@@ -74,62 +83,47 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     },
 });
 
-interface ArvadosSnackbarProps {
-    kind: SnackbarKind;
-}
+export const Snackbar = withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(
+    (props: SnackbarDataProps & SnackbarEventProps & WithStyles<CssRules>) => {
+        const { classes } = props;
 
-const ArvadosSnackbarContent = (props: SnackbarProps & ArvadosSnackbarProps & WithStyles<CssRules>) => {
-    const { classes, className, message, onClose, kind } = props;
+        const variants = {
+            [SnackbarKind.INFO]: [InfoIcon, classes.info],
+            [SnackbarKind.WARNING]: [WarningIcon, classes.warning],
+            [SnackbarKind.SUCCESS]: [CheckCircleIcon, classes.success],
+            [SnackbarKind.ERROR]: [ErrorIcon, classes.error]
+        };
 
-    let Icon = InfoIcon;
-    let cssClass = classes.info;
+        const [Icon, cssClass] = variants[props.kind];
 
-    switch (kind) {
-        case SnackbarKind.INFO:
-            Icon = InfoIcon;
-            cssClass = classes.info;
-            break;
-        case SnackbarKind.WARNING:
-            Icon = WarningIcon;
-            cssClass = classes.warning;
-            break;
-        case SnackbarKind.SUCCESS:
-            Icon = CheckCircleIcon;
-            cssClass = classes.success;
-            break;
-        case SnackbarKind.ERROR:
-            Icon = ErrorIcon;
-            cssClass = classes.error;
-            break;
+        return (
+            <MaterialSnackbar
+                open={props.open}
+                message={props.message}
+                onClose={props.onClose}
+                onExited={props.onExited}
+                anchorOrigin={props.anchorOrigin}
+                autoHideDuration={props.autoHideDuration}>
+                <SnackbarContent
+                    className={classNames(cssClass)}
+                    aria-describedby="client-snackbar"
+                    message={
+                        <span id="client-snackbar" className={classes.message}>
+                            <Icon className={classNames(classes.icon, classes.iconVariant)}/>
+                            {props.message}
+                        </span>
+                    }
+                    action={
+                        <IconButton
+                            key="close"
+                            aria-label="Close"
+                            color="inherit"
+                            onClick={e => props.onClose && props.onClose(e, '')}>
+                            <CloseIcon className={classes.icon}/>
+                        </IconButton>
+                    }
+                />
+            </MaterialSnackbar>
+        );
     }
-
-    return (
-        <SnackbarContent
-            className={classNames(cssClass, className)}
-            aria-describedby="client-snackbar"
-            message={
-                <span id="client-snackbar" className={classes.message}>
-                    <Icon className={classNames(classes.icon, classes.iconVariant)}/>
-                    {message}
-                </span>
-            }
-            action={
-                <IconButton
-                    key="close"
-                    aria-label="Close"
-                    color="inherit"
-                    onClick={e => {
-                        if (onClose) {
-                            onClose(e, '');
-                        }
-                    }}>
-                    <CloseIcon className={classes.icon}/>
-                </IconButton>
-            }
-        />
-    );
-};
-
-export const Snackbar = connect(mapStateToProps, mapDispatchToProps)(
-    withStyles(styles)(ArvadosSnackbar)
-);
+));
index 8e46385cc9cfa694c938c6b1ce5183e32d7f858c..0b264b6bab4593a454b5e9220c51274c9c44c392 100644 (file)
@@ -16,7 +16,6 @@ import { DetailsAttribute } from '~/components/details-attribute/details-attribu
 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';
@@ -55,7 +54,6 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 
 interface CollectionPanelDataProps {
     item: CollectionResource;
-    tags: TagResource[];
 }
 
 type CollectionPanelProps = CollectionPanelDataProps & DispatchProp
@@ -66,13 +64,12 @@ export const CollectionPanel = withStyles(styles)(
     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
@@ -118,10 +115,10 @@ export const CollectionPanel = withStyles(styles)(
                                 <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>
@@ -147,8 +144,8 @@ export const CollectionPanel = withStyles(styles)(
                 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 = () => {
@@ -160,8 +157,3 @@ export const CollectionPanel = withStyles(styles)(
         }
     )
 );
-
-const renderTagLabel = (tag: TagResource) => {
-    const { properties } = tag;
-    return `${properties.key}: ${properties.value}`;
-};
index 30e94bdefb4c9be9d37fc394908c15653130d55f..c8148433ef7250b47fb7b54896da373b806b40aa 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
     "@types/react" "*"
     redux "^3.6.0 || ^4.0.0"
 
+"@types/shell-quote@1.6.0":
+  version "1.6.0"
+  resolved "https://registry.yarnpkg.com/@types/shell-quote/-/shell-quote-1.6.0.tgz#537b2949a2ebdcb0d353e448fee45b081021963f"
+
 "@types/uuid@3.4.4":
   version "3.4.4"
   resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-3.4.4.tgz#7af69360fa65ef0decb41fd150bf4ca5c0cefdf5"