feat: protect responsive board layouts

This commit is contained in:
ajnart committed 2026-08-13 19:55:38 +02:00
1 parent 4df62221c7
commit 30c00ea30d
30 files changed
+1055 -254

No files matched your search

@@ -1,6 +1,7 @@
import { createId } from "@homarr/common";
import { createLogger } from "@homarr/core/infrastructure/logs";
import { createDbInsertCollectionForTransaction } from "@homarr/db/collection";
import { normalizeBoardLayoutRoles } from "@homarr/definitions";
import type { BoardSize, OldmarrConfig } from "@homarr/old-schema";
import { boardSizes, getBoardSizeName } from "@homarr/old-schema";
@@ -88,14 +89,19 @@ export const createBoardInsertCollection = (
{} as Record<BoardSize, string>,
);
const preparedLayouts = boardSizes.map((size) => ({
id: layoutMapping[size],
boardId: mappedBoard.id,
columnCount: mapColumnCount(board.config.settings.customization.gridstack, size),
breakpoint: mapBreakpoint(size),
name: getBoardSizeName(size),
}));
insertCollection.layouts.push(...preparedLayouts);
const importedLayouts = normalizeBoardLayoutRoles(
boardSizes.map((size) => ({
id: layoutMapping[size],
boardId: mappedBoard.id,
columnCount: mapColumnCount(board.config.settings.customization.gridstack, size),
leftGutterColumnCount: 0,
rightGutterColumnCount: 0,
breakpoint: mapBreakpoint(size),
name: getBoardSizeName(size),
})),
);
insertCollection.layouts.push(...importedLayouts);
const preparedSections = prepareSections(mappedBoard.id, { wrappers, categories });
@@ -113,7 +119,7 @@ export const createBoardInsertCollection = (
layoutMapping,
mappedBoard.id,
);
insertCollection.sectionLayouts.push(...placePreparedSections(preparedSections, preparedItems, preparedLayouts));
insertCollection.sectionLayouts.push(...placePreparedSections(preparedSections, preparedItems, importedLayouts));
preparedItems.forEach(({ layouts, ...item }) => {
insertCollection.items.push(item);
insertCollection.itemLayouts.push(...layouts);
@@ -1,9 +1,9 @@
import { generateResponsiveGridFor } from "@homarr/common";
import type { GridAlgorithmItem } from "@homarr/common";
import { createLogger } from "@homarr/core/infrastructure/logs";
import type { BoardSize, OldmarrApp, OldmarrConfig, OldmarrWidget, SizedShape } from "@homarr/old-schema";
import { boardSizes } from "@homarr/old-schema";
import type { GridAlgorithmItem } from "../../../api/src/router/board/grid-algorithm";
import { generateResponsiveGridFor } from "../../../api/src/router/board/grid-algorithm";
import { mapColumnCount } from "../mappers/map-column-count";
import { mapApp, mapWidget } from "../mappers/map-item";