feat: add import for config files from oldmarr (#1019)
* wip: add oldmarr config import
* wip: add support for wrong amount of categories / sections with autofix, color mapping, position adjustments of wrappers
* fix: lockfile broken
* feat: add support for form data trpc requests
* wip: improve file upload
* refactor: restructure import, add import configuration
* wip: add configurations for import to modal
* refactor: move oldmarr import to old-import package
* fix: column count not respects screen size for board
* feat: add beta badge for oldmarr config import
* chore: address pull request feedback
* fix: format issues
* fix: inconsistent versions
* fix: deepsource issues
* fix: revert {} to Record<string, never> convertion to prevent typecheck issue
* fix: inconsistent zod version
* fix: format issue
* chore: address pull request feedback
* fix: wrong import
* fix: broken lock file
* fix: inconsistent versions
* fix: format issues
This commit is contained in:
48
packages/old-import/src/mappers/map-colors.ts
Normal file
48
packages/old-import/src/mappers/map-colors.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
const oldColors = [
|
||||
"dark",
|
||||
"gray",
|
||||
"red",
|
||||
"pink",
|
||||
"grape",
|
||||
"violet",
|
||||
"indigo",
|
||||
"blue",
|
||||
"cyan",
|
||||
"green",
|
||||
"lime",
|
||||
"yellow",
|
||||
"orange",
|
||||
"teal",
|
||||
] as const;
|
||||
type OldColor = (typeof oldColors)[number];
|
||||
|
||||
export const mapColor = (color: string | undefined, fallback: string) => {
|
||||
if (!color) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
if (!oldColors.some((mantineColor) => color === mantineColor)) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
const mantineColor = color as OldColor;
|
||||
|
||||
return mappedColors[mantineColor];
|
||||
};
|
||||
|
||||
const mappedColors: Record<(typeof oldColors)[number], string> = {
|
||||
blue: "#228be6",
|
||||
cyan: "#15aabf",
|
||||
dark: "#2e2e2e",
|
||||
grape: "#be4bdb",
|
||||
gray: "#868e96",
|
||||
green: "#40c057",
|
||||
indigo: "#4c6ef5",
|
||||
lime: "#82c91e",
|
||||
orange: "#fd7e14",
|
||||
pink: "#e64980",
|
||||
red: "#fa5252",
|
||||
teal: "#12b886",
|
||||
violet: "#7950f2",
|
||||
yellow: "#fab005",
|
||||
};
|
||||
15
packages/old-import/src/mappers/map-column-count.ts
Normal file
15
packages/old-import/src/mappers/map-column-count.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { OldmarrConfig } from "@homarr/old-schema";
|
||||
import type { OldmarrImportConfiguration } from "@homarr/validation";
|
||||
|
||||
export const mapColumnCount = (old: OldmarrConfig, screenSize: OldmarrImportConfiguration["screenSize"]) => {
|
||||
switch (screenSize) {
|
||||
case "lg":
|
||||
return old.settings.customization.gridstack.columnCountLarge;
|
||||
case "md":
|
||||
return old.settings.customization.gridstack.columnCountMedium;
|
||||
case "sm":
|
||||
return old.settings.customization.gridstack.columnCountSmall;
|
||||
default:
|
||||
return 10;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user