1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { unionize, ofType, UnionOf } from "~/common/unionize";
6 import { loadProcess } from '~/store/processes/processes-actions';
7 import { Dispatch } from 'redux';
8 import { ProcessStatus } from '~/store/processes/process';
9 import { RootState } from '~/store/store';
10 import { ServiceRepository } from "~/services/services";
11 import { navigateToCollection, navigateToWorkflows } from '~/store/navigation/navigation-action';
12 import { snackbarActions } from '~/store/snackbar/snackbar-actions';
13 import { SnackbarKind } from '../snackbar/snackbar-actions';
14 import { showWorkflowDetails } from '~/store/workflow-panel/workflow-panel-actions';
16 export const procesPanelActions = unionize({
17 SET_PROCESS_PANEL_FILTERS: ofType<string[]>(),
18 TOGGLE_PROCESS_PANEL_FILTER: ofType<string>(),
21 export type ProcessPanelAction = UnionOf<typeof procesPanelActions>;
23 export const toggleProcessPanelFilter = procesPanelActions.TOGGLE_PROCESS_PANEL_FILTER;
25 export const loadProcessPanel = (uuid: string) =>
26 (dispatch: Dispatch) => {
27 dispatch<any>(loadProcess(uuid));
28 dispatch(initProcessPanelFilters);
31 export const navigateToOutput = (uuid: string) =>
32 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
34 await services.collectionService.get(uuid);
35 dispatch<any>(navigateToCollection(uuid));
37 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'This collection does not exists!', hideDuration: 2000, kind: SnackbarKind.ERROR }));
41 export const openWorkflow = (uuid: string) =>
42 (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
43 dispatch<any>(navigateToWorkflows);
44 dispatch<any>(showWorkflowDetails(uuid));
47 export const initProcessPanelFilters = procesPanelActions.SET_PROCESS_PANEL_FILTERS([
49 ProcessStatus.COMPLETED,
51 ProcessStatus.RUNNING,
53 ProcessStatus.CANCELLED