1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
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 import { getProcessPanelLogs } from '~/store/process-logs-panel/process-logs-panel';
14 import { setProcessLogsPanelFilter } from '~/store/process-logs-panel/process-logs-panel-actions';
16 export interface Log {
24 export interface FilterOption {
29 const mapStateToProps = ({ router, resources, processLogsPanel }: RootState): ProcessLogPanelRootDataProps => {
30 const pathname = router.location ? router.location.pathname : '';
31 const match = matchProcessLogRoute(pathname);
32 const uuid = match ? match.params.id : '';
34 process: getProcess(uuid)(resources),
35 selectedFilter: { label: processLogsPanel.selectedFilter, value: processLogsPanel.selectedFilter },
36 filters: processLogsPanel.filters.map(filter => ({ label: filter, value: filter })),
37 lines: getProcessPanelLogs(processLogsPanel)
41 const mapDispatchToProps = (dispatch: Dispatch): ProcessLogPanelRootActionProps => ({
42 onContextMenu: (event: React.MouseEvent<HTMLElement>) => {
43 dispatch<any>(openProcessContextMenu(event));
45 onChange: (filter: FilterOption) => {
46 dispatch(setProcessLogsPanelFilter(filter.value));
50 export const ProcessLogPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessLogPanelRoot);