show and hide button depends on url
[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 * 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 { ProcessLogPanelRootDataProps, ProcessLogPanelRootActionProps, ProcessLogPanelRoot } from './process-log-panel-root';
12 import { getProcessPanelLogs } from '~/store/process-logs-panel/process-logs-panel';
13 import { setProcessLogsPanelFilter } from '~/store/process-logs-panel/process-logs-panel-actions';
14 import { getProcessLogsPanelCurrentUuid } from '../../store/process-logs-panel/process-logs-panel';
15
16 export interface Log {
17     object_uuid: string;
18     event_at: string;
19     event_type: string;
20     summary: string;
21     properties: any;
22 }
23
24 export interface FilterOption {
25     label: string;
26     value: string;
27 }
28
29 const mapStateToProps = (state: RootState): ProcessLogPanelRootDataProps => {
30     const { resources, processLogsPanel } = state;
31     const uuid = getProcessLogsPanelCurrentUuid(state) || '';
32     return {
33         process: getProcess(uuid)(resources),
34         selectedFilter: { label: processLogsPanel.selectedFilter, value: processLogsPanel.selectedFilter },
35         filters: processLogsPanel.filters.map(filter => ({ label: filter, value: filter })),
36         lines: getProcessPanelLogs(processLogsPanel)
37     };
38 };
39
40 const mapDispatchToProps = (dispatch: Dispatch): ProcessLogPanelRootActionProps => ({
41     onContextMenu: (event: React.MouseEvent<HTMLElement>) => {
42         dispatch<any>(openProcessContextMenu(event));
43     },
44     onChange: (filter: FilterOption) => {
45         dispatch(setProcessLogsPanelFilter(filter.value));
46     }
47 });
48
49 export const ProcessLogPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessLogPanelRoot);