fix: address release v2 reviews
This commit is contained in:
1 parent
4905ea6738
commit
32732680e5
55 files changed
+925
-294
No files matched your search
@@ -86,6 +86,30 @@ Board layout responses identify each layout with a `mobile`, `base`, or `custom`
|
||||
|
||||
Use the interactive API reference to inspect the exact request body for each endpoint under the `boards` and `settings` tags.
|
||||
|
||||
## Docker action payload migration
|
||||
|
||||
Docker lifecycle and removal actions now identify each container with both its Docker endpoint and container ID. This is a
|
||||
breaking change for tRPC and MCP clients that previously sent an `ids` array to the start, stop, restart, or remove action.
|
||||
|
||||
Replace the old payload:
|
||||
|
||||
```json
|
||||
{ "ids": ["container-id"] }
|
||||
```
|
||||
|
||||
with endpoint-qualified targets:
|
||||
|
||||
```json
|
||||
{
|
||||
"targets": [{ "endpointId": "local", "id": "container-id" }]
|
||||
}
|
||||
```
|
||||
|
||||
Read `endpointId` and `id` from `docker.getContainers` (MCP tool `docker_getContainers`) immediately before the action.
|
||||
Pass those pairs unchanged to `docker.startAll`, `docker.stopAll`, `docker.restartAll`, or `docker.removeAll`; their MCP tool
|
||||
names use underscores, such as `docker_restartAll`. Endpoint qualification prevents identical container IDs on different
|
||||
Docker or Podman endpoints from targeting the wrong service.
|
||||
|
||||
## Partial integration failures
|
||||
|
||||
Multi-integration widget queries keep data from integrations that remain available. Calendar and media-server results include
|
||||
|
||||
+13
-2
@@ -1,9 +1,14 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { dismissDockerReconciliationCandidate, filterDockerReconciliationInbox } from "./docker-reconciliation-inbox";
|
||||
import {
|
||||
dismissDockerReconciliationCandidate,
|
||||
filterDockerReconciliationInbox,
|
||||
getValidDockerServiceUrl,
|
||||
} from "./docker-reconciliation-inbox";
|
||||
|
||||
const candidates = [
|
||||
{ candidateKey: "home:new", state: "newRecognized" as const },
|
||||
{ candidateKey: "home:new-app", state: "newApp" as const },
|
||||
{ candidateKey: "remote:moved", state: "moved" as const },
|
||||
{ candidateKey: "home:linked", state: "linked" as const },
|
||||
{ candidateKey: "home:represented", state: "represented" as const },
|
||||
@@ -13,7 +18,7 @@ describe("Docker reconciliation inbox", () => {
|
||||
test("separates attention items from represented services", () => {
|
||||
expect(
|
||||
filterDockerReconciliationInbox(candidates, "attention", []).map(({ candidateKey }) => candidateKey),
|
||||
).toEqual(["home:new", "remote:moved"]);
|
||||
).toEqual(["home:new", "home:new-app", "remote:moved"]);
|
||||
expect(
|
||||
filterDockerReconciliationInbox(candidates, "represented", []).map(({ candidateKey }) => candidateKey),
|
||||
).toEqual(["home:linked", "home:represented"]);
|
||||
@@ -31,4 +36,10 @@ describe("Docker reconciliation inbox", () => {
|
||||
});
|
||||
expect(dismissDockerReconciliationCandidate(dismissed, "home:new")).toBe(dismissed);
|
||||
});
|
||||
|
||||
test("accepts only HTTP service URLs", () => {
|
||||
expect(getValidDockerServiceUrl("https://service.example.com")).toBe("https://service.example.com/");
|
||||
expect(getValidDockerServiceUrl("ftp://service.example.com")).toBeNull();
|
||||
expect(getValidDockerServiceUrl("service.example.com")).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -23,3 +23,12 @@ export const filterDockerReconciliationInbox = <Candidate extends DockerReconcil
|
||||
|
||||
export const dismissDockerReconciliationCandidate = (dismissedCandidateKeys: string[], candidateKey: string) =>
|
||||
dismissedCandidateKeys.includes(candidateKey) ? dismissedCandidateKeys : [...dismissedCandidateKeys, candidateKey];
|
||||
|
||||
export const getValidDockerServiceUrl = (value: string) => {
|
||||
try {
|
||||
const url = new URL(value);
|
||||
return url.protocol === "http:" || url.protocol === "https:" ? url.toString() : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
Alert,
|
||||
Avatar,
|
||||
@@ -23,10 +23,15 @@ import { clientApi } from "@homarr/api/client";
|
||||
import { getIntegrationName } from "@homarr/definitions";
|
||||
import { useModalAction } from "@homarr/modals";
|
||||
import { AddDockerAppToHomarr } from "@homarr/modals-collection";
|
||||
import { showErrorNotification } from "@homarr/notifications";
|
||||
import { useScopedI18n } from "@homarr/translation/client";
|
||||
import { Link } from "@homarr/ui";
|
||||
import type { DockerReconciliationInboxFilter } from "./docker-reconciliation-inbox";
|
||||
import { dismissDockerReconciliationCandidate, filterDockerReconciliationInbox } from "./docker-reconciliation-inbox";
|
||||
import {
|
||||
dismissDockerReconciliationCandidate,
|
||||
filterDockerReconciliationInbox,
|
||||
getValidDockerServiceUrl,
|
||||
} from "./docker-reconciliation-inbox";
|
||||
|
||||
type ReconciliationCandidate = RouterOutputs["docker"]["reconcileServices"]["candidates"][number];
|
||||
type ServiceHealth = RouterOutputs["docker"]["getServiceHealth"]["services"][number];
|
||||
@@ -44,6 +49,12 @@ export const DockerReconciliation = () => {
|
||||
utils.docker.getServiceHealth.invalidate(),
|
||||
]);
|
||||
},
|
||||
onError() {
|
||||
showErrorNotification({
|
||||
title: t("refreshError.title"),
|
||||
message: t("refreshError.message"),
|
||||
});
|
||||
},
|
||||
});
|
||||
const [filter, setFilter] = useState<DockerReconciliationInboxFilter>("attention");
|
||||
const [dismissedCandidateKeys, setDismissedCandidateKeys] = useLocalStorage<string[]>({
|
||||
@@ -51,6 +62,19 @@ export const DockerReconciliation = () => {
|
||||
defaultValue: [],
|
||||
});
|
||||
|
||||
if (reconciliation.isError) {
|
||||
return (
|
||||
<Alert color="red" icon={<IconAlertTriangle size={16} />} title={t("loadError.title")}>
|
||||
<Stack gap="sm">
|
||||
<Text size="sm">{t("loadError.message")}</Text>
|
||||
<Button variant="light" color="red" size="xs" w="fit-content" onClick={() => void reconciliation.refetch()}>
|
||||
{t("action.retry")}
|
||||
</Button>
|
||||
</Stack>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
if (!reconciliation.data) return null;
|
||||
|
||||
const unavailableEndpoints = reconciliation.data.endpoints.filter(({ status }) => status === "unavailable");
|
||||
@@ -156,7 +180,16 @@ const DockerReconciliationCandidate = ({
|
||||
const [selectedCandidateId, setSelectedCandidateId] = useState(initialUrlCandidate?.id ?? null);
|
||||
const [url, setUrl] = useState(initialUrlCandidate?.url ?? "");
|
||||
const selectedCandidate = candidate.urlCandidates.find(({ id }) => id === selectedCandidateId);
|
||||
const target = getCandidateTarget(candidate, url);
|
||||
const validatedUrl = getValidDockerServiceUrl(url);
|
||||
const isInvalidUrl = url.length > 0 && validatedUrl === null;
|
||||
const target = getCandidateTarget(candidate, validatedUrl ?? "");
|
||||
const actionNeedsUrl = target.kind === "createApp" || target.kind === "setupIntegration";
|
||||
const isActionDisabled = actionNeedsUrl && validatedUrl === null;
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedCandidateId(initialUrlCandidate?.id ?? null);
|
||||
setUrl(initialUrlCandidate?.url ?? "");
|
||||
}, [initialUrlCandidate?.id, initialUrlCandidate?.url]);
|
||||
|
||||
return (
|
||||
<Card withBorder padding="md">
|
||||
@@ -224,8 +257,11 @@ const DockerReconciliationCandidate = ({
|
||||
}}
|
||||
/>
|
||||
<TextInput
|
||||
label={t("url.inputLabel")}
|
||||
aria-label={t("url.inputLabel")}
|
||||
value={url}
|
||||
placeholder="https://service.example.com"
|
||||
error={isInvalidUrl ? t("url.invalid") : undefined}
|
||||
onChange={(event) => setUrl(event.currentTarget.value)}
|
||||
/>
|
||||
|
||||
@@ -237,14 +273,27 @@ const DockerReconciliationCandidate = ({
|
||||
<Button
|
||||
variant="light"
|
||||
rightSection={<IconArrowRight size={16} />}
|
||||
disabled={isActionDisabled}
|
||||
onClick={() =>
|
||||
openModal({ selectedContainers: [candidate.container], initialUrls: url ? [url] : undefined })
|
||||
openModal({
|
||||
selectedContainers: [candidate.container],
|
||||
initialUrls: validatedUrl ? [validatedUrl] : undefined,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("action.createApp")}
|
||||
</Button>
|
||||
) : (
|
||||
<Button component={Link} href={target.href} variant="light" rightSection={<IconArrowRight size={16} />}>
|
||||
<Button
|
||||
component={Link}
|
||||
href={target.href}
|
||||
variant="light"
|
||||
rightSection={<IconArrowRight size={16} />}
|
||||
disabled={isActionDisabled}
|
||||
onClick={(event) => {
|
||||
if (isActionDisabled) event.preventDefault();
|
||||
}}
|
||||
>
|
||||
{t(`action.${target.kind}`)}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -24,10 +24,11 @@ export default async function DockerContainerLogsPage({ params, searchParams }:
|
||||
|
||||
const { containerId } = await params;
|
||||
const { endpointId, name } = await searchParams;
|
||||
if (!endpointId) notFound();
|
||||
const resolvedEndpointId = endpointId ?? (await getOnlyDockerEndpointIdAsync());
|
||||
if (!resolvedEndpointId) notFound();
|
||||
|
||||
try {
|
||||
await api.docker.logs({ endpointId, id: containerId, tail: 1 });
|
||||
await api.docker.logs({ endpointId: resolvedEndpointId, id: containerId, tail: 1 });
|
||||
} catch {
|
||||
notFound();
|
||||
}
|
||||
@@ -41,8 +42,17 @@ export default async function DockerContainerLogsPage({ params, searchParams }:
|
||||
/>
|
||||
</Group>
|
||||
<Box style={{ borderRadius: 6 }} h={fullHeightWithoutHeaderAndFooter} p="md" bg="black">
|
||||
<ClientSideDockerLogsTerminal endpointId={endpointId} containerId={containerId} />
|
||||
<ClientSideDockerLogsTerminal endpointId={resolvedEndpointId} containerId={containerId} />
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const getOnlyDockerEndpointIdAsync = async () => {
|
||||
try {
|
||||
const { endpoints } = await api.docker.getContainers();
|
||||
return endpoints.length === 1 ? endpoints[0]?.id : undefined;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
+10
-48
@@ -4,69 +4,31 @@ export type ResponseFixtureId = "loading" | "success" | "failure";
|
||||
|
||||
export interface CatalogStateFixture {
|
||||
id: CatalogFixtureId;
|
||||
label: string;
|
||||
status: string;
|
||||
description: string;
|
||||
color: "green" | "yellow" | "gray" | "red";
|
||||
}
|
||||
|
||||
export const catalogStateFixtures: readonly CatalogStateFixture[] = [
|
||||
{
|
||||
id: "ready",
|
||||
label: "Ready service",
|
||||
status: "Ready",
|
||||
description: "Configured and available to three widgets.",
|
||||
color: "green",
|
||||
},
|
||||
{
|
||||
id: "needsSetup",
|
||||
label: "Service needing setup",
|
||||
status: "Needs setup",
|
||||
description: "Credentials or a service URL are still required.",
|
||||
color: "yellow",
|
||||
},
|
||||
{
|
||||
id: "noConnection",
|
||||
label: "Standalone feature",
|
||||
status: "No connection required",
|
||||
description: "This feature works without a configured integration.",
|
||||
color: "gray",
|
||||
},
|
||||
{
|
||||
id: "error",
|
||||
label: "Unreachable service",
|
||||
status: "Connection failed",
|
||||
description: "The saved connection could not be reached.",
|
||||
color: "red",
|
||||
},
|
||||
{ id: "ready", color: "green" },
|
||||
{ id: "needsSetup", color: "yellow" },
|
||||
{ id: "noConnection", color: "gray" },
|
||||
{ id: "error", color: "red" },
|
||||
];
|
||||
|
||||
export const catalogInteractionFixtures: readonly { id: CatalogInteractionId; label: string }[] = [
|
||||
{ id: "default", label: "Default" },
|
||||
{ id: "selected", label: "Selected" },
|
||||
{ id: "loading", label: "Loading" },
|
||||
{ id: "disabled", label: "Disabled" },
|
||||
export const catalogInteractionFixtures: readonly CatalogInteractionId[] = [
|
||||
"default",
|
||||
"selected",
|
||||
"loading",
|
||||
"disabled",
|
||||
];
|
||||
|
||||
export const responseStateFixtures = [
|
||||
{
|
||||
id: "loading",
|
||||
label: "Loading",
|
||||
title: "Checking response",
|
||||
description: "The parser is waiting for the integration response.",
|
||||
},
|
||||
{ id: "loading" },
|
||||
{
|
||||
id: "success",
|
||||
label: "Success",
|
||||
title: "Response accepted",
|
||||
description: "The upstream payload matched the integration contract.",
|
||||
payload: { status: "ok", service: "fixture-service", version: "2.0" },
|
||||
},
|
||||
{
|
||||
id: "failure",
|
||||
label: "Failure",
|
||||
title: "Response rejected",
|
||||
description: "The upstream payload failed schema validation and stays isolated from the widget.",
|
||||
payload: { status: 503, message: "Service unavailable" },
|
||||
},
|
||||
] as const;
|
||||
+15
@@ -10,6 +10,21 @@ import { FeatureStateWorkbench } from "./_feature-state-workbench";
|
||||
import { catalogStateFixtures, responseStateFixtures } from "./_feature-state-fixtures";
|
||||
import { getResponseContractFixtureResultsAsync } from "./_response-contract-fixtures";
|
||||
|
||||
vi.mock("@homarr/translation/client", () => ({
|
||||
useScopedI18n: () => (key: string) =>
|
||||
({
|
||||
"catalog.state.needsSetup.label": "Service needing setup",
|
||||
"catalog.state.needsSetup.status": "Needs setup",
|
||||
"catalog.interaction.loading": "Loading",
|
||||
"catalog.interaction.disabled": "Disabled",
|
||||
"response.state.failure.label": "Failure",
|
||||
"response.state.failure.title": "Response rejected",
|
||||
"response.contractPassed": "Fixture contract passed",
|
||||
"catalog.loadingAriaLabel": "Loading catalog item",
|
||||
"catalog.loading": "Loading",
|
||||
})[key] ?? key,
|
||||
}));
|
||||
|
||||
let root: Root;
|
||||
let host: HTMLDivElement;
|
||||
|
||||
|
||||
+36
-26
@@ -17,6 +17,7 @@ import {
|
||||
} from "@mantine/core";
|
||||
import { IconAlertCircle, IconCircleCheck, IconPlugConnected, IconPlugConnectedX } from "@tabler/icons-react";
|
||||
|
||||
import { useScopedI18n } from "@homarr/translation/client";
|
||||
import { CatalogItem } from "@homarr/ui";
|
||||
|
||||
import { catalogInteractionFixtures, catalogStateFixtures, responseStateFixtures } from "./_feature-state-fixtures";
|
||||
@@ -28,6 +29,7 @@ interface FeatureStateWorkbenchProps {
|
||||
}
|
||||
|
||||
export function FeatureStateWorkbench({ responseResults }: FeatureStateWorkbenchProps) {
|
||||
const t = useScopedI18n("featureWorkbench");
|
||||
const [catalogFixtureId, setCatalogFixtureId] = useState<CatalogFixtureId>("ready");
|
||||
const [interactionId, setInteractionId] = useState<CatalogInteractionId>("default");
|
||||
const [responseFixtureId, setResponseFixtureId] = useState<ResponseFixtureId>("loading");
|
||||
@@ -38,6 +40,8 @@ export function FeatureStateWorkbench({ responseResults }: FeatureStateWorkbench
|
||||
const busy = interactionId === "loading";
|
||||
const disabled = interactionId === "disabled";
|
||||
const selected = interactionId === "selected";
|
||||
const catalogLabel = t(`catalog.state.${catalogFixture.id}.label`);
|
||||
const catalogStatus = busy ? t("catalog.loading") : t(`catalog.state.${catalogFixture.id}.status`);
|
||||
|
||||
return (
|
||||
<Stack gap="xl" maw={960}>
|
||||
@@ -45,34 +49,40 @@ export function FeatureStateWorkbench({ responseResults }: FeatureStateWorkbench
|
||||
<Stack gap="lg">
|
||||
<div>
|
||||
<Title id="catalog-workbench-title" order={2} size="h3">
|
||||
Catalog item states
|
||||
{t("catalog.title")}
|
||||
</Title>
|
||||
<Text c="dimmed" size="sm" maw={680}>
|
||||
Compare the shared selection surface with stable service and interaction fixtures.
|
||||
{t("catalog.description")}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
<SimpleGrid cols={{ base: 1, sm: 2 }} spacing="md">
|
||||
<Stack gap="xs">
|
||||
<Text size="sm" fw={600} id="catalog-fixture-label">
|
||||
Service state
|
||||
{t("catalog.serviceState")}
|
||||
</Text>
|
||||
<SegmentedControl
|
||||
aria-labelledby="catalog-fixture-label"
|
||||
value={catalogFixtureId}
|
||||
onChange={(value) => setCatalogFixtureId(value as CatalogFixtureId)}
|
||||
data={catalogStateFixtures.map((fixture) => ({ value: fixture.id, label: fixture.status }))}
|
||||
data={catalogStateFixtures.map((fixture) => ({
|
||||
value: fixture.id,
|
||||
label: t(`catalog.state.${fixture.id}.status`),
|
||||
}))}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack gap="xs">
|
||||
<Text size="sm" fw={600} id="catalog-interaction-label">
|
||||
Interaction state
|
||||
{t("catalog.interactionState")}
|
||||
</Text>
|
||||
<SegmentedControl
|
||||
aria-labelledby="catalog-interaction-label"
|
||||
value={interactionId}
|
||||
onChange={(value) => setInteractionId(value as CatalogInteractionId)}
|
||||
data={catalogInteractionFixtures.map((fixture) => ({ value: fixture.id, label: fixture.label }))}
|
||||
data={catalogInteractionFixtures.map((id) => ({
|
||||
value: id,
|
||||
label: t(`catalog.interaction.${id}`),
|
||||
}))}
|
||||
/>
|
||||
</Stack>
|
||||
</SimpleGrid>
|
||||
@@ -80,15 +90,15 @@ export function FeatureStateWorkbench({ responseResults }: FeatureStateWorkbench
|
||||
<SimpleGrid cols={{ base: 1, xs: 2 }} spacing="md">
|
||||
<CatalogItem
|
||||
height={140}
|
||||
label={catalogFixture.label}
|
||||
status={busy ? "Loading" : catalogFixture.status}
|
||||
label={catalogLabel}
|
||||
status={catalogStatus}
|
||||
selected={selected}
|
||||
busy={busy}
|
||||
disabled={disabled}
|
||||
onSelect={() => setInteractionId(selected ? "default" : "selected")}
|
||||
>
|
||||
{busy ? (
|
||||
<Stack gap="sm" aria-label="Loading catalog item">
|
||||
<Stack gap="sm" aria-label={t("catalog.loadingAriaLabel")}>
|
||||
<Skeleton height={24} width="65%" />
|
||||
<Skeleton height={16} />
|
||||
<Skeleton height={20} width="40%" />
|
||||
@@ -105,15 +115,15 @@ export function FeatureStateWorkbench({ responseResults }: FeatureStateWorkbench
|
||||
</ThemeIcon>
|
||||
<Stack gap={2}>
|
||||
<Text fw={600} size="sm">
|
||||
{catalogFixture.label}
|
||||
{catalogLabel}
|
||||
</Text>
|
||||
<Text size="xs" c="dimmed">
|
||||
{catalogFixture.description}
|
||||
{t(`catalog.state.${catalogFixture.id}.description`)}
|
||||
</Text>
|
||||
</Stack>
|
||||
</Group>
|
||||
<Badge color={catalogFixture.color} variant="light" size="sm" w="fit-content">
|
||||
{catalogFixture.status}
|
||||
{t(`catalog.state.${catalogFixture.id}.status`)}
|
||||
</Badge>
|
||||
</Stack>
|
||||
)}
|
||||
@@ -121,13 +131,13 @@ export function FeatureStateWorkbench({ responseResults }: FeatureStateWorkbench
|
||||
|
||||
<Stack gap="xs" justify="center">
|
||||
<Text size="sm" fw={600}>
|
||||
Semantic output
|
||||
{t("catalog.semanticOutput")}
|
||||
</Text>
|
||||
<Code
|
||||
block
|
||||
>{`aria-label="${catalogFixture.label}, ${busy ? "Loading" : catalogFixture.status}"\naria-pressed=${selected}\ndisabled=${busy || disabled}\naria-busy=${busy}`}</Code>
|
||||
>{`aria-label="${catalogLabel}, ${catalogStatus}"\naria-pressed=${selected}\ndisabled=${busy || disabled}\naria-busy=${busy}`}</Code>
|
||||
<Text size="xs" c="dimmed">
|
||||
Tab to the item to inspect its visible focus ring. Select it with Enter or Space.
|
||||
{t("catalog.instructions")}
|
||||
</Text>
|
||||
</Stack>
|
||||
</SimpleGrid>
|
||||
@@ -138,23 +148,25 @@ export function FeatureStateWorkbench({ responseResults }: FeatureStateWorkbench
|
||||
<Stack gap="lg">
|
||||
<div>
|
||||
<Title id="response-workbench-title" order={2} size="h3">
|
||||
Integration response contract
|
||||
{t("response.title")}
|
||||
</Title>
|
||||
<Text c="dimmed" size="sm" maw={680}>
|
||||
Inspect waiting, accepted, and rejected response fixtures using the same parser contract as generated
|
||||
integrations.
|
||||
{t("response.description")}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
<SegmentedControl
|
||||
aria-label="Response fixture"
|
||||
aria-label={t("response.fixtureLabel")}
|
||||
value={responseFixtureId}
|
||||
onChange={(value) => setResponseFixtureId(value as ResponseFixtureId)}
|
||||
data={responseStateFixtures.map((fixture) => ({ value: fixture.id, label: fixture.label }))}
|
||||
data={responseStateFixtures.map((fixture) => ({
|
||||
value: fixture.id,
|
||||
label: t(`response.state.${fixture.id}.label`),
|
||||
}))}
|
||||
/>
|
||||
|
||||
{responseFixture.id === "loading" ? (
|
||||
<Stack gap="sm" role="status" aria-label="Checking response">
|
||||
<Stack component="output" gap="sm" aria-label={t("response.checking")}>
|
||||
<Group justify="space-between">
|
||||
<Skeleton height={22} width={180} />
|
||||
<Skeleton height={22} width={72} />
|
||||
@@ -165,16 +177,14 @@ export function FeatureStateWorkbench({ responseResults }: FeatureStateWorkbench
|
||||
<Alert
|
||||
color={responseFixture.id === "success" ? "green" : "red"}
|
||||
icon={responseFixture.id === "success" ? <IconCircleCheck /> : <IconAlertCircle />}
|
||||
title={responseFixture.title}
|
||||
title={t(`response.state.${responseFixture.id}.title`)}
|
||||
role={responseFixture.id === "failure" ? "alert" : "status"}
|
||||
>
|
||||
<Stack gap="sm">
|
||||
<Text size="sm">{responseFixture.description}</Text>
|
||||
<Text size="sm">{t(`response.state.${responseFixture.id}.description`)}</Text>
|
||||
<Code block>{JSON.stringify(responseFixture.payload, null, 2)}</Code>
|
||||
<Badge color={responseResult?.passed ? "green" : "red"} variant="light" w="fit-content">
|
||||
{responseResult?.passed
|
||||
? "Fixture contract passed"
|
||||
: (responseResult?.message ?? "Fixture contract failed")}
|
||||
{responseResult?.passed ? t("response.contractPassed") : t("response.contractFailed")}
|
||||
</Badge>
|
||||
</Stack>
|
||||
</Alert>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { notFound } from "next/navigation";
|
||||
import { Stack, Text, Title } from "@mantine/core";
|
||||
|
||||
import { auth } from "@homarr/auth/next";
|
||||
import { getScopedI18n } from "@homarr/translation/server";
|
||||
|
||||
import { FeatureStateWorkbench } from "./_feature-state-workbench";
|
||||
import { getResponseContractFixtureResultsAsync } from "./_response-contract-fixtures";
|
||||
@@ -10,15 +11,15 @@ export default async function FeatureWorkbenchPage() {
|
||||
if (process.env.NODE_ENV === "production") notFound();
|
||||
const session = await auth();
|
||||
if (!session?.user.permissions.includes("admin")) notFound();
|
||||
const t = await getScopedI18n("featureWorkbench.page");
|
||||
const responseResults = await getResponseContractFixtureResultsAsync();
|
||||
|
||||
return (
|
||||
<Stack gap="xl">
|
||||
<div>
|
||||
<Title>Native feature state workbench</Title>
|
||||
<Title>{t("title")}</Title>
|
||||
<Text c="dimmed" maw={720}>
|
||||
A development-only fixture surface for reviewing shared catalog and integration response states without live
|
||||
services.
|
||||
{t("description")}
|
||||
</Text>
|
||||
</div>
|
||||
<FeatureStateWorkbench responseResults={responseResults} />
|
||||
|
||||
+15
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||
import { Alert, Badge, Group, Select } from "@mantine/core";
|
||||
import { Alert, Badge, Button, Group, Select, Stack, Text } from "@mantine/core";
|
||||
import { useLocalStorage } from "@mantine/hooks";
|
||||
import { IconAlertTriangle } from "@tabler/icons-react";
|
||||
|
||||
@@ -14,7 +14,7 @@ export const KubernetesContextSelector = () => {
|
||||
const pathname = usePathname();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { data } = clientApi.kubernetes.contexts.getContexts.useQuery(undefined, {
|
||||
const { data, isError, refetch } = clientApi.kubernetes.contexts.getContexts.useQuery(undefined, {
|
||||
refetchInterval: 30_000,
|
||||
refetchOnMount: "always",
|
||||
refetchOnReconnect: true,
|
||||
@@ -40,6 +40,19 @@ export const KubernetesContextSelector = () => {
|
||||
router.replace(`${pathname}?${next.toString()}`);
|
||||
}, [contextId, pathname, requestedContextId, router, searchParams]);
|
||||
|
||||
if (isError) {
|
||||
return (
|
||||
<Alert color="red" icon={<IconAlertTriangle size={16} />} title={t("loadError.title")}>
|
||||
<Stack gap="sm">
|
||||
<Text size="sm">{t("loadError.message")}</Text>
|
||||
<Button variant="light" color="red" size="xs" w="fit-content" onClick={() => void refetch()}>
|
||||
{t("loadError.retry")}
|
||||
</Button>
|
||||
</Stack>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
if (!data || !contextId) return null;
|
||||
|
||||
const selectContext = (value: string | null) => {
|
||||
|
||||
@@ -46,7 +46,7 @@ describe("getAssistantWidgetConfiguration", () => {
|
||||
boardName: "Home",
|
||||
kind: "audioStats",
|
||||
summary: "Show audio statistics",
|
||||
integrationIds: ["navidrome-1", "audiobookshelf-1", "plex-1"],
|
||||
integrationIds: ["navidrome-private", "navidrome-1", "audiobookshelf-1", "plex-1"],
|
||||
},
|
||||
settings,
|
||||
[
|
||||
|
||||
@@ -66,7 +66,10 @@ export const BoardSetupChecklist = () => {
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
</Group>
|
||||
<Progress value={(progress.completedCount / progress.totalCount) * 100} aria-label={t("progress")} />
|
||||
<Progress
|
||||
value={progress.totalCount === 0 ? 0 : (progress.completedCount / progress.totalCount) * 100}
|
||||
aria-label={t("progress")}
|
||||
/>
|
||||
<ChecklistStep
|
||||
complete={progress.steps.content}
|
||||
label={t("step.content.label")}
|
||||
|
||||
@@ -86,6 +86,7 @@ const createItemLayouts = (
|
||||
? currentSection.layouts.find((layout) => layout.layoutId === layoutId)
|
||||
: undefined;
|
||||
const lane = currentSection.kind === "empty" ? getRootSectionLane(currentSection.xOffset) : "main";
|
||||
if (currentSection.kind === "container" && !containerLayout) return [];
|
||||
const columnCount = containerLayout?.width ?? (boardLayout ? getBoardLaneColumnCount(boardLayout, lane) : 0);
|
||||
if (columnCount === 0) return [];
|
||||
const size = {
|
||||
|
||||
@@ -169,6 +169,27 @@ describe("item actions create-item", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test("omits layouts where the requested container has no layout entry", () => {
|
||||
const board = new BoardMockBuilder()
|
||||
.addLayout({ id: "mobile", name: "Mobile", role: "mobile", columnCount: 3, breakpoint: 0 })
|
||||
.addEmptySection({ id: "canvas" })
|
||||
.addSection(
|
||||
new ContainerSectionMockBuilder({ id: "media" })
|
||||
.addLayout({ layoutId: "base", parentSectionId: "canvas", width: 4, height: 3 })
|
||||
.build(),
|
||||
)
|
||||
.build();
|
||||
const baseLayout = board.layouts.find((layout) => layout.role === "base");
|
||||
if (!baseLayout) throw new Error("Expected a base layout");
|
||||
baseLayout.id = "base";
|
||||
|
||||
const result = createItemCallback({ id: "calendar", kind: "clock", targetSectionId: "media" })(board);
|
||||
|
||||
expect(result.items.find((item) => item.id === "calendar")?.layouts).toEqual([
|
||||
expect.objectContaining({ layoutId: "base", sectionId: "media" }),
|
||||
]);
|
||||
});
|
||||
|
||||
test("sizes a new item for its requested rail and omits layouts where that rail is hidden", () => {
|
||||
const board = new BoardMockBuilder()
|
||||
.addLayout({ id: "mobile", name: "Mobile", role: "mobile", columnCount: 3, breakpoint: 0 })
|
||||
|
||||
@@ -15,11 +15,12 @@ describe("getBoardRecipeRecommendations", () => {
|
||||
preferredIntegrationKind: "jellyfin",
|
||||
});
|
||||
|
||||
expect(recommendations).toHaveLength(3);
|
||||
expect(recommendations.slice(0, 2).every(({ isNewlyAvailable }) => isNewlyAvailable)).toBe(true);
|
||||
expect(recommendations.at(2)).toEqual(
|
||||
expect.objectContaining({ integrationKind: "piHole", isNewlyAvailable: false }),
|
||||
);
|
||||
const firstFallbackIndex = recommendations.findIndex(({ isNewlyAvailable }) => !isNewlyAvailable);
|
||||
expect(recommendations.some(({ isNewlyAvailable }) => isNewlyAvailable)).toBe(true);
|
||||
if (firstFallbackIndex !== -1) {
|
||||
expect(recommendations.slice(0, firstFallbackIndex).every(({ isNewlyAvailable }) => isNewlyAvailable)).toBe(true);
|
||||
expect(recommendations.slice(firstFallbackIndex).every(({ isNewlyAvailable }) => !isNewlyAvailable)).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
test("does not recommend widget kinds already present on the board", () => {
|
||||
@@ -29,7 +30,8 @@ describe("getBoardRecipeRecommendations", () => {
|
||||
preferredIntegrationKind: "piHole",
|
||||
});
|
||||
|
||||
expect(recommendations.map(({ widgetKind }) => widgetKind)).toEqual(["dnsHoleControls"]);
|
||||
expect(recommendations.every(({ widgetKind }) => widgetKind !== "dnsHoleSummary")).toBe(true);
|
||||
expect(recommendations.every(({ integrationKind }) => integrationKind === "piHole")).toBe(true);
|
||||
});
|
||||
|
||||
test("deduplicates configured kinds and emitted widget capabilities", () => {
|
||||
@@ -39,7 +41,9 @@ describe("getBoardRecipeRecommendations", () => {
|
||||
limit: 10,
|
||||
});
|
||||
|
||||
expect(recommendations.map(({ widgetKind }) => widgetKind)).toEqual(["dnsHoleControls", "dnsHoleSummary"]);
|
||||
const widgetKinds = recommendations.map(({ widgetKind }) => widgetKind);
|
||||
expect(new Set(widgetKinds).size).toBe(widgetKinds.length);
|
||||
expect(recommendations.every(({ integrationKind }) => integrationKind === "piHole")).toBe(true);
|
||||
});
|
||||
|
||||
test("falls back to other configured integrations when the new service has no missing widgets", () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Avatar, Badge, Box, Button, Center, Divider, Group, Image, Select, Stack, Text, Tooltip } from "@mantine/core";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { IconApi } from "@tabler/icons-react";
|
||||
@@ -94,10 +94,16 @@ const ItemSelectModalContent = ({
|
||||
],
|
||||
[board.sections, currentLayout, mainCanvasSection, t],
|
||||
);
|
||||
const [targetSectionId, setTargetSectionId] = useState<string | null>(mainCanvasSection?.id ?? null);
|
||||
const [targetSectionId, setTargetSectionId] = useState<string | null>(placementOptions[0]?.value ?? null);
|
||||
const [loadingSelection, setLoadingSelection] = useState<string | null>(null);
|
||||
const selectionLock = useRef(false);
|
||||
const { createItem, removeItem } = useItemActions();
|
||||
|
||||
useEffect(() => {
|
||||
if (placementOptions.some(({ value }) => value === targetSectionId)) return;
|
||||
setTargetSectionId(placementOptions[0]?.value ?? null);
|
||||
}, [placementOptions, targetSectionId]);
|
||||
|
||||
const { openModal: openEditModal } = useModalAction(LazyWidgetEditModal);
|
||||
const { openModal: openIntegrationModal } = useModalAction(IntegrationSelectModal);
|
||||
const settings = useSettings();
|
||||
@@ -155,14 +161,32 @@ const ItemSelectModalContent = ({
|
||||
});
|
||||
};
|
||||
|
||||
const notifyCreated = (itemId: string, name: string) => {
|
||||
const notifyCreated = (updatedBoard: ReturnType<typeof createItem>, itemId: string, name: string) => {
|
||||
const createdItem = updatedBoard?.items.find((item) => item.id === itemId);
|
||||
if (!createdItem) {
|
||||
showErrorNotification({
|
||||
title: t("item.create.notification.error.title"),
|
||||
message: t("item.create.notification.error.message"),
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
const actualSectionId =
|
||||
createdItem.layouts.find(({ layoutId }) => layoutId === currentLayoutId)?.sectionId ??
|
||||
createdItem.layouts[0]?.sectionId;
|
||||
const actualDestination = placementOptions.find(({ value }) => value === actualSectionId)?.label;
|
||||
const wasRelocated = targetSectionId !== null && actualSectionId !== targetSectionId && actualDestination;
|
||||
const notificationId = `board-item-created:${itemId}`;
|
||||
showSuccessNotification({
|
||||
id: notificationId,
|
||||
title: t("item.create.notification.success.title"),
|
||||
message: (
|
||||
<Group justify="space-between" wrap="nowrap">
|
||||
<Text size="sm">{t("item.create.notification.success.message", { name })}</Text>
|
||||
<Text size="sm">
|
||||
{wasRelocated
|
||||
? t("item.create.notification.success.relocatedMessage", { name, destination: actualDestination })
|
||||
: t("item.create.notification.success.message", { name })}
|
||||
</Text>
|
||||
<Button
|
||||
variant="subtle"
|
||||
size="compact-xs"
|
||||
@@ -177,6 +201,7 @@ const ItemSelectModalContent = ({
|
||||
),
|
||||
autoClose: 10_000,
|
||||
});
|
||||
return true;
|
||||
};
|
||||
|
||||
const handleAddCustomWidget = async (customWidgetDefinition: NonNullable<typeof customWidgetDefs>[number]) => {
|
||||
@@ -204,7 +229,7 @@ const ItemSelectModalContent = ({
|
||||
integrationIds: [],
|
||||
},
|
||||
onSuccessfulEdit: ({ options: configuredOptions, advancedOptions }) => {
|
||||
createItem({
|
||||
const updatedBoard = createItem({
|
||||
id: itemId,
|
||||
kind: "customApi",
|
||||
integrationIds: [],
|
||||
@@ -212,7 +237,7 @@ const ItemSelectModalContent = ({
|
||||
targetSectionId: targetSectionId ?? undefined,
|
||||
advancedOptions,
|
||||
});
|
||||
notifyCreated(itemId, customWidgetDefinition.name);
|
||||
notifyCreated(updatedBoard, itemId, customWidgetDefinition.name);
|
||||
},
|
||||
integrationData: [],
|
||||
integrationSupport: false,
|
||||
@@ -247,8 +272,8 @@ const ItemSelectModalContent = ({
|
||||
ensureDataAsync: ensureIntegrationDataAsync,
|
||||
});
|
||||
|
||||
const maxIntegrations = (definition as { maxIntegrations?: number }).maxIntegrations ?? Infinity;
|
||||
const integrationIds = matchingIntegrations.slice(0, maxIntegrations).map((i) => i.id);
|
||||
const maxIntegrations = "maxIntegrations" in definition ? (definition.maxIntegrations ?? Infinity) : Infinity;
|
||||
const matchingIntegrationCount = Math.min(matchingIntegrations.length, maxIntegrations);
|
||||
const itemId = createId();
|
||||
const defaultOptions = reduceWidgetOptionsWithDefinition(definition, settings);
|
||||
const openEditor = (
|
||||
@@ -267,7 +292,7 @@ const ItemSelectModalContent = ({
|
||||
integrationIds: selectedIntegrationIds,
|
||||
},
|
||||
onSuccessfulEdit: ({ options, integrationIds: newIntegrationIds, advancedOptions }) => {
|
||||
createItem({
|
||||
const updatedBoard = createItem({
|
||||
id: itemId,
|
||||
kind,
|
||||
options,
|
||||
@@ -275,7 +300,7 @@ const ItemSelectModalContent = ({
|
||||
targetSectionId: targetSectionId ?? undefined,
|
||||
advancedOptions,
|
||||
});
|
||||
notifyCreated(itemId, t(`widget.${kind}.name`));
|
||||
if (!notifyCreated(updatedBoard, itemId, t(`widget.${kind}.name`))) return;
|
||||
trackSetup("widget-completed", {
|
||||
entryPoint: "board",
|
||||
intent: kind,
|
||||
@@ -295,7 +320,7 @@ const ItemSelectModalContent = ({
|
||||
const integrationsRequired =
|
||||
hasIntegrationSupport && (!("integrationsRequired" in definition) || definition.integrationsRequired !== false);
|
||||
|
||||
if (integrationsRequired && integrationIds.length === 0) {
|
||||
if (integrationsRequired && matchingIntegrationCount === 0) {
|
||||
trackSetup("dependency-blocked", {
|
||||
entryPoint: "board",
|
||||
intent: kind,
|
||||
|
||||
@@ -12,7 +12,15 @@ describe("SetupMetricProperties", () => {
|
||||
"hasBoardContext",
|
||||
"canResolveInline",
|
||||
] satisfies (keyof SetupMetricProperties)[];
|
||||
type ExpectedKey = (typeof allowedKeys)[number];
|
||||
type ActualKey = keyof SetupMetricProperties;
|
||||
const exactContract: [ActualKey] extends [ExpectedKey]
|
||||
? [ExpectedKey] extends [ActualKey]
|
||||
? true
|
||||
: false
|
||||
: false = true;
|
||||
|
||||
expect(exactContract).toBe(true);
|
||||
expect(allowedKeys).not.toContain("url");
|
||||
expect(allowedKeys).not.toContain("query");
|
||||
expect(allowedKeys).not.toContain("recordId");
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import { useCallback } from "react";
|
||||
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
import { showErrorNotification } from "@homarr/notifications";
|
||||
import { useI18n } from "@homarr/translation/client";
|
||||
|
||||
export type SetupMetricEvent =
|
||||
| "surface-opened"
|
||||
@@ -30,7 +32,15 @@ export interface SetupMetricProperties {
|
||||
* Never pass record IDs, names, URLs, search text, credentials, or provider responses here.
|
||||
*/
|
||||
export const useSetupAnalytics = () => {
|
||||
const { mutate } = clientApi.analytics.trackFeature.useMutation();
|
||||
const t = useI18n();
|
||||
const { mutate } = clientApi.analytics.trackFeature.useMutation({
|
||||
onError() {
|
||||
showErrorNotification({
|
||||
title: t("common.error"),
|
||||
message: t("universalCreate.analyticsError"),
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return useCallback(
|
||||
(event: SetupMetricEvent, properties: SetupMetricProperties) => {
|
||||
|
||||
@@ -173,6 +173,6 @@ export const UniversalCreateModal = createModal<UniversalCreateModalProps>(({ ac
|
||||
</Stack>
|
||||
);
|
||||
}).withOptions({
|
||||
defaultTitle: "universalCreate.title",
|
||||
defaultTitle: (t) => t("universalCreate.title"),
|
||||
size: "lg",
|
||||
});
|
||||
Reference in new issue
Block a user