Revert "feat: complete automatic mobile board UX"

This reverts commit 7959c20d88.
This commit is contained in:
ajnart committed 2026-08-13 19:55:21 +02:00
1 parent e93293f8a9
commit be9c69f325
41 files changed
+270 -1225

No files matched your search

-36
View File
@@ -1,36 +0,0 @@
import { describe, expect, test } from "vitest";
import type { RouterOutputs } from "@homarr/api";
import { getBoardLayouts, getCurrentLayout, getDesktopLayout } from "./context";
const createBoard = () =>
({
layouts: [
{ id: "small", name: "Small", columnCount: 4, breakpoint: 0 },
{ id: "medium", name: "Medium", columnCount: 8, breakpoint: 768 },
{ id: "large", name: "Large", columnCount: 12, breakpoint: 1200 },
],
}) as RouterOutputs["board"]["getBoardByName"];
describe("board layout selection", () => {
test("automatic mode always uses the desktop layout", () => {
const board = createBoard();
expect(getDesktopLayout(board).id).toBe("large");
expect(getCurrentLayout(board, true, 390)).toBe("large");
});
test.each([
[390, "small"],
[768, "medium"],
[1024, "medium"],
[1440, "large"],
])("legacy mode selects the matching responsive layout at %spx", (viewportWidth, expectedLayoutId) => {
expect(getCurrentLayout(createBoard(), false, viewportWidth)).toBe(expectedLayoutId);
});
test("keeps every saved layout available for reversible mutations", () => {
expect(getBoardLayouts(createBoard())).toEqual(["small", "medium", "large"]);
});
});
-30
View File
@@ -1,30 +0,0 @@
import { describe, expect, test, vi } from "vitest";
import type { BoardEditAction, BoardEditActionEvent } from "./edit-mode";
import { boardEditActionEventName, requestBoardEditAction } from "./edit-mode";
describe("requestBoardEditAction", () => {
test("runs the action immediately when no edit guard is mounted", () => {
const action = vi.fn();
requestBoardEditAction(action);
expect(action).toHaveBeenCalledOnce();
});
test("lets an edit guard defer the action until the user confirms", () => {
const action = vi.fn();
let deferredAction: BoardEditAction | undefined;
const listener = (event: Event) => {
event.preventDefault();
deferredAction = (event as BoardEditActionEvent).detail.action;
};
document.addEventListener(boardEditActionEventName, listener, { once: true });
requestBoardEditAction(action);
expect(action).not.toHaveBeenCalled();
void deferredAction?.();
expect(action).toHaveBeenCalledOnce();
});
});
-22
View File
@@ -6,28 +6,6 @@ import { useDisclosure } from "@mantine/hooks";
const EditModeContext = createContext<ReturnType<typeof useDisclosure> | null>(null);
export const boardEditActionEventName = "homarr:board-edit-action";
export type BoardEditActionResult = boolean | void;
export type BoardEditAction = () => BoardEditActionResult | Promise<BoardEditActionResult>;
export type BoardEditActionEvent = CustomEvent<{ action: BoardEditAction }>;
export const requestBoardEditAction = (action: BoardEditAction) => {
if (typeof document === "undefined") {
void action();
return;
}
const event: BoardEditActionEvent = new CustomEvent(boardEditActionEventName, {
cancelable: true,
detail: { action },
});
if (document.dispatchEvent(event)) {
void action();
}
};
const noop = () => undefined;
const readOnlyEditMode = [false, { open: noop, close: noop, toggle: noop, set: noop }] satisfies ReturnType<
typeof useDisclosure