Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NCL-8835 Change log viewer button layout #579

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/components/BuildLogLink/BuildLogLink.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
import { Button } from '@patternfly/react-core';
import { ExternalLinkAltIcon } from '@patternfly/react-icons';

import { TooltipWrapper } from 'components/TooltipWrapper/TooltipWrapper';

import * as webConfigService from 'services/webConfigService';

interface IBuildLogLinkProps {
buildId: string;
isIconVariant?: boolean;
title?: string;
}

export const BuildLogLink = ({ buildId, title = 'view' }: IBuildLogLinkProps) => (
<a target="_blank" rel="noopener noreferrer" href={`${webConfigService.getPncUrl()}/builds/${buildId}/logs/build`}>
{title}
</a>
);
export const BuildLogLink = ({ buildId, isIconVariant = false, title = 'View raw' }: IBuildLogLinkProps) => {
const buildLogUrl = `${webConfigService.getPncUrl()}/builds/${buildId}/logs/build`;

return isIconVariant ? (
<TooltipWrapper tooltip={title}>
<Button variant="plain" target="_blank" rel="noopener noreferrer" component="a" href={buildLogUrl} style={{ padding: 0 }}>
<ExternalLinkAltIcon /> {title}
</Button>
</TooltipWrapper>
) : (
<a target="_blank" rel="noopener noreferrer" href={buildLogUrl}>
{title}
</a>
);
};
2 changes: 1 addition & 1 deletion src/components/BuildLogPage/BuildLogPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const BuildLogPage = () => {
{ buildId, preventListening: !isBuilding }
);

const logActions = [<BuildLogLink key="log-link" buildId={buildId!} />];
const logActions = [<BuildLogLink key="log-link" isIconVariant buildId={buildId!} />];

return (
<>
Expand Down
107 changes: 62 additions & 45 deletions src/components/LogViewer/LogViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Switch, Toolbar, ToolbarContent, ToolbarItem } from '@patternfly/react-core';
import { Button, Checkbox, Toolbar, ToolbarContent, ToolbarGroup, ToolbarItem } from '@patternfly/react-core';
import { LongArrowAltDownIcon, LongArrowAltUpIcon, OutlinedPlayCircleIcon } from '@patternfly/react-icons';
import { LogViewer as LogViewerPF } from '@patternfly/react-log-viewer';
import { ReactNode, useEffect, useRef, useState } from 'react';
Expand Down Expand Up @@ -80,55 +80,72 @@ export const LogViewer = ({ isStatic = false, data, customActions }: ILogViewerP

const HeaderToolbar = () => (
<Toolbar>
<ToolbarContent>
<ToolbarItem>
<Button
onClick={() => {
if (logViewerRef.current?.state.scrollOffset) {
setIsPaused(true);
logViewerRef.current.scrollTo(0, 0);
}
}}
variant="control"
icon={<LongArrowAltUpIcon />}
>
Top
</Button>
</ToolbarItem>
<ToolbarItem>
<Button
onClick={() => {
setIsPaused(false);
logViewerRef.current?.scrollToBottom();
}}
variant="control"
icon={<LongArrowAltDownIcon />}
>
Bottom
</Button>
</ToolbarItem>
{!!customActions?.length && customActions.map((node, index) => <ToolbarItem key={index}>{node}</ToolbarItem>)}
{!isStatic && (
<ToolbarContent alignItems="center">
<ToolbarGroup>
<ToolbarItem>
<Switch
label="Force Following"
isChecked={isFollowing}
onChange={(_, checked) => {
<Button
onClick={() => {
if (logViewerRef.current?.state.scrollOffset) {
setIsPaused(true);
logViewerRef.current.scrollTo(0, 0);
}
}}
variant="control"
icon={<LongArrowAltUpIcon />}
>
Top
</Button>
</ToolbarItem>
<ToolbarItem>
<Button
onClick={() => {
setIsPaused(false);
storeIsFollowing(checked);
logViewerRef.current?.scrollToBottom();
}}
variant="control"
icon={<LongArrowAltDownIcon />}
>
Bottom
</Button>
</ToolbarItem>
</ToolbarGroup>
<ToolbarGroup align={{ default: 'alignRight' }}>
{!isStatic && (
<>
<ToolbarItem alignSelf="center">
<Checkbox
id="force-following-check"
label="Force following"
isChecked={isFollowing}
onChange={(_, checked) => {
setIsPaused(false);
storeIsFollowing(checked);
}}
/>
</ToolbarItem>
<ToolbarItem variant="separator" />
</>
)}
<ToolbarItem alignSelf="center">
<Checkbox
id="wrap-lines-check"
label="Wrap lines"
isChecked={areLinesWrapped}
onChange={(_, checked) => {
storeAreLinesWrapped(checked);
}}
/>
</ToolbarItem>
)}
<ToolbarItem>
<Switch
label="Wrap Lines"
isChecked={areLinesWrapped}
onChange={(_, checked) => {
storeAreLinesWrapped(checked);
}}
/>
</ToolbarItem>
{!!customActions?.length &&
customActions.map((node, index) => (
<>
<ToolbarItem variant="separator" />
<ToolbarItem key={index} alignSelf="center">
{node}
</ToolbarItem>
</>
))}
</ToolbarGroup>
</ToolbarContent>
</Toolbar>
);
Expand Down