init view log with props
[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 * as React from 'react';
6 import { RootState } from '~/store/store';
7 import { connect } from 'react-redux';
8 import { getProcess } from '~/store/processes/process';
9 import { Dispatch } from 'redux';
10 import { openProcessContextMenu } from '~/store/context-menu/context-menu-actions';
11 import { matchProcessLogRoute } from '~/routes/routes';
12 import { ProcessLogPanelRootDataProps, ProcessLogPanelRootActionProps, ProcessLogPanelRoot } from './process-log-panel-root';
13
14 const SELECT_OPTIONS = [
15     { label: 'Dispatch', value: 'dispatch' },
16     { label: 'Crunch-run', value: 'crunch-run' },
17     { label: 'Crunchstat', value: 'crunchstat' },
18     { label: 'Hoststat', value: 'hoststat' },
19     { label: 'Node-info', value: 'node-info' },
20     { label: 'Arv-mount', value: 'arv-mount' },
21     { label: 'Stdout', value: 'stdout' },
22     { label: 'Stderr', value: 'stderr' }
23 ];
24
25 export interface Log {
26     object_uuid: string;
27     event_at: string;
28     event_type: string;
29     summary: string;
30     properties: any;
31 }
32
33 export interface FilterOption {
34     label: string;
35     value: string;
36 }
37
38 const mapStateToProps = ({ router, resources }: RootState): ProcessLogPanelRootDataProps => {
39     const pathname = router.location ? router.location.pathname : '';
40     const match = matchProcessLogRoute(pathname);
41     const uuid = match ? match.params.id : '';
42     return {
43         process: getProcess(uuid)(resources),
44         selectedFilter: SELECT_OPTIONS[0],
45         filters: SELECT_OPTIONS
46         // lines: string[]
47     };
48 };
49
50 const mapDispatchToProps = (dispatch: Dispatch): ProcessLogPanelRootActionProps => ({
51     onContextMenu: (event: React.MouseEvent<HTMLElement>) => {
52         dispatch<any>(openProcessContextMenu(event));
53     },
54     onChange: (filter: FilterOption) => { return; }
55 });
56
57 export const ProcessLogPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessLogPanelRoot);