Implement command dialog, update code snippet styles
[arvados.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';
7 import { Dispatch } from 'redux';
8 import { getProcess } from '~/store/processes/process';
9
10 export const PROCESS_COMMAND_DIALOG_NAME = 'processCommandDialog';
11
12 export interface ProcessCommandDialogData {
13     command: string;
14     processName: string;
15 }
16
17 export const openProcessCommandDialog = (processUuid: string) =>
18     (dispatch: Dispatch<any>, getState: () => RootState) => {
19         const process = getProcess(processUuid)(getState().resources);
20         if (process) {
21             const data: ProcessCommandDialogData = {
22                 command: process.containerRequest.command.join(' '),
23                 processName: process.containerRequest.name,
24             };
25             dispatch(dialogActions.OPEN_DIALOG({ id: PROCESS_COMMAND_DIALOG_NAME, data }));
26         }
27     };