Skip to content

Commit

Permalink
feat: Update log viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
PintoGideon committed Jan 16, 2025
1 parent 6306b24 commit 42f9c44
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions src/components/NodeDetails/LogTerminal.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
import { LogViewer } from "@patternfly/react-log-viewer";
import { useAppSelector } from "../../store/hooks";
import { LogViewer, LogViewerSearch } from "@patternfly/react-log-viewer";
import { Toolbar, ToolbarContent, ToolbarItem } from "@patternfly/react-core";

type LogTerminalProps = {
text: string;
};

const LogTerminal = ({ text }: LogTerminalProps) => {
const isTerminalMaximized = useAppSelector(
(state) => state.drawers.node.maximized,
);

const containerStyle = {
height: isTerminalMaximized ? "100vh" : "100%",
// container style
const containerStyle: React.CSSProperties = {
// If "maximized", fill entire viewport
height: "100vh",
width: "100%",
display: "flex",
flexDirection: "column" as const,
flexGrow: 1,
};

const logViewerStyle = {
flexDirection: "column",
flexGrow: 1,
overflow: "auto",
height: "100%",
width: "100%",
};

return (
<div style={containerStyle}>
<LogViewer style={logViewerStyle} hasLineNumbers={false} data={text} />
<LogViewer
/* Provide the log text (could be text or data.data, etc.) */
data={text}
/* Let user toggle wrap text via the checkbox */

/* Hide line numbers if desired */
hasLineNumbers={true}
/* Optionally set a fixed or relative height */

/* Provide a custom toolbar with PatternFly controls */
toolbar={
<Toolbar>
<ToolbarContent>
{/* 2) Built-in LogViewerSearch for searching logs */}
<ToolbarItem>
<LogViewerSearch placeholder="Search" />
</ToolbarItem>
</ToolbarContent>
</Toolbar>
}
/>
</div>
);
};
Expand Down

0 comments on commit 42f9c44

Please sign in to comment.