Skip to content

Commit

Permalink
frontend: LogViwer: Fix log not expanding on full screen
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent T <[email protected]>
  • Loading branch information
vyncent-t committed Dec 9, 2024
1 parent 9928715 commit 60d9f1b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions frontend/src/components/common/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export function DialogTitle(props: OurDialogTitleProps) {
export interface OurDialogProps {
withFullScreen?: boolean;
onFullScreenToggled?: (isFullScreen: boolean) => void;
logView?: any;
titleProps?: OurDialogTitleProps;
}

Expand Down Expand Up @@ -106,6 +107,9 @@ export function Dialog(props: DialogProps) {

return newFullScreenState;
});

// If we are using the log viewer component this handles the full screen sizing for xterm
props.logView?.setter(!props.logView.hasAdjustment);
}

function FullScreenButton() {
Expand Down
20 changes: 17 additions & 3 deletions frontend/src/components/common/LogViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FitAddon } from '@xterm/addon-fit';
import { ISearchOptions, SearchAddon } from '@xterm/addon-search';
import { Terminal as XTerminal } from '@xterm/xterm';
import _ from 'lodash';
import React, { ReactNode, useEffect } from 'react';
import React, { ReactNode, useEffect, useState } from 'react';
import { useHotkeys } from 'react-hotkeys-hook';
import { useTranslation } from 'react-i18next';
import ActionButton from './ActionButton';
Expand Down Expand Up @@ -64,6 +64,20 @@ export function LogViewer(props: LogViewerProps) {
element.click();
}

/**
* This is used to pass the logView state to the Dialog component to handle full screen
*/
const [logView, setLogView] = useState({
hasAdjustment: false,
setter: (value: boolean) => {
logViewSetter(value);
},
});

function logViewSetter(value: boolean) {
setLogView({ ...logView, hasAdjustment: value });
}

React.useEffect(() => {
if (!terminalContainerRef || !!xtermRef.current) {
return;
Expand Down Expand Up @@ -106,7 +120,7 @@ export function LogViewer(props: LogViewerProps) {
searchAddonRef.current?.dispose();
xtermRef.current = null;
};
}, [terminalContainerRef, xtermRef.current]);
}, [terminalContainerRef, xtermRef.current, logView.hasAdjustment]);

React.useEffect(() => {
if (!xtermRef.current) {
Expand All @@ -129,7 +143,7 @@ export function LogViewer(props: LogViewerProps) {
}

return (
<Dialog title={title} withFullScreen onClose={onClose} {...other}>
<Dialog title={title} withFullScreen logView={logView} onClose={onClose} {...other}>
<DialogContent
sx={theme => ({
height: '80%',
Expand Down

0 comments on commit 60d9f1b

Please sign in to comment.