Merge branch '14461-remove-process-permanently'
[arvados-workbench2.git] / src / store / processes / process-command-actions.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { dialogActions } from '~/store/dialog/dialog-actions';
6 import { RootState } from '~/store/store';
7 import { Dispatch } from 'redux';
8 import { getProcess } from '~/store/processes/process';
9 import { quote } from 'shell-quote';
10
11 export const PROCESS_COMMAND_DIALOG_NAME = 'processCommandDialog';
12
13 export interface ProcessCommandDialogData {
14     command: string;
15     processName: string;
16 }
17
18 export const openProcessCommandDialog = (processUuid: string) =>
19     (dispatch: Dispatch<any>, getState: () => RootState) => {
20         const process = getProcess(processUuid)(getState().resources);
21         if (process) {
22             const data: ProcessCommandDialogData = {
23                 command: quote(process.containerRequest.command),
24                 processName: process.containerRequest.name,
25             };
26             dispatch(dialogActions.OPEN_DIALOG({ id: PROCESS_COMMAND_DIALOG_NAME, data }));
27         }
28     };