feat: refine widget interactions
This commit is contained in:
1 parent
a8a7545f40
commit
842e86012d
107 files changed
+3144
-1233
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { getAdvancedColumnWidth } from "./component";
|
||||
import { getAdvancedColumnWidth, getCompactSectionVisibility } from "./component";
|
||||
|
||||
describe("Tracearr advanced layout", () => {
|
||||
it("subtracts grid padding and the inter-column gap", () => {
|
||||
@@ -12,3 +12,29 @@ describe("Tracearr advanced layout", () => {
|
||||
expect(getAdvancedColumnWidth(799, false)).toBe(767);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Tracearr compact disclosure", () => {
|
||||
it("keeps urgent violations visible in a short widget", () => {
|
||||
expect(
|
||||
getCompactSectionVisibility({
|
||||
height: 160,
|
||||
showStreams: true,
|
||||
showViolations: true,
|
||||
hasViolations: true,
|
||||
showRecentActivity: true,
|
||||
}),
|
||||
).toEqual({ violations: true, recentActivity: false });
|
||||
});
|
||||
|
||||
it("reveals secondary history as height becomes available", () => {
|
||||
expect(
|
||||
getCompactSectionVisibility({
|
||||
height: 400,
|
||||
showStreams: true,
|
||||
showViolations: true,
|
||||
hasViolations: false,
|
||||
showRecentActivity: true,
|
||||
}),
|
||||
).toEqual({ violations: true, recentActivity: true });
|
||||
});
|
||||
});
|
||||
@@ -18,6 +18,23 @@ const ADVANCED_GRID_BREAKPOINT = 800;
|
||||
const ADVANCED_GRID_GAP_PX = 16;
|
||||
const ADVANCED_GRID_PADDING_PX = 16;
|
||||
|
||||
export const getCompactSectionVisibility = ({
|
||||
height,
|
||||
showStreams,
|
||||
showViolations,
|
||||
hasViolations,
|
||||
showRecentActivity,
|
||||
}: {
|
||||
height: number;
|
||||
showStreams: boolean;
|
||||
showViolations: boolean;
|
||||
hasViolations: boolean;
|
||||
showRecentActivity: boolean;
|
||||
}) => ({
|
||||
violations: showViolations && (hasViolations || height >= 240 || !showStreams),
|
||||
recentActivity: showRecentActivity && (height >= 360 || (!showStreams && (!showViolations || !hasViolations))),
|
||||
});
|
||||
|
||||
export default function TracearrWidget({
|
||||
options,
|
||||
integrationIds,
|
||||
@@ -124,6 +141,13 @@ function TracearrContent({ integrationIds, options, width, height, displayMode }
|
||||
const streams = displayMode === "advanced" ? combined.streams.data : combined.streams.data.slice(0, compactLimit);
|
||||
const violations = combined.violations?.data ?? [];
|
||||
const recentActivity = combined.recentActivity?.data ?? [];
|
||||
const compactSections = getCompactSectionVisibility({
|
||||
height,
|
||||
showStreams: options.showStreams,
|
||||
showViolations: options.showViolations,
|
||||
hasViolations: violations.length > 0,
|
||||
showRecentActivity: options.showRecentActivity,
|
||||
});
|
||||
|
||||
if (displayMode === "advanced") {
|
||||
const isTwoColumn = width >= ADVANCED_GRID_BREAKPOINT;
|
||||
@@ -154,9 +178,9 @@ function TracearrContent({ integrationIds, options, width, height, displayMode }
|
||||
<ScrollArea h="100%">
|
||||
<Stack gap="xs" p="xs">
|
||||
{options.showStats && <StatsBar stats={combined.stats} summary={combined.streams.summary} width={width} />}
|
||||
{compactSections.violations && <ViolationsList violations={violations.slice(0, compactLimit)} />}
|
||||
{options.showStreams && <StreamsList streams={streams} width={width} />}
|
||||
{options.showViolations && <ViolationsList violations={violations.slice(0, compactLimit)} />}
|
||||
{options.showRecentActivity && <RecentActivityList sessions={recentActivity.slice(0, compactLimit)} />}
|
||||
{compactSections.recentActivity && <RecentActivityList sessions={recentActivity.slice(0, compactLimit)} />}
|
||||
{noSectionsEnabled && (
|
||||
<Text c="dimmed" ta="center">
|
||||
{t("noSectionsEnabled")}
|
||||
|
||||
@@ -8,7 +8,7 @@ export function RecentActivityList({ sessions }: { sessions: TracearrHistorySess
|
||||
|
||||
return (
|
||||
<Stack gap={4}>
|
||||
<Text size="xs" fw={600} c="dimmed" tt="uppercase">
|
||||
<Text size="xs" fw={600} c="dimmed">
|
||||
{t("recentActivity.title")}
|
||||
</Text>
|
||||
{sessions.length === 0 ? (
|
||||
|
||||
@@ -9,7 +9,7 @@ export function ViolationsList({ violations }: { violations: TracearrViolation[]
|
||||
|
||||
return (
|
||||
<Stack gap={4}>
|
||||
<Text size="xs" fw={600} c="dimmed" tt="uppercase">
|
||||
<Text size="xs" fw={600} c="dimmed">
|
||||
{t("violations.title")}
|
||||
</Text>
|
||||
{violations.length === 0 ? (
|
||||
|
||||
Reference in new issue
Block a user