Files
portainer/app/react/components/LogViewer/ToggleButton.tsx
T
agent_coder 7f02d20e54 feat(logs): React log viewer for container logs
Replace the legacy AngularJS <log-viewer> on the container logs page with a
modern React log viewer, reusing the existing streaming (#6) and formatting/
coloring pipeline. Features: line-number gutter, zerolog level + key=value
coloring (from the existing formatter spans), from/to datetime range, Lines
limit, Line numbers / Timestamp / Wrap lines toggles, Auto refresh (live tail
on/off), Search + 'Filter search results', Copy, Download logs, and fullscreen.

The viewer is source-agnostic (StreamLogsFn), so service/task logs can adopt it
later; this PR wires container logs only. containerLogsController.js no longer
opens its own live stream (React owns fetching now), preventing a double stream.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 19:05:56 +03:00

44 lines
993 B
TypeScript

import { ComponentType, ReactNode } from 'react';
import { AutomationTestingProps } from '@/types';
import { Button } from '@@/buttons';
interface Props extends AutomationTestingProps {
active: boolean;
onChange: (active: boolean) => void;
label: ReactNode;
icon?: ReactNode | ComponentType<unknown>;
title?: string;
}
/**
* An independent on/off toggle rendered as a real <button> with `aria-pressed`.
* The viewer's Line numbers / Timestamp / Wrap lines / Auto refresh controls are
* independent toggles (not a single-select segmented control), so each is its
* own ToggleButton.
*/
export function ToggleButton({
active,
onChange,
label,
icon,
title,
'data-cy': dataCy,
}: Props) {
return (
<Button
type="button"
size="small"
color={active ? 'primary' : 'default'}
icon={icon}
title={title}
aria-pressed={active}
onClick={() => onChange(!active)}
data-cy={dataCy}
>
{label}
</Button>
);
}