15672: Adds minimal subprocess data explorer (WIP)
[arvados.git] / src / store / process-panel / process-panel-actions.ts
index 902a5c9c4e7ab7cf99fe258e7237ad0691126ec7..8bdbe4f297dfb363555c2850fd895c42ea3322c9 100644 (file)
@@ -5,25 +5,54 @@
 import { unionize, ofType, UnionOf } from "~/common/unionize";
 import { loadProcess } from '~/store/processes/processes-actions';
 import { Dispatch } from 'redux';
+import { ProcessStatus } from '~/store/processes/process';
+import { RootState } from '~/store/store';
+import { ServiceRepository } from "~/services/services";
+import { navigateTo, navigateToWorkflows } from '~/store/navigation/navigation-action';
+import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+import { SnackbarKind } from '../snackbar/snackbar-actions';
+import { showWorkflowDetails } from '~/store/workflow-panel/workflow-panel-actions';
+import { loadSubprocessPanel } from "../subprocess-panel/subprocess-panel-actions";
 
-export const procesPanelActions = unionize({
-    INIT_PROCESS_PANEL_FILTERS: ofType<string[]>(),
+export const processPanelActions = unionize({
+    SET_PROCESS_PANEL_CONTAINER_REQUEST_UUID: ofType<string>(),
+    SET_PROCESS_PANEL_FILTERS: ofType<string[]>(),
     TOGGLE_PROCESS_PANEL_FILTER: ofType<string>(),
 });
 
-export type ProcessPanelAction = UnionOf<typeof procesPanelActions>;
+export type ProcessPanelAction = UnionOf<typeof processPanelActions>;
 
-export const toggleProcessPanelFilter = procesPanelActions.TOGGLE_PROCESS_PANEL_FILTER;
+export const toggleProcessPanelFilter = processPanelActions.TOGGLE_PROCESS_PANEL_FILTER;
 
 export const loadProcessPanel = (uuid: string) =>
     (dispatch: Dispatch) => {
+        dispatch<ProcessPanelAction>(processPanelActions.SET_PROCESS_PANEL_CONTAINER_REQUEST_UUID(uuid));
         dispatch<any>(loadProcess(uuid));
         dispatch(initProcessPanelFilters);
+        dispatch<any>(loadSubprocessPanel());
     };
 
-export const initProcessPanelFilters = procesPanelActions.INIT_PROCESS_PANEL_FILTERS([
-    'Queued',
-    'Complete',
-    'Active',
-    'Failed'
+export const navigateToOutput = (uuid: string) =>
+    async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        try {
+            await services.collectionService.get(uuid);
+            dispatch<any>(navigateTo(uuid));
+        } catch {
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'This collection does not exists!', hideDuration: 2000, kind: SnackbarKind.ERROR }));
+        }
+    };
+
+export const openWorkflow = (uuid: string) =>
+    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        dispatch<any>(navigateToWorkflows);
+        dispatch<any>(showWorkflowDetails(uuid));
+    };
+
+export const initProcessPanelFilters = processPanelActions.SET_PROCESS_PANEL_FILTERS([
+    ProcessStatus.QUEUED,
+    ProcessStatus.COMPLETED,
+    ProcessStatus.FAILED,
+    ProcessStatus.RUNNING,
+    ProcessStatus.LOCKED,
+    ProcessStatus.CANCELLED
 ]);