Create simplified object type filters for use where collection types are not supported
[arvados.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 } 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 = (state: RootState): ProcessLogPanelRootDataProps => {
29     const { resources, processLogsPanel } = state;
30     const uuid = getProcessLogsPanelCurrentUuid(state) || '';
31     return {
32         process: getProcess(uuid)(resources),
33         selectedFilter: { label: processLogsPanel.selectedFilter, value: processLogsPanel.selectedFilter },
34         filters: processLogsPanel.filters.map(filter => ({ label: filter, value: filter })),
35         lines: getProcessPanelLogs(processLogsPanel)
36     };
37 };
38
39 const mapDispatchToProps = (dispatch: Dispatch): ProcessLogPanelRootActionProps => ({
40     onContextMenu: (event, process) => {
41         dispatch<any>(openProcessContextMenu(event, process));
42     },
43     onChange: filter => {
44         dispatch(setProcessLogsPanelFilter(filter.value));
45     }
46 });
47
48 export const ProcessLogPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessLogPanelRoot);