fix: isolate downloads stats state

This commit is contained in:
Thomas Camlong committed 2026-08-14 22:07:12 +02:00
1 parent 2e3e654748
commit 3c533f2d96
4 files changed
+42 -10

No files matched your search

+2 -1
View File
@@ -135,7 +135,8 @@ are enabled, the shared menu provides widget-level actions such as advanced view
- **Right-click** any download to copy its name or ID; pause, resume, and delete are available only with Interact access - **Right-click** any download to copy its name or ID; pause, resume, and delete are available only with Interact access
- **Click** any row to expand it and see full download details inline - **Click** any row to expand it and see full download details inline
- **Hover** a download name for a quick stats tooltip - **Hover** a download name for a quick stats tooltip
- **Stats toggle** — show or hide the global stats bar in compact mode; advanced view always shows the stats bar - **Stats toggle** — show or hide the global stats bar in compact mode; advanced view always shows the stats bar without
changing the compact choice
- **Pause / Resume** actionable queues using the footer controls - **Pause / Resume** actionable queues using the footer controls
- **Filter** rows by integration or status using the filter button in the footer - **Filter** rows by integration or status using the filter button in the footer
- **Sort** by clicking sortable column headers; the default sort is configured per widget, while header changes apply to the current view - **Sort** by clicking sortable column headers; the default sort is configured per widget, while header changes apply to the current view
+13 -9
View File
@@ -64,6 +64,7 @@ import {
filterDownloadItemsByStatus, filterDownloadItemsByStatus,
getAvailableDownloadStates, getAvailableDownloadStates,
getDownloadColumnAccessors, getDownloadColumnAccessors,
getDownloadsStatsDisplay,
} from "./helpers"; } from "./helpers";
dayjs.extend(relativeTime); dayjs.extend(relativeTime);
@@ -327,6 +328,7 @@ export default function DownloadClientsWidget({
const [contextMenu, setContextMenu] = useState<ContextMenuState | null>(null); const [contextMenu, setContextMenu] = useState<ContextMenuState | null>(null);
const [showStats, { toggle: toggleStats }] = useDisclosure(false); const [showStats, { toggle: toggleStats }] = useDisclosure(false);
const isAdvanced = displayMode === "advanced"; const isAdvanced = displayMode === "advanced";
const statsDisplay = getDownloadsStatsDisplay(showStats, isAdvanced);
const utils = clientApi.useUtils(); const utils = clientApi.useUtils();
const mutationOptions = { const mutationOptions = {
@@ -751,7 +753,7 @@ export default function DownloadClientsWidget({
return ( return (
<Stack gap={0} h="100%" style={{ overflow: "hidden" }}> <Stack gap={0} h="100%" style={{ overflow: "hidden" }}>
{(showStats || isAdvanced) && ( {statsDisplay.visible && (
<GlobalStatsBar <GlobalStatsBar
key={displayMode} key={displayMode}
queueStats={queueStats} queueStats={queueStats}
@@ -814,8 +816,8 @@ export default function DownloadClientsWidget({
availableStatuses={availableStatuses} availableStatuses={availableStatuses}
pauseQueue={mutatePauseQueue} pauseQueue={mutatePauseQueue}
resumeQueue={mutateResumeQueue} resumeQueue={mutateResumeQueue}
showStats={showStats} showStats={statsDisplay.visible}
toggleStats={toggleStats} toggleStats={statsDisplay.canToggle ? toggleStats : undefined}
/> />
)} )}
@@ -1185,7 +1187,7 @@ interface WidgetFooterProps {
pauseQueue: (args: { integrationIds: string[] }) => void; pauseQueue: (args: { integrationIds: string[] }) => void;
resumeQueue: (args: { integrationIds: string[] }) => void; resumeQueue: (args: { integrationIds: string[] }) => void;
showStats: boolean; showStats: boolean;
toggleStats: () => void; toggleStats?: () => void;
} }
function WidgetFooter({ function WidgetFooter({
@@ -1323,11 +1325,13 @@ function WidgetFooter({
</ActionIcon> </ActionIcon>
</Tooltip> </Tooltip>
<Tooltip label={statsTooltip}> {toggleStats ? (
<ActionIcon size="xs" variant={statsIconVariant} aria-label={statsTooltip} onClick={toggleStats}> <Tooltip label={statsTooltip}>
<StatsIcon size={14} /> <ActionIcon size="xs" variant={statsIconVariant} aria-label={statsTooltip} onClick={toggleStats}>
</ActionIcon> <StatsIcon size={14} />
</Tooltip> </ActionIcon>
</Tooltip>
) : null}
<Group gap={2}> <Group gap={2}>
{clients.map(({ integration }) => ( {clients.map(({ integration }) => (
@@ -5,6 +5,7 @@ import {
filterDownloadItemsByStatus, filterDownloadItemsByStatus,
getAvailableDownloadStates, getAvailableDownloadStates,
getDownloadColumnAccessors, getDownloadColumnAccessors,
getDownloadsStatsDisplay,
} from "./helpers"; } from "./helpers";
describe("downloads filters", () => { describe("downloads filters", () => {
@@ -29,3 +30,22 @@ describe("downloads advanced columns", () => {
expect(getDownloadColumnAccessors(["name"], false)).toEqual(["name"]); expect(getDownloadColumnAccessors(["name"], false)).toEqual(["name"]);
}); });
}); });
describe("downloads stats display", () => {
test("keeps advanced stats independent from the compact toggle", () => {
const compactStatsVisible = false;
expect(
[true, false, true, false].map((isAdvanced) => getDownloadsStatsDisplay(compactStatsVisible, isAdvanced)),
).toEqual([
{ visible: true, canToggle: false },
{ visible: false, canToggle: true },
{ visible: true, canToggle: false },
{ visible: false, canToggle: true },
]);
});
test("preserves an explicitly enabled compact stats bar", () => {
expect(getDownloadsStatsDisplay(true, false)).toEqual({ visible: true, canToggle: true });
});
});
@@ -22,6 +22,13 @@ export const DOWNLOAD_COLUMN_ACCESSORS = [
type DownloadColumnAccessor = (typeof DOWNLOAD_COLUMN_ACCESSORS)[number]; type DownloadColumnAccessor = (typeof DOWNLOAD_COLUMN_ACCESSORS)[number];
export function getDownloadsStatsDisplay(showCompactStats: boolean, isAdvanced: boolean) {
return {
visible: showCompactStats || isAdvanced,
canToggle: !isAdvanced,
};
}
export function getDownloadColumnAccessors( export function getDownloadColumnAccessors(
configuredColumns: readonly DownloadColumnAccessor[], configuredColumns: readonly DownloadColumnAccessor[],
isAdvanced: boolean, isAdvanced: boolean,