[ARVADOS-WORKBENCH2] updated: 1.2.0-340-g4752bff

Git user git at public.curoverse.com
Mon Sep 10 08:53:08 EDT 2018


Summary of changes:
 src/store/processes/process-update-actions.ts      | 15 +++++++++------
 src/store/workbench/workbench-actions.ts           | 22 ++++++++++++----------
 .../context-menu/action-sets/process-action-set.ts |  4 +---
 .../action-sets/process-resource-action-set.ts     |  4 +---
 4 files changed, 23 insertions(+), 22 deletions(-)

       via  4752bffbcf5d0e1fc16f4bb2e7934c348834dd9c (commit)
      from  eb2560b06f58e029b63a169a6809ba514ceab072 (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 4752bffbcf5d0e1fc16f4bb2e7934c348834dd9c
Author: Janicki Artur <artur.janicki at contractors.roche.com>
Date:   Mon Sep 10 14:53:00 2018 +0200

    improve code after CR
    
    Feature #14155
    
    Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>

diff --git a/src/store/processes/process-update-actions.ts b/src/store/processes/process-update-actions.ts
index 7e01ecd..92cf032 100644
--- a/src/store/processes/process-update-actions.ts
+++ b/src/store/processes/process-update-actions.ts
@@ -8,10 +8,9 @@ import { RootState } from "~/store/store";
 import { dialogActions } from "~/store/dialog/dialog-actions";
 import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
 import { ServiceRepository } from "~/services/services";
-import { ProjectResource } from '~/models/project';
-import { ContextMenuResource } from "~/store/context-menu/context-menu-actions";
 import { getProcess } from '~/store/processes/process';
 import { projectPanelActions } from '~/store/project-panel/project-panel-action';
+import { snackbarActions } from '~/store/snackbar/snackbar-actions';
 
 export interface ProcessUpdateFormDialogData {
     uuid: string;
@@ -24,9 +23,10 @@ export const openProcessUpdateDialog = (resource: ProcessUpdateFormDialogData) =
     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const process = getProcess(resource.uuid)(getState().resources);
         if(process) {
-            resource.name = process.containerRequest.name;
-            dispatch(initialize(PROCESS_UPDATE_FORM_NAME, resource));
+            dispatch(initialize(PROCESS_UPDATE_FORM_NAME, { ...resource, name: process.containerRequest.name }));
             dispatch(dialogActions.OPEN_DIALOG({ id: PROCESS_UPDATE_FORM_NAME, data: {} }));
+        } else {
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Process not found', hideDuration: 2000 }));
         }
     };
 
@@ -35,16 +35,19 @@ export const updateProcess = (resource: ProcessUpdateFormDialogData) =>
         dispatch(startSubmit(PROCESS_UPDATE_FORM_NAME));
         try {
             const process = await services.containerRequestService.get(resource.uuid);
-            await services.containerRequestService.update(resource.uuid, { ...process, name: resource.name });
+            const updatedProcess = await services.containerRequestService.update(resource.uuid, { ...process, name: resource.name });
             dispatch(projectPanelActions.REQUEST_ITEMS());
             dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_UPDATE_FORM_NAME }));
-            return process;
+            return updatedProcess;
         } catch (e) {
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
                 dispatch(stopSubmit(PROCESS_UPDATE_FORM_NAME, { name: 'Process with the same name already exists.' }));
             } else if (error === CommonResourceServiceError.MODIFYING_CONTAINER_REQUEST_FINAL_STATE) {
                 dispatch(stopSubmit(PROCESS_UPDATE_FORM_NAME, { name: 'You cannot modified in "Final" state.' }));
+            } else {
+                dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_UPDATE_FORM_NAME }));
+                dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not update the process.', hideDuration: 2000 }));
             }
             return;
         }
diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts
index 1b00c2b..deb07ab 100644
--- a/src/store/workbench/workbench-actions.ts
+++ b/src/store/workbench/workbench-actions.ts
@@ -31,13 +31,11 @@ import * as collectionMoveActions from '~/store/collections/collection-move-acti
 import * as processesActions from '../processes/processes-actions';
 import * as processMoveActions from '~/store/processes/process-move-actions';
 import * as processUpdateActions from '~/store/processes/process-update-actions';
-
 import { trashPanelColumns } from "~/views/trash-panel/trash-panel";
 import { loadTrashPanel, trashPanelActions } from "~/store/trash-panel/trash-panel-action";
 import { initProcessLogsPanel } from '../process-logs-panel/process-logs-panel-actions';
 import { loadProcessPanel } from '~/store/process-panel/process-panel-actions';
 
-
 export const loadWorkbench = () =>
     async (dispatch: Dispatch, getState: () => RootState) => {
         const { auth, router } = getState();
@@ -199,14 +197,18 @@ export const loadProcess = (uuid: string) =>
 
 export const updateProcess = (data: processUpdateActions.ProcessUpdateFormDialogData) =>
     async (dispatch: Dispatch) => {
-        const process = await dispatch<any>(processUpdateActions.updateProcess(data));
-        if (process) {
-            dispatch(snackbarActions.OPEN_SNACKBAR({
-                message: "Process has been successfully updated.",
-                hideDuration: 2000
-            }));
-            dispatch<any>(updateResources([process]));
-            dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
+        try {
+            const process = await dispatch<any>(processUpdateActions.updateProcess(data));
+            if (process) {
+                dispatch(snackbarActions.OPEN_SNACKBAR({
+                    message: "Process has been successfully updated.",
+                    hideDuration: 2000
+                }));
+                dispatch<any>(updateResources([process]));
+                dispatch<any>(reloadProjectMatchingUuid([process.ownerUuid]));
+            }
+        } catch (e) {
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000 }));
         }
     };
 
diff --git a/src/views-components/context-menu/action-sets/process-action-set.ts b/src/views-components/context-menu/action-sets/process-action-set.ts
index de1556f..284b9e8 100644
--- a/src/views-components/context-menu/action-sets/process-action-set.ts
+++ b/src/views-components/context-menu/action-sets/process-action-set.ts
@@ -18,9 +18,7 @@ export const processActionSet: ContextMenuActionSet = [[
     {
         icon: RenameIcon,
         name: "Edit process",
-        execute: (dispatch, resource) => {
-            dispatch<any>(openProcessUpdateDialog(resource));
-        }
+        execute: (dispatch, resource) => dispatch<any>(openProcessUpdateDialog(resource))
     },
     {
         icon: ShareIcon,
diff --git a/src/views-components/context-menu/action-sets/process-resource-action-set.ts b/src/views-components/context-menu/action-sets/process-resource-action-set.ts
index 14f1705..9deaff9 100644
--- a/src/views-components/context-menu/action-sets/process-resource-action-set.ts
+++ b/src/views-components/context-menu/action-sets/process-resource-action-set.ts
@@ -14,9 +14,7 @@ export const processResourceActionSet: ContextMenuActionSet = [[
     {
         icon: RenameIcon,
         name: "Edit process",
-        execute: (dispatch, resource) => {
-            dispatch<any>(openProcessUpdateDialog(resource));
-        }
+        execute: (dispatch, resource) => dispatch<any>(openProcessUpdateDialog(resource))
     },
     {
         icon: ShareIcon,

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list