feat(boards): add form logic and translations to board create modal

This commit is contained in:
Meier Lukas committed 2025-11-26 18:38:32 +01:00
1 parent 2b6eb88a53
commit 0843ccda99
7 files changed
+35 -13

No files matched your search

+2
View File
@@ -8,7 +8,9 @@ export const backgroundImageRepeats = createDefinition(["repeat", "repeat-x", "r
export const backgroundImageSizes = createDefinition(["cover", "contain"], { export const backgroundImageSizes = createDefinition(["cover", "contain"], {
defaultValue: "cover", defaultValue: "cover",
}); });
export const boardLayoutModes = createDefinition(["auto", "custom"], { defaultValue: "auto" });
export type BackgroundImageAttachment = inferDefinitionType<typeof backgroundImageAttachments>; export type BackgroundImageAttachment = inferDefinitionType<typeof backgroundImageAttachments>;
export type BackgroundImageRepeat = inferDefinitionType<typeof backgroundImageRepeats>; export type BackgroundImageRepeat = inferDefinitionType<typeof backgroundImageRepeats>;
export type BackgroundImageSize = inferDefinitionType<typeof backgroundImageSizes>; export type BackgroundImageSize = inferDefinitionType<typeof backgroundImageSizes>;
export type BoardLayoutMode = inferDefinitionType<typeof boardLayoutModes>;
+1
View File
@@ -24,6 +24,7 @@
"dependencies": { "dependencies": {
"@homarr/api": "workspace:^0.1.0", "@homarr/api": "workspace:^0.1.0",
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
"@homarr/definitions": "workspace:^0.1.0",
"@homarr/form": "workspace:^0.1.0", "@homarr/form": "workspace:^0.1.0",
"@homarr/forms-collection": "workspace:^0.1.0", "@homarr/forms-collection": "workspace:^0.1.0",
"@homarr/modals": "workspace:^0.1.0", "@homarr/modals": "workspace:^0.1.0",
@@ -15,6 +15,7 @@ import { IconAlertTriangle, IconCircleCheck } from "@tabler/icons-react";
import { clientApi } from "@homarr/api/client"; import { clientApi } from "@homarr/api/client";
import { revalidatePathActionAsync } from "@homarr/common/client"; import { revalidatePathActionAsync } from "@homarr/common/client";
import { boardLayoutModes } from "@homarr/definitions";
import { useZodForm } from "@homarr/form"; import { useZodForm } from "@homarr/form";
import { createModal } from "@homarr/modals"; import { createModal } from "@homarr/modals";
import { showErrorNotification, showSuccessNotification } from "@homarr/notifications"; import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";
@@ -30,6 +31,7 @@ export const AddBoardModal = createModal(({ actions }) => {
name: "", name: "",
columnCount: 10, columnCount: 10,
isPublic: false, isPublic: false,
layoutMode: boardLayoutModes.defaultValue,
}, },
}); });
const { mutate, isPending } = clientApi.board.createBoard.useMutation({ const { mutate, isPending } = clientApi.board.createBoard.useMutation({
@@ -77,19 +79,18 @@ export const AddBoardModal = createModal(({ actions }) => {
} }
/> />
<Fieldset legend="Layout"> <Fieldset legend={t("board.setting.section.layout.title")}>
<Stack gap="sm"> <Stack gap="sm">
<RadioGroup> <RadioGroup {...form.getInputProps("layoutMode")}>
<SimpleGrid cols={{ sm: 2, xs: 1 }} spacing="md"> <SimpleGrid cols={{ sm: 2, xs: 1 }} spacing="md">
<CustomRadioCard {boardLayoutModes.values.map((mode) => (
name="Auto" <CustomRadioCard
description="Position and size of all layouts are calculated from the base layout." key={mode}
checked value={mode}
/> label={t(`board.field.layoutMode.option.${mode}.label`)}
<CustomRadioCard description={t(`board.field.layoutMode.option.${mode}.description`)}
name="Custom" />
description="Position and size must be configured for all layouts separately." ))}
/>
</SimpleGrid> </SimpleGrid>
</RadioGroup> </RadioGroup>
+13
View File
@@ -2793,6 +2793,19 @@
"label": "Disable app status", "label": "Disable app status",
"description": "Disables the status check for all apps on this board" "description": "Disables the status check for all apps on this board"
}, },
"layoutMode": {
"label": "Layout mode",
"option": {
"auto": {
"label": "Auto",
"description": "Position and size of all layouts are calculated from the base layout."
},
"custom": {
"label": "Custom",
"description": "Position and size must be configured for all layouts separately."
}
}
},
"columnCount": { "columnCount": {
"label": "Column count" "label": "Column count"
}, },
+2 -2
View File
@@ -5,7 +5,7 @@ import clsx from "clsx";
import classes from "./radio.module.css"; import classes from "./radio.module.css";
interface CustomRadioCardProps extends RadioCardProps { interface CustomRadioCardProps extends RadioCardProps {
name: string; label: string;
description: string; description: string;
} }
@@ -15,7 +15,7 @@ export const CustomRadioCard = (props: CustomRadioCardProps) => {
<Group wrap="nowrap" align="flex-start"> <Group wrap="nowrap" align="flex-start">
<RadioIndicator /> <RadioIndicator />
<div> <div>
<Text className={classes.label}>{props.name}</Text> <Text className={classes.label}>{props.label}</Text>
<Text className={classes.description}>{props.description}</Text> <Text className={classes.description}>{props.description}</Text>
</div> </div>
</Group> </Group>
+2
View File
@@ -4,6 +4,7 @@ import {
backgroundImageAttachments, backgroundImageAttachments,
backgroundImageRepeats, backgroundImageRepeats,
backgroundImageSizes, backgroundImageSizes,
boardLayoutModes,
boardPermissions, boardPermissions,
} from "@homarr/definitions"; } from "@homarr/definitions";
@@ -90,6 +91,7 @@ export const boardSaveSchema = z.object({
export const boardCreateSchema = z.object({ export const boardCreateSchema = z.object({
name: boardNameSchema, name: boardNameSchema,
columnCount: boardColumnCountSchema, columnCount: boardColumnCountSchema,
layoutMode: z.enum(boardLayoutModes.values).default(boardLayoutModes.defaultValue),
isPublic: z.boolean(), isPublic: z.boolean(),
}); });
+3
View File
@@ -1613,6 +1613,9 @@ importers:
'@homarr/common': '@homarr/common':
specifier: workspace:^0.1.0 specifier: workspace:^0.1.0
version: link:../common version: link:../common
'@homarr/definitions':
specifier: workspace:^0.1.0
version: link:../definitions
'@homarr/form': '@homarr/form':
specifier: workspace:^0.1.0 specifier: workspace:^0.1.0
version: link:../form version: link:../form