diff --git a/src/renderer/views/downloads/DownloadsTable.tsx b/src/renderer/views/downloads/DownloadsTable.tsx index 030d9c1..3374a47 100644 --- a/src/renderer/views/downloads/DownloadsTable.tsx +++ b/src/renderer/views/downloads/DownloadsTable.tsx @@ -512,6 +512,7 @@ export interface DownloadsTableHeaderProps { actions: DownloadsTableActions; columnOrder: readonly string[]; gridTemplate: string; + onResetColumnLayout?: () => void; sortColumn: DownloadSortColumn; sortDirection: "asc" | "desc"; selectedCount: number; @@ -533,7 +534,7 @@ function moveColumnWithPointerActions(column: string, direction: -1 | 1, element actions.onColumnPointerUp(column, pointerEvent(clientX)); } -export function DownloadsTableHeader({ actions, columnOrder, gridTemplate, sortColumn, sortDirection, selectedCount, visibleIds }: DownloadsTableHeaderProps): ReactElement { +export function DownloadsTableHeader({ actions, columnOrder, gridTemplate, onResetColumnLayout, sortColumn, sortDirection, selectedCount, visibleIds }: DownloadsTableHeaderProps): ReactElement { const allSelected = visibleIds.length > 0 && selectedCount === visibleIds.length; const mixedSelection = selectedCount > 0 && selectedCount < visibleIds.length; return ( @@ -574,7 +575,7 @@ export function DownloadsTableHeader({ actions, columnOrder, gridTemplate, sortC ); })} - Aktion + Aktion{onResetColumnLayout ? : null} ); } diff --git a/src/renderer/views/downloads/DownloadsView.tsx b/src/renderer/views/downloads/DownloadsView.tsx index f1327ac..a5ebd92 100644 --- a/src/renderer/views/downloads/DownloadsView.tsx +++ b/src/renderer/views/downloads/DownloadsView.tsx @@ -52,8 +52,9 @@ export interface DownloadsViewModel extends DownloadsViewModelCore { status: DownloadsStatusModel; } -export interface DownloadsViewActions extends DownloadsTableActions { - onDisplayModeChange: (mode: DownloadDisplayMode) => void; +export interface DownloadsViewActions extends DownloadsTableActions { + onResetColumnLayout: () => void; + onDisplayModeChange: (mode: DownloadDisplayMode) => void; onFilterChange: (filter: DownloadSidebarFilter) => void; onProviderFilterChange: (provider: string) => void; onQueryChange: (query: string) => void; @@ -148,7 +149,7 @@ export function DownloadsContent({ actions, model }: { actions: DownloadsViewAct return (
- +
diff --git a/src/renderer/views/downloads/downloads.css b/src/renderer/views/downloads/downloads.css index a845908..942045b 100644 --- a/src/renderer/views/downloads/downloads.css +++ b/src/renderer/views/downloads/downloads.css @@ -527,6 +527,21 @@ padding: 0; } +.downloads-header-action-cell { + flex-direction: column; + gap: 1px; + line-height: 11px; +} + +.downloads-header-action-cell .downloads-column-reset-button { + width: 20px; + height: 20px; + min-height: 20px; + border-radius: 4px; + font-size: 15px; + line-height: 1; +} + .downloads-collapse-button { box-sizing: border-box; flex: 0 0 30px; diff --git a/tests/downloads-view.test.tsx b/tests/downloads-view.test.tsx index feb0431..dccac29 100644 --- a/tests/downloads-view.test.tsx +++ b/tests/downloads-view.test.tsx @@ -95,6 +95,30 @@ describe("Downloadtabellen-Spalten", () => { expect(header.props.style.gridTemplateColumns).toBe(expected); }); + it("exposes a header action that delegates resetting the column layout", () => { + const reset = vi.fn(); + const actions = createActions({ onResetColumnLayout: reset }); + const model = withRuntime(createInput()); + const content = renderToStaticMarkup(); + const header = DownloadsTableHeader({ + actions, + columnOrder: model.columnOrder, + gridTemplate: model.gridTemplate, + onResetColumnLayout: actions.onResetColumnLayout, + selectedCount: 0, + sortColumn: "name", + sortDirection: "asc", + visibleIds: model.visibleRowIds + }); + const button = findElement(header, (element) => element.type === "button" && element.props["aria-label"] === "Spaltenlayout zurücksetzen"); + + button.props.onClick(); + + expect(content).toContain('aria-label="Spaltenlayout zurücksetzen"'); + expect(button.props.title).toBe("Spaltenlayout zurücksetzen"); + expect(reset).toHaveBeenCalledTimes(1); + }); + it("never interpolates download grid tracks while column contents move", () => { const css = fs.readFileSync(path.join(process.cwd(), "src/renderer/views/downloads/downloads.css"), "utf8"); @@ -651,6 +675,7 @@ function createLargeInput(packageCount: number, itemCount: number, overrides: Pa function createActions(overrides: Partial = {}): DownloadsViewActions { return { + onResetColumnLayout: () => {}, onDisplayModeChange: () => {}, onFilterChange: () => {}, onProviderFilterChange: () => {},