Merge branch 'master' of git.curoverse.com:arvados-workbench2 into 14602_admin_comput...
authorJanicki Artur <artur.janicki@contractors.roche.com>
Mon, 17 Dec 2018 06:44:11 +0000 (07:44 +0100)
committerJanicki Artur <artur.janicki@contractors.roche.com>
Mon, 17 Dec 2018 06:44:11 +0000 (07:44 +0100)
refs #2
14602

Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki@contractors.roche.com>

src/routes/route-change-handlers.ts
src/store/dialog/dialog-actions.ts
src/store/dialog/dialog-reducer.ts
src/store/processes/process-input-actions.ts
src/views/collection-panel/collection-panel.tsx

index c4b0fc7d5d5486f8be4fc30896a5296407c90ed2..655c806f3a3b0337cc1a89eccae6b7a29ddaa832 100644 (file)
@@ -7,6 +7,7 @@ import { RootStore } from '~/store/store';
 import * as Routes from '~/routes/routes';
 import * as WorkbenchActions from '~/store/workbench/workbench-actions';
 import { navigateToRootProject } from '~/store/navigation/navigation-action';
+import { dialogActions } from '~/store/dialog/dialog-actions';
 
 export const addRouteChangeHandlers = (history: History, store: RootStore) => {
     const handler = handleLocationChange(store);
@@ -38,6 +39,8 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
     const userMatch = Routes.matchUsersRoute(pathname);
     const linksMatch = Routes.matchLinksRoute(pathname);
 
+    store.dispatch(dialogActions.CLOSE_ALL_DIALOGS());
+
     if (projectMatch) {
         store.dispatch(WorkbenchActions.loadProject(projectMatch.params.id));
     } else if (collectionMatch) {
index 22629b692f2bff6dea8c7f78ee97ea18fe0308ca..ce01a50d6919285190974570e254e14841989061 100644 (file)
@@ -6,7 +6,8 @@ import { unionize, ofType, UnionOf } from "~/common/unionize";
 
 export const dialogActions = unionize({
     OPEN_DIALOG: ofType<{ id: string, data: any }>(),
-    CLOSE_DIALOG: ofType<{ id: string }>()
+    CLOSE_DIALOG: ofType<{ id: string }>(),
+    CLOSE_ALL_DIALOGS: ofType<{}>()
 });
 
 export type DialogAction = UnionOf<typeof dialogActions>;
index 48f8ee8a1e6caac149fb07b8c94a10a46a3f2377..30368685064dfe6f9837d7c20d0cc4808b0cbf01 100644 (file)
@@ -6,19 +6,22 @@ import { DialogAction, dialogActions } from "./dialog-actions";
 
 export type DialogState = Record<string, Dialog<any>>;
 
-export interface Dialog <T> {
+export interface Dialog<T> {
     open: boolean;
     data: T;
 }
 
 export const dialogReducer = (state: DialogState = {}, action: DialogAction) =>
+
     dialogActions.match(action, {
         OPEN_DIALOG: ({ id, data }) => ({ ...state, [id]: { open: true, data } }),
-        CLOSE_DIALOG: ({ id }) => ({ 
-            ...state, 
-            [id]: state[id] ? { ...state[id], open: false } : { open: false, data: {} } }),
+        CLOSE_DIALOG: ({ id }) => ({
+            ...state,
+            [id]: state[id] ? { ...state[id], open: false } : { open: false, data: {} }
+        }),
+        CLOSE_ALL_DIALOGS: () => ({ }),
         default: () => state,
     });
 
-export const getDialog = <T>(state: DialogState, id: string) => 
+export const getDialog = <T>(state: DialogState, id: string) =>
     state[id] ? state[id] as Dialog<T> : undefined;
index b67622d3908e394543ae54bd31575048aaa6ad24..b35081c19e656d63288a00a7d8ce937caeb68853 100644 (file)
@@ -5,7 +5,8 @@
 import { dialogActions } from '~/store/dialog/dialog-actions';
 import { RootState } from '~/store/store';
 import { Dispatch } from 'redux';
-import { getProcess, Process } from '~/store/processes/process';
+import { getProcess } from '~/store/processes/process';
+import { snackbarActions } from '~/store/snackbar/snackbar-actions';
 
 export const PROCESS_INPUT_DIALOG_NAME = 'processInputDialog';
 
@@ -13,7 +14,11 @@ export const openProcessInputDialog = (processUuid: string) =>
     (dispatch: Dispatch<any>, getState: () => RootState) => {
         const process = getProcess(processUuid)(getState().resources);
         if (process) {
-            const data: Process = process;
-            dispatch(dialogActions.OPEN_DIALOG({ id: PROCESS_INPUT_DIALOG_NAME, data }));
+            const data: any = process;
+            if (data && data.containerRequest.mounts.varLibCwlWorkflowJson && data.containerRequest.mounts.varLibCwlWorkflowJson.content.graph[1].inputs.length > 0) {
+                dispatch(dialogActions.OPEN_DIALOG({ id: PROCESS_INPUT_DIALOG_NAME, data }));
+            } else {
+                dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'There are no inputs in this process!' }));
+            }
         }
     }; 
\ No newline at end of file
index 119b9e994605061d61962f4e94801614815d4283..41a685f3283667a3fc5d39b60ccf18e6bc7a2c40 100644 (file)
@@ -113,7 +113,7 @@ export const CollectionPanel = withStyles(styles)(
                                             label='Content size' value={data && formatFileSize(data.fileSize)} />
                                         <DetailsAttribute classLabel={classes.label} classValue={classes.value}
                                             label='Owner' value={item && item.ownerUuid} />
-                                        <span onClick={() => dispatch<any>(navigateToProcess(item.properties.container_request))}>
+                                        <span onClick={() => dispatch<any>(navigateToProcess(item.properties.container_request  || item.properties.containerRequest))}>
                                             <DetailsAttribute classLabel={classes.link} label='Link to process' />
                                         </span>
                                     </Grid>