16672: Process log card fully implemented in process panel.
[arvados-workbench2.git] / src / views / process-log-panel / process-log-panel.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { RootState } from 'store/store';
6 import { connect } from 'react-redux';
7 import { getProcess } from 'store/processes/process';
8 import { Dispatch } from 'redux';
9 import { openProcessContextMenu } from 'store/context-menu/context-menu-actions';
10 import { ProcessLogPanelRootDataProps, ProcessLogPanelRootActionProps, ProcessLogPanelRoot } from './process-log-panel-root';
11 import { getProcessPanelLogs } from 'store/process-logs-panel/process-logs-panel';
12 import { setProcessLogsPanelFilter, navigateToLogCollection } from 'store/process-logs-panel/process-logs-panel-actions';
13 import { getProcessLogsPanelCurrentUuid } from 'store/process-logs-panel/process-logs-panel';
14
15 export interface Log {
16     object_uuid: string;
17     event_at: string;
18     event_type: string;
19     summary: string;
20     properties: any;
21 }
22
23 export interface FilterOption {
24     label: string;
25     value: string;
26 }
27
28 const mapStateToProps = ({resources, processLogsPanel, router}: RootState): ProcessLogPanelRootDataProps => {
29     const uuid = getProcessLogsPanelCurrentUuid(router) || '';
30     return {
31         process: getProcess(uuid)(resources),
32         selectedFilter: { label: processLogsPanel.selectedFilter, value: processLogsPanel.selectedFilter },
33         filters: processLogsPanel.filters.map(filter => ({ label: filter, value: filter })),
34         lines: getProcessPanelLogs(processLogsPanel)
35     };
36 };
37
38 const mapDispatchToProps = (dispatch: Dispatch): ProcessLogPanelRootActionProps => ({
39     onContextMenu: (event, process) => {
40         dispatch<any>(openProcessContextMenu(event, process));
41     },
42     onChange: filter => {
43         dispatch(setProcessLogsPanelFilter(filter.value));
44     },
45     navigateToLogCollection: (uuid: string) => {
46         dispatch<any>(navigateToLogCollection(uuid));
47     }
48 });
49
50 export const ProcessLogPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessLogPanelRoot);