[ARVADOS-WORKBENCH2] updated: 1.1.4-478-g833a5d0

Git user git at public.curoverse.com
Thu Aug 2 09:40:22 EDT 2018


Summary of changes:
 src/store/dialog/dialog-actions.ts                 | 15 ++++++++++
 src/store/dialog/dialog-reducer.test.ts            | 30 +++++++++++++++++++
 src/store/dialog/dialog-reducer.ts                 | 22 ++++++++++++++
 src/store/dialog/with-dialog.ts                    | 33 +++++++++++++++++++++
 src/store/store.ts                                 |  3 ++
 .../action-sets/collection-files-action-set.ts     |  3 +-
 .../collection-files-item-action-set.ts            |  3 +-
 .../remove-dialog/remove-dialog.tsx                | 34 ++++++++++++++++++++++
 src/views/workbench/workbench.tsx                  |  2 ++
 9 files changed, 143 insertions(+), 2 deletions(-)
 create mode 100644 src/store/dialog/dialog-actions.ts
 create mode 100644 src/store/dialog/dialog-reducer.test.ts
 create mode 100644 src/store/dialog/dialog-reducer.ts
 create mode 100644 src/store/dialog/with-dialog.ts
 create mode 100644 src/views-components/remove-dialog/remove-dialog.tsx

       via  833a5d07f87b31133ade505b82215b9a5d47bdc3 (commit)
       via  922a67467d2b7cc9995bbde095d9c2fa5b4518a9 (commit)
       via  7395e152908d17d2078ace72f1f8713c4c8a1f41 (commit)
       via  4f46e3cc8ebe88041fdd044d81fb39a0f0396f3c (commit)
      from  2a4998819eacf85fe1ceefe6bfbcc73e03a87452 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 833a5d07f87b31133ade505b82215b9a5d47bdc3
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Thu Aug 2 15:39:56 2018 +0200

    Mock collection files removal dialogs
    
    Feature #13855
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/views-components/context-menu/action-sets/collection-files-action-set.ts b/src/views-components/context-menu/action-sets/collection-files-action-set.ts
index dc17e69..9396b9e 100644
--- a/src/views-components/context-menu/action-sets/collection-files-action-set.ts
+++ b/src/views-components/context-menu/action-sets/collection-files-action-set.ts
@@ -4,6 +4,7 @@
 
 import { ContextMenuActionSet } from "../context-menu-action-set";
 import { collectionPanelFilesAction } from "../../../store/collection-panel/collection-panel-files/collection-panel-files-actions";
+import { openRemoveDialog } from "../../remove-dialog/remove-dialog";
 
 
 export const collectionFilesActionSet: ContextMenuActionSet = [[{
@@ -19,7 +20,7 @@ export const collectionFilesActionSet: ContextMenuActionSet = [[{
 },{
     name: "Remove selected",
     execute: (dispatch, resource) => {
-        return;
+        dispatch(openRemoveDialog('selected files'));
     }
 },{
     name: "Download selected",
diff --git a/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts b/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts
index 5e84276..da11b47 100644
--- a/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts
+++ b/src/views-components/context-menu/action-sets/collection-files-item-action-set.ts
@@ -4,6 +4,7 @@
 
 import { ContextMenuActionSet } from "../context-menu-action-set";
 import { RenameIcon, DownloadIcon, RemoveIcon } from "../../../components/icon/icon";
+import { openRemoveDialog } from "../../remove-dialog/remove-dialog";
 
 
 export const collectionFilesItemActionSet: ContextMenuActionSet = [[{
@@ -22,6 +23,6 @@ export const collectionFilesItemActionSet: ContextMenuActionSet = [[{
     name: "Remove",
     icon: RemoveIcon,
     execute: (dispatch, resource) => {
-        return;
+        dispatch(openRemoveDialog('selected file'));
     }
 }]];
diff --git a/src/views-components/remove-dialog/remove-dialog.tsx b/src/views-components/remove-dialog/remove-dialog.tsx
new file mode 100644
index 0000000..f08727f
--- /dev/null
+++ b/src/views-components/remove-dialog/remove-dialog.tsx
@@ -0,0 +1,34 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { Dialog, DialogTitle, DialogContent, DialogActions, Button } from "@material-ui/core";
+import { withDialog } from "../../store/dialog/with-dialog";
+import { dialogActions } from "../../store/dialog/dialog-actions";
+
+export const REMOVE_DIALOG = 'removeCollectionFilesDialog';
+
+export const RemoveDialog = withDialog(REMOVE_DIALOG)(
+    (props) =>
+        <Dialog open={props.open}>
+            <DialogTitle>{`Removing ${props.data}`}</DialogTitle>
+            <DialogContent>
+                {`Are you sure you want to remove ${props.data}?`}
+            </DialogContent>
+            <DialogActions>
+                <Button
+                    variant='flat'
+                    color='primary'
+                    onClick={props.closeDialog}>
+                    Cancel
+                </Button>
+                <Button variant='raised' color='primary'>
+                    Remove
+                </Button>
+            </DialogActions>
+        </Dialog>
+);
+
+export const openRemoveDialog = (removedDataName: string) =>
+    dialogActions.OPEN_DIALOG({ id: REMOVE_DIALOG, data: removedDataName });
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index 160e12f..6fc3484 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -41,6 +41,7 @@ import { CreateCollectionDialog } from '../../views-components/create-collection
 import { CollectionPanel } from '../collection-panel/collection-panel';
 import { loadCollection } from '../../store/collection-panel/collection-panel-action';
 import { getCollectionUrl } from '../../models/collection';
+import { RemoveDialog } from '../../views-components/remove-dialog/remove-dialog';
 
 const drawerWidth = 240;
 const appBarHeight = 100;
@@ -226,6 +227,7 @@ export const Workbench = withStyles(styles)(
                         <Snackbar />
                         <CreateProjectDialog />
                         <CreateCollectionDialog />
+                        <RemoveDialog />
                         <CurrentTokenDialog
                             currentToken={this.props.currentToken}
                             open={this.state.isCurrentTokenDialogOpen}

commit 922a67467d2b7cc9995bbde095d9c2fa5b4518a9
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Thu Aug 2 15:39:21 2018 +0200

    Pass closeDialog action into component wrapped withDialog
    
    Feature #13855
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/store/dialog/with-dialog.ts b/src/store/dialog/with-dialog.ts
index 60cb5d1..42ae73e 100644
--- a/src/store/dialog/with-dialog.ts
+++ b/src/store/dialog/with-dialog.ts
@@ -5,17 +5,29 @@
 import * as React from 'react';
 import { connect } from 'react-redux';
 import { DialogState } from './dialog-reducer';
+import { Dispatch } from 'redux';
+import { dialogActions } from './dialog-actions';
 
 export type WithDialog<T> = {
     open: boolean;
     data?: T;
 };
 
+export type WithDialogActions = {
+    closeDialog: () => void;
+};
+
 export const withDialog = (id: string) =>
-    <T>(component: React.ComponentType<WithDialog<T>>) =>
-        connect(mapStateToProps(id))(component);
+    <T>(component: React.ComponentType<WithDialog<T> & WithDialogActions>) =>
+        connect(mapStateToProps(id), mapDispatchToProps(id))(component);
 
 export const mapStateToProps = (id: string) => <T>(state: { dialog: DialogState }): WithDialog<T> => {
     const dialog = state.dialog[id];
     return dialog ? dialog : { open: false };
 };
+
+export const mapDispatchToProps = (id: string) => (dispatch: Dispatch): WithDialogActions => ({
+    closeDialog: () => {
+        dispatch(dialogActions.CLOSE_DIALOG({ id }));
+    }
+});
\ No newline at end of file

commit 7395e152908d17d2078ace72f1f8713c4c8a1f41
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Thu Aug 2 15:38:41 2018 +0200

    Persist dialog data after closing to avoid dialog content blinking
    
    Feature #13855
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/store/dialog/dialog-reducer.test.ts b/src/store/dialog/dialog-reducer.test.ts
index 1beb6ee..f0bf9be 100644
--- a/src/store/dialog/dialog-reducer.test.ts
+++ b/src/store/dialog/dialog-reducer.test.ts
@@ -18,4 +18,13 @@ describe('DialogReducer', () => {
         const state = dialogReducer({}, dialogActions.CLOSE_DIALOG({ id }));
         expect(state[id]).toEqual({ open: false });
     });
+    
+    it('CLOSE_DIALOG persist data', () => {
+        const id = 'test id';
+        const [newState] = [{}]
+            .map(state => dialogReducer(state, dialogActions.OPEN_DIALOG({ id, data: 'test data' })))
+            .map(state => dialogReducer(state, dialogActions.CLOSE_DIALOG({ id })));
+        
+        expect(newState[id]).toEqual({ open: false, data: 'test data' });
+    });
 });
diff --git a/src/store/dialog/dialog-reducer.ts b/src/store/dialog/dialog-reducer.ts
index 6013ab6..e49f65d 100644
--- a/src/store/dialog/dialog-reducer.ts
+++ b/src/store/dialog/dialog-reducer.ts
@@ -14,7 +14,9 @@ export interface Dialog {
 export const dialogReducer = (state: DialogState = {}, action: DialogAction) =>
     dialogActions.match(action, {
         OPEN_DIALOG: ({ id, data }) => ({ ...state, [id]: { open: true, data } }),
-        CLOSE_DIALOG: ({ id }) => ({ ...state, [id]: { open: false } }),
+        CLOSE_DIALOG: ({ id }) => ({ 
+            ...state, 
+            [id]: state[id] ? { ...state[id], open: false } : { open: false } }),
         default: () => state,
     });
 

commit 4f46e3cc8ebe88041fdd044d81fb39a0f0396f3c
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Thu Aug 2 15:04:55 2018 +0200

    Create generic dialog state
    
    Feature #13855
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/store/dialog/dialog-actions.ts b/src/store/dialog/dialog-actions.ts
new file mode 100644
index 0000000..df4418f
--- /dev/null
+++ b/src/store/dialog/dialog-actions.ts
@@ -0,0 +1,15 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { default as unionize, ofType, UnionOf } from "unionize";
+
+export const dialogActions = unionize({
+    OPEN_DIALOG: ofType<{ id: string, data: any }>(),
+    CLOSE_DIALOG: ofType<{ id: string }>()
+}, {
+        tag: 'type',
+        value: 'payload'
+    });
+
+export type DialogAction = UnionOf<typeof dialogActions>;
diff --git a/src/store/dialog/dialog-reducer.test.ts b/src/store/dialog/dialog-reducer.test.ts
new file mode 100644
index 0000000..1beb6ee
--- /dev/null
+++ b/src/store/dialog/dialog-reducer.test.ts
@@ -0,0 +1,21 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { dialogReducer } from "./dialog-reducer";
+import { dialogActions } from "./dialog-actions";
+
+describe('DialogReducer', () => {
+    it('OPEN_DIALOG', () => {
+        const id = 'test id';
+        const data = 'test data';
+        const state = dialogReducer({}, dialogActions.OPEN_DIALOG({ id, data }));
+        expect(state[id]).toEqual({ open: true, data });
+    });
+
+    it('CLOSE_DIALOG', () => {
+        const id = 'test id';
+        const state = dialogReducer({}, dialogActions.CLOSE_DIALOG({ id }));
+        expect(state[id]).toEqual({ open: false });
+    });
+});
diff --git a/src/store/dialog/dialog-reducer.ts b/src/store/dialog/dialog-reducer.ts
new file mode 100644
index 0000000..6013ab6
--- /dev/null
+++ b/src/store/dialog/dialog-reducer.ts
@@ -0,0 +1,20 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { DialogAction, dialogActions } from "./dialog-actions";
+
+export type DialogState = Record<string, Dialog>;
+
+export interface Dialog {
+    open: boolean;
+    data?: any;
+}
+
+export const dialogReducer = (state: DialogState = {}, action: DialogAction) =>
+    dialogActions.match(action, {
+        OPEN_DIALOG: ({ id, data }) => ({ ...state, [id]: { open: true, data } }),
+        CLOSE_DIALOG: ({ id }) => ({ ...state, [id]: { open: false } }),
+        default: () => state,
+    });
+
diff --git a/src/store/dialog/with-dialog.ts b/src/store/dialog/with-dialog.ts
new file mode 100644
index 0000000..60cb5d1
--- /dev/null
+++ b/src/store/dialog/with-dialog.ts
@@ -0,0 +1,21 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { connect } from 'react-redux';
+import { DialogState } from './dialog-reducer';
+
+export type WithDialog<T> = {
+    open: boolean;
+    data?: T;
+};
+
+export const withDialog = (id: string) =>
+    <T>(component: React.ComponentType<WithDialog<T>>) =>
+        connect(mapStateToProps(id))(component);
+
+export const mapStateToProps = (id: string) => <T>(state: { dialog: DialogState }): WithDialog<T> => {
+    const dialog = state.dialog[id];
+    return dialog ? dialog : { open: false };
+};
diff --git a/src/store/store.ts b/src/store/store.ts
index 9d888ef..0ce4616 100644
--- a/src/store/store.ts
+++ b/src/store/store.ts
@@ -22,6 +22,7 @@ import { CollectionPanelFilesState } from './collection-panel/collection-panel-f
 import { collectionPanelFilesReducer } from './collection-panel/collection-panel-files/collections-panel-files-reducer';
 import { CollectionCreatorState, collectionCreationReducer } from './collections/creator/collection-creator-reducer';
 import { CollectionPanelState, collectionPanelReducer } from './collection-panel/collection-panel-reducer';
+import { DialogState, dialogReducer } from './dialog/dialog-reducer';
 
 const composeEnhancers =
     (process.env.NODE_ENV === 'development' &&
@@ -41,6 +42,7 @@ export interface RootState {
     favorites: FavoritesState;
     snackbar: SnackbarState;
     collectionPanelFiles: CollectionPanelFilesState;
+    dialog: DialogState;
 }
 
 const rootReducer = combineReducers({
@@ -57,6 +59,7 @@ const rootReducer = combineReducers({
     favorites: favoritesReducer,
     snackbar: snackbarReducer,
     collectionPanelFiles: collectionPanelFilesReducer,
+    dialog: dialogReducer
 });
 
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list