fix(downloads): move column reset into the header menu
Keep the action column reserved for row actions and expose the global layout reset through the existing column-header context menu.
This commit is contained in:
+24
-17
@@ -4804,21 +4804,23 @@ export function App(): ReactElement {
|
|||||||
}
|
}
|
||||||
}), [actionBusy, columnOrder, downloadDisclosureRevision, downloadPackageSpeeds, downloadQueueTotalBytes, downloadRemaining, downloadsSortColumn, downloadsSortDescending, downloadsViewCore, editingName, editingPackageId, gridTemplate, liveDownloadSpeedBps, providerStats.length, scheduleCountdown, schedulePickerOpen, scheduleTimeInput, snapshot.canPause, snapshot.canStart, snapshot.canStop, snapshot.clipboardActive, snapshot.etaText, snapshot.reconnectSeconds, snapshot.session.items, snapshot.session.paused, snapshot.session.reconnectReason, snapshot.session.running, snapshot.settings.animatePackageDisclosure, snapshot.settings.scheduledStartEpochMs, snapshot.stats.totalDownloaded, snapshot.stats.totalPackages]);
|
}), [actionBusy, columnOrder, downloadDisclosureRevision, downloadPackageSpeeds, downloadQueueTotalBytes, downloadRemaining, downloadsSortColumn, downloadsSortDescending, downloadsViewCore, editingName, editingPackageId, gridTemplate, liveDownloadSpeedBps, providerStats.length, scheduleCountdown, schedulePickerOpen, scheduleTimeInput, snapshot.canPause, snapshot.canStart, snapshot.canStop, snapshot.clipboardActive, snapshot.etaText, snapshot.reconnectSeconds, snapshot.session.items, snapshot.session.paused, snapshot.session.reconnectReason, snapshot.session.running, snapshot.settings.animatePackageDisclosure, snapshot.settings.scheduledStartEpochMs, snapshot.stats.totalDownloaded, snapshot.stats.totalPackages]);
|
||||||
|
|
||||||
|
const resetColumnLayout = useCallback((): void => {
|
||||||
|
if (columnDragSettleTimerRef.current !== null) {
|
||||||
|
window.clearTimeout(columnDragSettleTimerRef.current);
|
||||||
|
columnDragSettleTimerRef.current = null;
|
||||||
|
}
|
||||||
|
cancelColumnDragAnimations();
|
||||||
|
if (columnDragSessionRef.current) {
|
||||||
|
clearDownloadColumnDrag(columnDragSessionRef.current);
|
||||||
|
columnDragSessionRef.current = null;
|
||||||
|
}
|
||||||
|
setColumnOrder(DEFAULT_COLUMN_ORDER);
|
||||||
|
persistColumnOrder(DEFAULT_COLUMN_ORDER);
|
||||||
|
showToast("Spaltenlayout zurückgesetzt", 1800);
|
||||||
|
}, [cancelColumnDragAnimations, persistColumnOrder, showToast]);
|
||||||
|
|
||||||
const downloadsActions: DownloadsViewActions = {
|
const downloadsActions: DownloadsViewActions = {
|
||||||
onResetColumnLayout: () => {
|
onResetColumnLayout: resetColumnLayout,
|
||||||
if (columnDragSettleTimerRef.current !== null) {
|
|
||||||
window.clearTimeout(columnDragSettleTimerRef.current);
|
|
||||||
columnDragSettleTimerRef.current = null;
|
|
||||||
}
|
|
||||||
cancelColumnDragAnimations();
|
|
||||||
if (columnDragSessionRef.current) {
|
|
||||||
clearDownloadColumnDrag(columnDragSessionRef.current);
|
|
||||||
columnDragSessionRef.current = null;
|
|
||||||
}
|
|
||||||
setColumnOrder(DEFAULT_COLUMN_ORDER);
|
|
||||||
persistColumnOrder(DEFAULT_COLUMN_ORDER);
|
|
||||||
showToast("Spaltenlayout zurückgesetzt", 1800);
|
|
||||||
},
|
|
||||||
onDisplayModeChange: setDownloadDisplayMode,
|
onDisplayModeChange: setDownloadDisplayMode,
|
||||||
onFilterChange: setDownloadFilter,
|
onFilterChange: setDownloadFilter,
|
||||||
onProviderFilterChange: setDownloadProviderFilter,
|
onProviderFilterChange: setDownloadProviderFilter,
|
||||||
@@ -6449,7 +6451,7 @@ export function App(): ReactElement {
|
|||||||
x={colHeaderCtx.x}
|
x={colHeaderCtx.x}
|
||||||
y={colHeaderCtx.y}
|
y={colHeaderCtx.y}
|
||||||
>
|
>
|
||||||
{ALL_COLUMN_KEYS.map((col) => {
|
{ALL_COLUMN_KEYS.map((col) => {
|
||||||
const def = COLUMN_DEFS[col];
|
const def = COLUMN_DEFS[col];
|
||||||
if (!def) return null;
|
if (!def) return null;
|
||||||
const isVisible = columnOrder.includes(col);
|
const isVisible = columnOrder.includes(col);
|
||||||
@@ -6482,8 +6484,13 @@ export function App(): ReactElement {
|
|||||||
>
|
>
|
||||||
{isVisible ? "\u2713 " : "\u2003 "}{def.label}
|
{isVisible ? "\u2713 " : "\u2003 "}{def.label}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
<div className="ctx-menu-sep" />
|
||||||
|
<button className="ctx-menu-item" onClick={() => {
|
||||||
|
resetColumnLayout();
|
||||||
|
setColHeaderCtx(null);
|
||||||
|
}}>Spaltenlayout zurücksetzen</button>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
) : null}
|
) : null}
|
||||||
historyContextMenu={historyCtxMenu ? (() => {
|
historyContextMenu={historyCtxMenu ? (() => {
|
||||||
|
|||||||
@@ -85,12 +85,17 @@ describe("desktop shell", () => {
|
|||||||
|
|
||||||
it("resets the download columns immediately and persists the default order", () => {
|
it("resets the download columns immediately and persists the default order", () => {
|
||||||
const source = readFileSync(new URL("../src/renderer/App.tsx", import.meta.url), "utf8");
|
const source = readFileSync(new URL("../src/renderer/App.tsx", import.meta.url), "utf8");
|
||||||
|
const reset = source.slice(source.indexOf("const resetColumnLayout"), source.indexOf("const downloadsActions"));
|
||||||
const actions = source.slice(source.indexOf("const downloadsActions"), source.indexOf("const statisticsActions"));
|
const actions = source.slice(source.indexOf("const downloadsActions"), source.indexOf("const statisticsActions"));
|
||||||
|
const menu = source.slice(source.indexOf("columnContextMenu={"), source.indexOf("historyContextMenu={"));
|
||||||
|
|
||||||
expect(actions).toContain("onResetColumnLayout");
|
expect(reset).toContain("setColumnOrder(DEFAULT_COLUMN_ORDER)");
|
||||||
expect(actions).toContain("setColumnOrder(DEFAULT_COLUMN_ORDER)");
|
expect(reset).toContain("persistColumnOrder(DEFAULT_COLUMN_ORDER)");
|
||||||
expect(actions).toContain("persistColumnOrder(DEFAULT_COLUMN_ORDER)");
|
expect(reset).toContain('showToast("Spaltenlayout zurückgesetzt"');
|
||||||
expect(actions).toContain('showToast("Spaltenlayout zurückgesetzt"');
|
expect(actions).toContain("onResetColumnLayout: resetColumnLayout");
|
||||||
|
expect(menu).toContain("Spaltenlayout zurücksetzen");
|
||||||
|
expect(menu).toContain("resetColumnLayout()");
|
||||||
|
expect(menu).toContain("setColHeaderCtx(null)");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps application menus mounted for animated opening and closing", () => {
|
it("keeps application menus mounted for animated opening and closing", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user