X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5c8a5dd07252ed2ac431c53fccc9e2fb649c3014..671aae429289611510af1facbc59c96c318293a2:/src/views/process-panel/process-log-card.tsx diff --git a/src/views/process-panel/process-log-card.tsx b/src/views/process-panel/process-log-card.tsx index b87bb6e475..4890c726f4 100644 --- a/src/views/process-panel/process-log-card.tsx +++ b/src/views/process-panel/process-log-card.tsx @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -import React from 'react'; +import React, { useState } from 'react'; import { StyleRulesCallback, WithStyles, @@ -19,8 +19,14 @@ import { ArvadosTheme } from 'common/custom-theme'; import { CloseIcon, CollectionIcon, + CopyIcon, LogIcon, - MaximizeIcon + MaximizeIcon, + UnMaximizeIcon, + TextDecreaseIcon, + TextIncreaseIcon, + WordWrapOffIcon, + WordWrapOnIcon, } from 'components/icon/icon'; import { Process } from 'store/processes/process'; import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view'; @@ -31,17 +37,28 @@ import { import { ProcessLogCodeSnippet } from 'views/process-panel/process-log-code-snippet'; import { DefaultView } from 'components/default-view/default-view'; import { CodeSnippetDataProps } from 'components/code-snippet/code-snippet'; +import CopyToClipboard from 'react-copy-to-clipboard'; -type CssRules = 'card' | 'content' | 'title' | 'iconHeader'; +type CssRules = 'card' | 'content' | 'title' | 'iconHeader' | 'header' | 'root' | 'logViewer' | 'logViewerContainer'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ card: { height: '100%' }, + header: { + paddingTop: theme.spacing.unit, + paddingBottom: theme.spacing.unit, + }, content: { - '&:last-child': { - paddingBottom: theme.spacing.unit * 2, - } + padding: theme.spacing.unit * 0, + height: '100%', + }, + logViewer: { + height: '100%', + overflowY: 'scroll', // Required for MacOS's Safari -- See #19687 + }, + logViewerContainer: { + height: '100%', }, title: { overflow: 'hidden', @@ -51,6 +68,9 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ fontSize: '1.875rem', color: theme.customs.colors.green700 }, + root: { + height: '100%', + }, }); export interface ProcessLogsCardDataProps { @@ -62,6 +82,7 @@ export interface ProcessLogsCardDataProps { export interface ProcessLogsCardActionProps { onLogFilterChange: (filter: FilterOption) => void; navigateToLog: (uuid: string) => void; + onCopy: (text: string) => void; } type ProcessLogsCardProps = ProcessLogsCardDataProps @@ -71,17 +92,53 @@ type ProcessLogsCardProps = ProcessLogsCardDataProps & MPVPanelProps; export const ProcessLogsCard = withStyles(styles)( - ({ classes, process, filters, selectedFilter, lines, onLogFilterChange, navigateToLog, - doHidePanel, doMaximizePanel, panelMaximized, panelName }: ProcessLogsCardProps) => - + ({ classes, process, filters, selectedFilter, lines, + onLogFilterChange, navigateToLog, onCopy, + doHidePanel, doMaximizePanel, doUnMaximizePanel, panelMaximized, panelName }: ProcessLogsCardProps) => { + const [wordWrap, setWordWrap] = useState(true); + const [fontSize, setFontSize] = useState(3); + const fontBaseSize = 10; + const fontStepSize = 1; + + return - } action={ + + + fontSize > 1 && setFontSize(fontSize-1)}> + + + + + + + fontSize < 5 && setFontSize(fontSize+1)}> + + + + + + + + onCopy("Log copied to clipboard")}> + + + + + + + + setWordWrap(!wordWrap)}> + {wordWrap ? : } + + + navigateToLog(process.containerRequest.logUuid!)}> @@ -89,15 +146,18 @@ export const ProcessLogsCard = withStyles(styles)( + { doUnMaximizePanel && panelMaximized && + + + } { doMaximizePanel && !panelMaximized && } - { doHidePanel && - - - - } + { doHidePanel && + + + } } title={ @@ -107,11 +167,12 @@ export const ProcessLogsCard = withStyles(styles)( {lines.length > 0 ? < Grid + className={classes.logViewerContainer} container spacing={24} direction='column'> - - + + : -); +});