From 909844cdb1eda3d4cd31f3fa1818ee7eca62d319 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Tue, 15 Mar 2022 16:25:05 -0300 Subject: [PATCH] 16672: Initial Log viewer placement on process panel. WIP Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- .../process-panel/process-panel-actions.ts | 2 + .../process-log-main-card.tsx | 40 ++++++++++--------- .../process-panel/process-panel-root.tsx | 29 +++++++++++++- src/views/process-panel/process-panel.tsx | 8 +++- 4 files changed, 57 insertions(+), 22 deletions(-) diff --git a/src/store/process-panel/process-panel-actions.ts b/src/store/process-panel/process-panel-actions.ts index de114a3e..2e5fb6b9 100644 --- a/src/store/process-panel/process-panel-actions.ts +++ b/src/store/process-panel/process-panel-actions.ts @@ -13,6 +13,7 @@ import { snackbarActions } from 'store/snackbar/snackbar-actions'; import { SnackbarKind } from '../snackbar/snackbar-actions'; import { showWorkflowDetails } from 'store/workflow-panel/workflow-panel-actions'; import { loadSubprocessPanel } from "../subprocess-panel/subprocess-panel-actions"; +import { initProcessLogsPanel } from "store/process-logs-panel/process-logs-panel-actions"; export const processPanelActions = unionize({ SET_PROCESS_PANEL_CONTAINER_REQUEST_UUID: ofType(), @@ -29,6 +30,7 @@ export const loadProcessPanel = (uuid: string) => dispatch(processPanelActions.SET_PROCESS_PANEL_CONTAINER_REQUEST_UUID(uuid)); dispatch(loadProcess(uuid)); dispatch(initProcessPanelFilters); + dispatch(initProcessLogsPanel(uuid)); dispatch(loadSubprocessPanel()); }; diff --git a/src/views/process-log-panel/process-log-main-card.tsx b/src/views/process-log-panel/process-log-main-card.tsx index e6d4091d..aab44da4 100644 --- a/src/views/process-log-panel/process-log-main-card.tsx +++ b/src/views/process-log-panel/process-log-main-card.tsx @@ -3,18 +3,28 @@ // SPDX-License-Identifier: AGPL-3.0 import React from 'react'; -import { Link } from 'react-router-dom'; import { - StyleRulesCallback, WithStyles, withStyles, Card, - CardHeader, IconButton, CardContent, Grid, Typography, Tooltip + StyleRulesCallback, + WithStyles, + withStyles, + Card, + CardHeader, + IconButton, + CardContent, + Grid, + Typography, + Tooltip } from '@material-ui/core'; import { Process } from 'store/processes/process'; import { ProcessLogCodeSnippet } from 'views/process-log-panel/process-log-code-snippet'; -import { ProcessLogForm, ProcessLogFormDataProps, ProcessLogFormActionProps } from 'views/process-log-panel/process-log-form'; -import { MoreOptionsIcon, ProcessIcon } from 'components/icon/icon'; +import { + ProcessLogForm, + ProcessLogFormDataProps, + ProcessLogFormActionProps +} from 'views/process-log-panel/process-log-form'; +import { MoreOptionsIcon, LogIcon } from 'components/icon/icon'; import { ArvadosTheme } from 'common/custom-theme'; import { CodeSnippetDataProps } from 'components/code-snippet/code-snippet'; -import { BackIcon } from 'components/icon/icon'; import { DefaultView } from 'components/default-view/default-view'; type CssRules = 'backLink' | 'backIcon' | 'card' | 'title' | 'iconHeader' | 'link'; @@ -52,7 +62,6 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ } }); - interface ProcessLogMainCardDataProps { process: Process; } @@ -71,12 +80,9 @@ export type ProcessLogMainCardProps = ProcessLogMainCardDataProps export const ProcessLogMainCard = withStyles(styles)( ({ classes, process, selectedFilter, filters, onChange, lines, onContextMenu, navigateToLogCollection }: ProcessLogMainCardProps & WithStyles) => - - BACK - } + avatar={} action={ onContextMenu(event, process)} aria-label="More options"> @@ -84,12 +90,10 @@ export const ProcessLogMainCard = withStyles(styles)( } title={ - - - {process.containerRequest.name} - - } - subheader={process.containerRequest.description} /> + + Logs for {process.containerRequest.name} + } + /> {lines.length > 0 ? < Grid @@ -111,7 +115,7 @@ export const ProcessLogMainCard = withStyles(styles)( : } diff --git a/src/views/process-panel/process-panel-root.tsx b/src/views/process-panel/process-panel-root.tsx index 6fb9c09d..5a0b6b64 100644 --- a/src/views/process-panel/process-panel-root.tsx +++ b/src/views/process-panel/process-panel-root.tsx @@ -13,6 +13,9 @@ import { SubprocessFilterDataProps } from 'components/subprocess-filter/subproce import { MPVContainer, MPVPanelContent, MPVPanelState } from 'components/multi-panel-view/multi-panel-view'; import { ArvadosTheme } from 'common/custom-theme'; import { ProcessDetailsCard } from './process-details-card'; +import { FilterOption } from 'views/process-log-panel/process-log-panel'; +import { ProcessLogMainCard } from 'views/process-log-panel/process-log-main-card'; +import { getProcessPanelLogs, ProcessLogsPanel } from 'store/process-logs-panel/process-logs-panel'; type CssRules = 'root'; @@ -26,6 +29,7 @@ export interface ProcessPanelRootDataProps { process?: Process; subprocesses: Array; filters: Array; + processLogsPanel: ProcessLogsPanel; } export interface ProcessPanelRootActionProps { @@ -35,6 +39,8 @@ export interface ProcessPanelRootActionProps { navigateToOutput: (uuid: string) => void; navigateToWorkflow: (uuid: string) => void; cancelProcess: (uuid: string) => void; + onLogFilterChange: (filter: FilterOption) => void; + navigateToLog: (uuid: string) => void; } export type ProcessPanelRootProps = ProcessPanelRootDataProps & ProcessPanelRootActionProps & WithStyles; @@ -42,10 +48,12 @@ export type ProcessPanelRootProps = ProcessPanelRootDataProps & ProcessPanelRoot const panelsData: MPVPanelState[] = [ {name: "Info"}, {name: "Details", visible: false}, + {name: "Logs", visible: true}, {name: "Subprocesses"}, ]; -export const ProcessPanelRoot = withStyles(styles)(({ process, ...props }: ProcessPanelRootProps) => +export const ProcessPanelRoot = withStyles(styles)( + ({ process, processLogsPanel, ...props }: ProcessPanelRootProps) => process ? @@ -61,6 +69,24 @@ export const ProcessPanelRoot = withStyles(styles)(({ process, ...props }: Proce + + ({ label: filter, value: filter }) + )} + onChange={props.onLogFilterChange} + onContextMenu={function (event: any, process: Process): void { + throw new Error('Function not implemented.'); + } } + navigateToLogCollection={props.navigateToLog} + /> + @@ -73,4 +99,3 @@ export const ProcessPanelRoot = withStyles(styles)(({ process, ...props }: Proce icon={ProcessIcon} messages={['Process not found']} /> ); - diff --git a/src/views/process-panel/process-panel.tsx b/src/views/process-panel/process-panel.tsx index 27acc869..6dd02c9b 100644 --- a/src/views/process-panel/process-panel.tsx +++ b/src/views/process-panel/process-panel.tsx @@ -24,14 +24,16 @@ import { } from 'store/process-panel/process-panel-actions'; import { openProcessInputDialog } from 'store/processes/process-input-actions'; import { cancelRunningWorkflow } from 'store/processes/processes-actions'; +import { navigateToLogCollection, setProcessLogsPanelFilter } from 'store/process-logs-panel/process-logs-panel-actions'; -const mapStateToProps = ({ router, resources, processPanel }: RootState): ProcessPanelRootDataProps => { +const mapStateToProps = ({ router, resources, processPanel, processLogsPanel }: RootState): ProcessPanelRootDataProps => { const uuid = getProcessPanelCurrentUuid(router) || ''; const subprocesses = getSubprocesses(uuid)(resources); return { process: getProcess(uuid)(resources), subprocesses: subprocesses.filter(subprocess => processPanel.filters[getProcessStatus(subprocess)]), filters: getFilters(processPanel, subprocesses), + processLogsPanel: processLogsPanel, }; }; @@ -45,7 +47,9 @@ const mapDispatchToProps = (dispatch: Dispatch): ProcessPanelRootActionProps => openProcessInputDialog: (uuid) => dispatch(openProcessInputDialog(uuid)), navigateToOutput: (uuid) => dispatch(navigateToOutput(uuid)), navigateToWorkflow: (uuid) => dispatch(openWorkflow(uuid)), - cancelProcess: (uuid) => dispatch(cancelRunningWorkflow(uuid)) + cancelProcess: (uuid) => dispatch(cancelRunningWorkflow(uuid)), + onLogFilterChange: (filter) => dispatch(setProcessLogsPanelFilter(filter.value)), + navigateToLog: (uuid) => dispatch(navigateToLogCollection(uuid)), }); const getFilters = (processPanel: ProcessPanelState, processes: Process[]) => { -- 2.30.2