fix(board): harden selection and creation flows

This commit is contained in:
Thomas Camlong committed 2026-08-21 02:55:47 +02:00
1 parent 71d307a9cd
commit 50bd56edb9
12 files changed
+119 -26

No files matched your search

@@ -62,13 +62,19 @@ vi.mock("@homarr/modals", async () => {
});
vi.mock("@homarr/translation/client", () => ({
useI18n: () => (key: string) => {
useI18n: () => (key: string, values?: { count?: number }) => {
const count = values?.count ?? 0;
const translations: Record<string, string> = {
"app.action.select.search": "Search apps",
"app.action.select.title": "Select application",
"app.action.select.selected": "Selected",
"app.action.select.toggle": "Click to select",
"app.action.select.noResults": "No apps found",
"app.action.select.multiSelectTip": "Hold Ctrl or Command to select multiple apps",
"app.action.select.selectedCount": `${count} selected`,
"app.action.select.appsSelected": `${count} ${count === 1 ? "app" : "apps"} selected`,
"app.action.select.customApplication": "Custom application",
"app.action.select.application": "Application",
"app.action.create.title": "Add custom app",
"app.action.create.description": "Configure custom URL and icon",
"common.action.discard": "Discard",
@@ -19,7 +19,7 @@ import type { RouterOutputs } from "@homarr/api";
import { clientApi } from "@homarr/api/client";
import { createModal, modalSizeSelect, useModalAction } from "@homarr/modals";
import { useI18n } from "@homarr/translation/client";
import { SelectableCard } from "@homarr/ui";
import { selectGridCols, SelectableCard } from "@homarr/ui";
import { QuickAddAppModal } from "./quick-add-app/quick-add-app-modal";
@@ -31,8 +31,6 @@ interface AppSelectModalProps {
withCreate: boolean;
}
const selectGridCols = { base: 1, xs: 2, sm: 2, md: 3, lg: 4 };
export const AppSelectModal = createModal<AppSelectModalProps>(({ actions, innerProps }) => {
const [search, setSearch] = useState("");
const [selectedAppIds, setSelectedAppIds] = useState<Set<string>>(new Set());
+5 -2
View File
@@ -1674,7 +1674,8 @@
"detected": "Detected via Docker",
"connected": "{count, plural, one {# connected} other {# connected}}",
"tiedWidgets": "Tied widgets",
"more": "+{count} more"
"more": "+{count} more",
"loadError": "Integrations could not be loaded. Try again before creating a new connection."
},
"category": {
"dnsHole": "DNS",
@@ -2792,7 +2793,9 @@
"clear": "Clear selection",
"clearShortcut": "Clear selection (Escape)",
"saveErrorTitle": "Unable to update items",
"saveErrorMessage": "The changes could not be saved. The board was refreshed."
"saveErrorMessage": "The changes could not be saved. The board was refreshed.",
"moveUnavailableTitle": "Unable to move selected items",
"moveUnavailableMessage": "The destination does not have enough room for the entire selection."
},
"moveResize": {
"title": "Move / resize item",
@@ -201,7 +201,7 @@ describe("SelectableCard", () => {
expect(host.textContent).not.toContain("This should not appear");
});
it("renders description with fallback when description is empty string", async () => {
it("renders an empty description without fallback copy", async () => {
await act(async () =>
root.render(
<MantineProvider>
@@ -210,7 +210,8 @@ describe("SelectableCard", () => {
),
);
expect(host.textContent).toContain("No description provided");
expect(host.textContent).toContain("No Desc Item");
expect(host.textContent).not.toContain("No description provided");
});
it("omits header, body, or footer when corresponding props are omitted", async () => {
@@ -22,11 +22,14 @@ vi.mock("@homarr/definitions", async (importOriginal) => {
});
vi.mock("@homarr/translation/client", () => ({
useI18n: () => (key: string) => {
useI18n: () => (key: string, values?: { count?: number }) => {
const translations: Record<string, string> = {
"integration.page.list.search": "Search integrations",
"common.noResults": "No results found",
"integration.grid.noWidgets": "No widgets tied to this service",
"integration.grid.tiedWidgets": "Tied Widgets",
"integration.grid.connected": `${values?.count ?? 0} connected`,
"integration.grid.more": `+${values?.count ?? 0} more`,
"widget.mediaServer.name": "Media Server",
"widget.calendar.name": "Calendar",
"widget.downloads.name": "Downloads",
@@ -47,6 +47,7 @@ import { useI18n } from "@homarr/translation/client";
import { IntegrationAvatar } from "../components/integration-avatar";
import { SelectableCard } from "../components/selectable-card";
import { selectGridCols } from "../select-grid-layout";
import { buildSortedIntegrations, categoryTranslationKeys, filterIntegrations } from "./integration-grid-shared";
import type { IntegrationGridItem } from "./integration-grid-shared";
@@ -57,8 +58,6 @@ export interface IntegrationSelectGridProps {
integrationData?: { kind: IntegrationKind; name?: string }[];
}
const selectGridCols = { base: 1, xs: 2, sm: 2, md: 3, lg: 4 };
export const IntegrationSelectGrid = ({
onSelect,
enableMockIntegration = false,
@@ -218,6 +218,7 @@ export const WidgetEditModal = createModal<WidgetEditModalProps<WidgetKind>>(({
handleSubmit(event);
};
const canCreateIntegration = maxIntegrations === 1 || form.values.integrationIds.length < maxIntegrations;
const handleOpenNewIntegration = innerProps.onOpenNewIntegration
? () => {
innerProps.onOpenNewIntegration?.((newId) => {
@@ -236,7 +237,7 @@ export const WidgetEditModal = createModal<WidgetEditModalProps<WidgetKind>>(({
data={innerProps.integrationData}
canSelectMultiple={maxIntegrations > 1}
withAsterisk={integrationsRequired}
onOpenNewIntegration={handleOpenNewIntegration}
onOpenNewIntegration={canCreateIntegration ? handleOpenNewIntegration : undefined}
{...form.getInputProps("integrationIds")}
/>
)}