[ARVADOS-WORKBENCH2] created: 1.2.0-715-g6f73d03

Git user git at public.curoverse.com
Tue Oct 23 09:50:32 EDT 2018


        at  6f73d03da9243243e52acedc60c34398fb1ce436 (commit)


commit 6f73d03da9243243e52acedc60c34398fb1ce436
Author: Janicki Artur <artur.janicki at contractors.roche.com>
Date:   Tue Oct 23 15:50:20 2018 +0200

    init link for copy collection snackbar
    
    Feature #14316
    
    Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>

diff --git a/src/common/custom-theme.ts b/src/common/custom-theme.ts
index 98380b9..f7559ee 100644
--- a/src/common/custom-theme.ts
+++ b/src/common/custom-theme.ts
@@ -27,6 +27,7 @@ interface Colors {
     yellow700: string;
     red900: string;
     blue500: string;
+    purple: string;
 }
 
 const arvadosPurple = '#361336';
@@ -44,6 +45,7 @@ export const themeOptions: ArvadosThemeOptions = {
             yellow700: yellow["700"],
             red900: red['900'],
             blue500: blue['500'],
+            purple: arvadosPurple
         }
     },
     overrides: {
diff --git a/src/store/collections/collection-copy-actions.ts b/src/store/collections/collection-copy-actions.ts
index 058d2dd..d038760 100644
--- a/src/store/collections/collection-copy-actions.ts
+++ b/src/store/collections/collection-copy-actions.ts
@@ -30,10 +30,10 @@ export const copyCollection = (resource: CopyFormDialogData) =>
             const collection = await services.collectionService.get(resource.uuid);
             const uuidKey = 'uuid';
             delete collection[uuidKey];
-            await services.collectionService.create({ ...collection, ownerUuid: resource.ownerUuid, name: resource.name });
+            const newCollection = await services.collectionService.create({ ...collection, ownerUuid: resource.ownerUuid, name: resource.name });
             dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_COPY_FORM_NAME }));
             dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_COPY_FORM_NAME));
-            return collection;
+            return newCollection;
         } catch (e) {
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
diff --git a/src/store/snackbar/snackbar-actions.ts b/src/store/snackbar/snackbar-actions.ts
index d6d7128..e11d26d 100644
--- a/src/store/snackbar/snackbar-actions.ts
+++ b/src/store/snackbar/snackbar-actions.ts
@@ -8,6 +8,7 @@ export interface SnackbarMessage {
     message: string;
     hideDuration: number;
     kind: SnackbarKind;
+    link?: string;
 }
 
 export enum SnackbarKind {
@@ -18,7 +19,7 @@ export enum SnackbarKind {
 }
 
 export const snackbarActions = unionize({
-    OPEN_SNACKBAR: ofType<{message: string; hideDuration?: number, kind?: SnackbarKind}>(),
+    OPEN_SNACKBAR: ofType<{message: string; hideDuration?: number, kind?: SnackbarKind, link?: string}>(),
     CLOSE_SNACKBAR: ofType<{}>(),
     SHIFT_MESSAGES: ofType<{}>()
 });
diff --git a/src/store/snackbar/snackbar-reducer.ts b/src/store/snackbar/snackbar-reducer.ts
index 73c566f..fa1717c 100644
--- a/src/store/snackbar/snackbar-reducer.ts
+++ b/src/store/snackbar/snackbar-reducer.ts
@@ -24,7 +24,8 @@ export const snackbarReducer = (state = initialState, action: SnackbarAction) =>
                 messages: state.messages.concat({
                     message: data.message,
                     hideDuration: data.hideDuration ? data.hideDuration : DEFAULT_HIDE_DURATION,
-                    kind: data.kind ? data.kind : SnackbarKind.INFO
+                    kind: data.kind ? data.kind : SnackbarKind.INFO, 
+                    link: data.link
                 })
             };
         },
diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts
index 1f31656..774e96e 100644
--- a/src/store/workbench/workbench-actions.ts
+++ b/src/store/workbench/workbench-actions.ts
@@ -53,6 +53,7 @@ import { collectionPanelActions } from "~/store/collection-panel/collection-pane
 import { CollectionResource } from "~/models/collection";
 import { searchResultsPanelActions, loadSearchResultsPanel } from '~/store/search-results-panel/search-results-panel-actions';
 import { searchResultsPanelColumns } from '~/views/search-results-panel/search-results-panel-view';
+import * as uuid from 'uuid/v4';
 
 export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
 
@@ -256,12 +257,20 @@ export const updateCollection = (data: collectionUpdateActions.CollectionUpdateF
 export const copyCollection = (data: CopyFormDialogData) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         try {
+            const oldProject = getResource(data.ownerUuid)(getState().resources);
             const collection = await dispatch<any>(collectionCopyActions.copyCollection(data));
-            dispatch<any>(updateResources([collection]));
-            dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
-            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been copied.', hideDuration: 2000 }));
+            // dispatch<any>(updateResources([collection]));
+            if (oldProject && collection) {
+                dispatch<any>(reloadProjectMatchingUuid([oldProject.uuid]));
+                dispatch(snackbarActions.OPEN_SNACKBAR({
+                    message: 'Collection has been copied.',
+                    hideDuration: 3000,
+                    kind: SnackbarKind.SUCCESS,
+                    link: collection.ownerUuid
+                }));
+            }
         } catch (e) {
-            dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000 }));
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000, kind: SnackbarKind.ERROR }));
         }
     };
 
diff --git a/src/views-components/snackbar/snackbar.tsx b/src/views-components/snackbar/snackbar.tsx
index 03fe57e..f3149e6 100644
--- a/src/views-components/snackbar/snackbar.tsx
+++ b/src/views-components/snackbar/snackbar.tsx
@@ -3,19 +3,18 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from "react";
+import { Dispatch } from "redux";
 import { connect } from "react-redux";
 import { RootState } from "~/store/store";
+import { Button, IconButton, StyleRulesCallback, WithStyles, withStyles, SnackbarContent } from '@material-ui/core';
 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';
-import SnackbarContent from '@material-ui/core/SnackbarContent';
+import { navigateToProject } from '~/store/navigation/navigation-action';
 import WarningIcon from '@material-ui/icons/Warning';
 import CheckCircleIcon from '@material-ui/icons/CheckCircle';
 import ErrorIcon from '@material-ui/icons/Error';
 import InfoIcon from '@material-ui/icons/Info';
 import CloseIcon from '@material-ui/icons/Close';
-import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
 import { ArvadosTheme } from "~/common/custom-theme";
 import { amber, green } from "@material-ui/core/colors";
 import * as classNames from 'classnames';
@@ -26,11 +25,13 @@ interface SnackbarDataProps {
     open: boolean;
     message?: React.ReactElement<any>;
     kind: SnackbarKind;
+    link?: string;
 }
 
 interface SnackbarEventProps {
     onClose?: (event: React.SyntheticEvent<any>, reason: string) => void;
     onExited: () => void;
+    onClick: (uuid: string) => void;
 }
 
 const mapStateToProps = (state: RootState): SnackbarDataProps => {
@@ -40,7 +41,8 @@ const mapStateToProps = (state: RootState): SnackbarDataProps => {
         open: state.snackbar.open,
         message: <span>{messages.length > 0 ? messages[0].message : ""}</span>,
         autoHideDuration: messages.length > 0 ? messages[0].hideDuration : 0,
-        kind: messages.length > 0 ? messages[0].kind : SnackbarKind.INFO
+        kind: messages.length > 0 ? messages[0].kind : SnackbarKind.INFO,
+        link: messages.length > 0 ? messages[0].link : ''
     };
 };
 
@@ -52,10 +54,13 @@ const mapDispatchToProps = (dispatch: Dispatch): SnackbarEventProps => ({
     },
     onExited: () => {
         dispatch(snackbarActions.SHIFT_MESSAGES());
+    },
+    onClick: (uuid: string) => {
+        dispatch(navigateToProject(uuid));
     }
 });
 
-type CssRules = "success" | "error" | "info" | "warning" | "icon" | "iconVariant" | "message";
+type CssRules = "success" | "error" | "info" | "warning" | "icon" | "iconVariant" | "message" | "linkButton";
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     success: {
@@ -81,10 +86,15 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         display: 'flex',
         alignItems: 'center'
     },
+    linkButton: {
+        fontWeight: 'bolder'
+    }
 });
 
+type SnackbarProps = SnackbarDataProps & SnackbarEventProps & WithStyles<CssRules>;
+
 export const Snackbar = withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(
-    (props: SnackbarDataProps & SnackbarEventProps & WithStyles<CssRules>) => {
+    (props: SnackbarProps) => {
         const { classes } = props;
 
         const variants = {
@@ -96,6 +106,8 @@ export const Snackbar = withStyles(styles)(connect(mapStateToProps, mapDispatchT
 
         const [Icon, cssClass] = variants[props.kind];
 
+
+
         return (
             <MaterialSnackbar
                 open={props.open}
@@ -113,17 +125,35 @@ export const Snackbar = withStyles(styles)(connect(mapStateToProps, mapDispatchT
                             {props.message}
                         </span>
                     }
-                    action={
-                        <IconButton
-                            key="close"
-                            aria-label="Close"
-                            color="inherit"
-                            onClick={e => props.onClose && props.onClose(e, '')}>
-                            <CloseIcon className={classes.icon}/>
-                        </IconButton>
-                    }
+                    action={actions(props)}
                 />
             </MaterialSnackbar>
         );
     }
 ));
+
+const actions = (props: SnackbarProps) => {
+    const { link, onClose, onClick, classes } = props;
+    const actions = [
+        <IconButton
+            key="close"
+            aria-label="Close"
+            color="inherit"
+            onClick={e => onClose && onClose(e, '')}>
+            <CloseIcon className={classes.icon} />
+        </IconButton>
+    ];
+    if (link) {
+        actions.splice(0, 0,
+            <Button key="goTo"
+                aria-label="goTo"
+                size="small"
+                color="inherit"
+                className={classes.linkButton}
+                onClick={() => onClick(link) }>
+                Go To
+            </Button>
+        );
+    }
+    return actions;
+};

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list