feat: configure custom widget sources

This commit is contained in:
Thomas Camlong committed 2026-07-22 18:12:09 +02:00
1 parent 47cd7dda1f
commit e94b4d4bc9
43 files changed
+2361 -394

No files matched your search

@@ -91,13 +91,13 @@ const AUTHORING_PROMPT = `You are writing one safe Homarr Custom JSX v2 dashboar
Manifest contract:
${leanShape}
Sources are keyed by name and must include "default". Auth is "none", "bearer", "basic", {"type":"apiKeyHeader","name":"X-Api-Key"}, or {"type":"apiKeyQuery","name":"api_key"}. Never put credentials in the manifest.
Sources are keyed by name and must include "default". Auth is "none", "bearer", "basic", {"type":"apiKeyHeader","name":"X-Api-Key"}, or {"type":"apiKeyQuery","name":"api_key"}. Use the stable public API URL for public services and a clear suggested URL for self-hosted services; Homarr asks the installer for their own server URL. Never put credentials in the manifest.
Requests are keyed by ID. Defaults are source "default", kind "query", method "GET", query trigger "load", inherited auth, and permission "view" for queries or "modify" for actions. Actions are always manual. DELETE requires full permission and receives confirmation automatically. Use {option:name} or {"$option":"name"} for saved options. Use {param:name} or {"$param":"name"} only for invocation-time params supplied by SubFetch, ActionButton, or ToggleSwitch. Load queries cannot use params. Values and primitive types are inferred from references; do not declare parameters or option bindings. Paths and query values must be primitive; JSON bodies may bind structured options.
Options are keyed by name. Every option has label, control, and default. Controls: text, textarea, number, switch, select, multiSelect, slider, date, time, color, icon, url, duration, timeZone, json. Select choices use \`"choices": [{"label":"...","value":"..."}]\`. Dynamic choices must use \`"choicesFrom": {"request":"requestId","itemsPath":"optional.path","valuePath":"id","labelPath":"name"}\`, never an object under \`choices\`. Options are configured outside the widget and read through \`options.name\`; a bound control writes only to \`inputs.name\` and never changes an option.
JSX reads data.requestId, status.requestId, options.name, and temporary inputs.name. A status has loading, ok, status, statusText, and error. Use bind="search" on supported controls and inputs.search in params. SubFetch invokes a manual query. With trigger="manual", it renders its own load button; never author onClick or a fetch callback. Its child callback is (result, meta), where meta has ok, status, statusText, loading=false, and no error because SubFetch renders loading/error states itself. Use expression callbacks for map, filter, sort, and SubFetch. Do not use imports, hooks, refs, raw HTML, event callbacks, fetch, eval, bigint, npm packages, authored const blocks, IIFEs, or recursion. Regex is only for bounded string matching/replacement. Do not embed secrets.
JSX reads data.requestId, status.requestId, options.name, and temporary inputs.name. A status has loading, ok, status, statusText, and error. Use bind="search" on supported controls and inputs.search in params. SubFetch invokes a manual query. With trigger="manual", it renders its own load button; pass a card or image as triggerContent with triggerAriaLabel to make that content launch the request. Never author onClick or a fetch callback. Its child callback is (result, meta), where meta has ok, status, statusText, loading=false, and no error because SubFetch renders loading/error states itself. Use expression callbacks for map, filter, sort, and SubFetch. Do not use imports, hooks, refs, raw HTML, event callbacks, fetch, eval, bigint, npm packages, authored const blocks, IIFEs, or recursion. Regex is only for bounded string matching/replacement. Do not embed secrets.
Hard syntax rule: never write \`=> {\` anywhere. Every callback must be one concise expression, for example \`items.map(item => <Card key={item.id}>...</Card>)\`. Inline derived values directly, even when that repeats a short expression. Never use an IIFE to create local variables or branch; use JSX ternaries instead. Callback parameter names must not shadow the reserved roots \`data\`, \`status\`, \`options\`, or \`inputs\`.
@@ -123,9 +123,11 @@ export const CUSTOM_WIDGET_AUTHORING_PROMPT = AUTHORING_PROMPT;
export const CUSTOM_WIDGET_MCP_AUTHORING_PROMPT = `Author one Homarr Custom JSX v2 widget at a time.
Read the live schema and only the component resources needed for the design. Construct a credential-free widget, validate it, create a preview, test queries and simulated actions, visually inspect it, then create it. Request credentials through Homarr when needed and never repeat plaintext. The live resources are authoritative for this Homarr release.
Read the live schema and only the component resources needed for the design. Construct a credential-free widget, validate it, create a preview, test queries and simulated actions, visually inspect it, then create it. Configure deployment-specific source URLs and request credentials through Homarr when needed; never repeat plaintext. The live resources are authoritative for this Homarr release.
Use the lean keyed sources, requests, and options contract. Bind saved values directly with $option and invocation values with $param. Load queries cannot use $param. Keep the design responsive, accessible, theme-safe, loading-aware, empty-aware, and error-aware.`;
Use the lean keyed sources, requests, and options contract. Bind saved values directly with $option and invocation values with $param. Load queries cannot use $param. Keep the design responsive, accessible, theme-safe, loading-aware, empty-aware, and error-aware.
Use Workshop search/get/install when the user asks for an existing community widget. After installation, configure self-hosted source URLs and credentials with the dedicated source configuration tool or a secure user configuration request.`;
export function buildCustomWidgetMcpPrompt(request?: string | null, documentationUrl?: string | null) {
const sections = [CUSTOM_WIDGET_MCP_AUTHORING_PROMPT];
@@ -7,7 +7,7 @@ export const CUSTOM_WIDGET_SKILL_SOURCE_URL =
"https://github.com/homarr-labs/homarr/tree/HEAD/.agents/skills/homarr-custom-widget";
export const CUSTOM_WIDGET_SKILL_INSTALL_COMMAND =
"npx skills add https://github.com/homarr-labs/homarr --skill homarr-custom-widget";
export const CUSTOM_WIDGET_SKILL_VERSION = "2.0.0";
export const CUSTOM_WIDGET_SKILL_VERSION = "2.1.0";
export const CUSTOM_WIDGET_SKILL_MD = `---
name: homarr-custom-widget
@@ -21,17 +21,21 @@ Author one widget at a time. When connected to Homarr, retrieve \`homarr://custo
1. Read the API documentation.
2. Create one credential-free widget with keyed \`sources\`, keyed \`requests\`, optional keyed \`options\`, and safe JSX \`template\`.
3. Validate, preview, test queries and simulated actions, visually inspect, and iterate.
4. Request credentials through Homarr and never repeat plaintext.
4. Configure deployment-specific source URLs and request credentials through Homarr; never repeat plaintext.
5. Save only after narrow/wide, light/dark, loading, empty, error, and success states work.
Use \`{option:name}\` or \`$option\` for saved options. Use \`{param:name}\` or \`$param\` for values supplied by \`SubFetch\`, \`ActionButton\`, or \`ToggleSwitch\`. Load queries cannot use invocation parameters. Templates read \`data\`, \`status\`, \`options\`, and temporary \`inputs\`.
\`SubFetch\` with \`trigger="manual"\` renders its own load button. Its callback is \`(result, meta)\`; never author \`onClick\` or a fetch callback.
\`SubFetch\` with \`trigger="manual"\` renders its own load button. Pass a card or image through \`triggerContent\` with \`triggerAriaLabel\` when that content should launch the request. Its callback is \`(result, meta)\`; never author \`onClick\` or a fetch callback.
Use standard Mantine compound names and deliberate visual hierarchy, spacing, restrained semantic color, and responsive layouts. Avoid excessive nested cards.
Do not use imports, hooks, refs, raw HTML, raw event callbacks, browser requests, arbitrary functions, eval, bigint, npm packages, authored statement blocks, IIFEs, or recursion. Do not pretend MCP tools exist in an offline chat session.
To install an existing widget, use \`customWidget_workshopSearch\`, inspect it with \`customWidget_workshopGet\`, then use \`customWidget_workshopInstall\`. Configure each self-hosted source afterward with \`customWidget_sourceConfigure\`, or call \`customWidget_configurationRequestUser\` so the user can enter the server URL and credentials directly in Homarr.
Preview-scoped configuration expires with the preview. To persist user-entered values for a new widget, create the widget first, request configuration for its definition ID, then create a final preview with that definition ID so Homarr loads the stored credentials.
When this skill is installed from the repository, optional offline details are in \`references/schema.md\`, \`references/runtime.md\`, and \`references/security.md\`. MCP-only clients should use the live Homarr resources instead.
`;
@@ -5,4 +5,5 @@ export * from "./options";
export * from "./schema";
export * from "./schema-references";
export * from "./secret-requirements";
export * from "./source-setup";
export * from "./tabler-icons";
@@ -0,0 +1,96 @@
import type { CustomWidgetSource } from "./request-schema";
import { getCustomWidgetSourceUrlIssue } from "./request-schema";
import type { CustomWidgetSecretKind } from "./schema-types";
import { getCustomWidgetSecretRequirements } from "./secret-requirements";
export interface CustomWidgetConfiguredSecret {
sourceId: string;
kind: CustomWidgetSecretKind;
hasValue?: boolean;
value?: string;
}
export interface CustomWidgetSourceSetup {
sourceId: string;
sourceName: string;
suggestedBaseUrl: string;
baseUrl: string;
networkScope: CustomWidgetSource["networkScope"];
authType: "none" | "bearer" | "basic" | "apiKeyHeader" | "apiKeyQuery";
credentialFields: Array<{
kind: CustomWidgetSecretKind;
destination?: string;
configured: boolean;
}>;
requiresUrlConfirmation: boolean;
}
const placeholderHosts = new Set(["example.com", "example.org", "example.net"]);
export function isCustomWidgetSourceUrlPlaceholder(baseUrl: string) {
if (!URL.canParse(baseUrl)) return false;
const hostname = new URL(baseUrl).hostname.toLowerCase();
return (
placeholderHosts.has(hostname) ||
hostname.endsWith(".example.com") ||
hostname.endsWith(".example.org") ||
hostname.endsWith(".example.net") ||
/^(?:your-|replace-|change-me)/u.test(hostname)
);
}
export function customWidgetSourceRequiresUrlConfirmation(source: CustomWidgetSource) {
return source.networkScope !== "public" || isCustomWidgetSourceUrlPlaceholder(source.baseUrl);
}
export function hasSameCustomWidgetSourceAuthentication(left: CustomWidgetSource, right: CustomWidgetSource) {
if (typeof left.auth === "string" || typeof right.auth === "string") return left.auth === right.auth;
return left.auth.type === right.auth.type && left.auth.name === right.auth.name;
}
export function getCustomWidgetSourceSetups(
sources: Record<string, CustomWidgetSource>,
configuredSecrets: readonly CustomWidgetConfiguredSecret[] = [],
): CustomWidgetSourceSetup[] {
const requirements = getCustomWidgetSecretRequirements(sources);
return Object.entries(sources).map(([sourceId, source]) => {
const authType = typeof source.auth === "string" ? source.auth : source.auth.type;
return {
sourceId,
sourceName: source.name ?? sourceId,
suggestedBaseUrl: source.baseUrl,
baseUrl: source.baseUrl,
networkScope: source.networkScope,
authType,
credentialFields: requirements
.filter((requirement) => requirement.sourceId === sourceId)
.map((requirement) => ({
kind: requirement.kind,
destination: requirement.destination,
configured: configuredSecrets.some(
(secret) =>
secret.sourceId === sourceId &&
secret.kind === requirement.kind &&
(secret.hasValue === true || Boolean(secret.value?.trim())),
),
})),
requiresUrlConfirmation: customWidgetSourceRequiresUrlConfirmation(source),
};
});
}
export function applyCustomWidgetSourceSetup(
sources: Record<string, CustomWidgetSource>,
setup: Record<string, Pick<CustomWidgetSource, "baseUrl" | "networkScope">>,
) {
return Object.fromEntries(
Object.entries(sources).map(([sourceId, source]) => {
const configured = setup[sourceId];
return [sourceId, configured ? { ...source, ...configured } : source];
}),
);
}
export function getCustomWidgetSourceSetupIssue(source: Pick<CustomWidgetSourceSetup, "baseUrl">) {
return getCustomWidgetSourceUrlIssue(source.baseUrl);
}
@@ -5,6 +5,7 @@ import {
customWidgetRequestsSchema,
customWidgetSecretKinds,
customWidgetSourcesSchema,
hasSameCustomWidgetSourceAuthentication,
} from "../core";
import type { CustomJsxRequest, CustomWidgetOptions, CustomWidgetSource } from "../core";
import { CustomWidgetDomainError } from "./errors";
@@ -179,6 +180,40 @@ export class CustomWidgetPreviewSessionService {
return { id, expiresAt: next.expiresAt };
}
public async configureSource(
id: string,
userId: string,
sourceId: string,
source: CustomWidgetSource,
secrets: Array<{ sourceId: string; kind: (typeof customWidgetSecretKinds)[number]; value: string }>,
) {
const session = await this.get(id, userId);
const currentSource = session.sources[sourceId];
if (!currentSource) {
throw new CustomWidgetDomainError({ code: "NOT_FOUND", message: "Preview source was not found" });
}
if (!hasSameCustomWidgetSourceAuthentication(currentSource, source)) {
throw new CustomWidgetDomainError({
code: "BAD_REQUEST",
message: "Preview source authentication changed; create a new configuration request",
});
}
const replacements = new Set(secrets.map((secret) => `${secret.sourceId}:${secret.kind}`));
const next = {
...session,
sources: {
...session.sources,
[sourceId]: { ...currentSource, baseUrl: source.baseUrl, networkScope: source.networkScope },
},
secrets: [
...session.secrets.filter((secret) => !replacements.has(`${secret.sourceId}:${secret.kind}`)),
...secrets.map((secret) => ({ ...secret, value: this.options.encrypt(secret.value) })),
],
};
await this.save(next);
return { id, expiresAt: next.expiresAt };
}
private async save(session: CustomWidgetPreviewSession): Promise<void> {
const ttlMs = Math.max(0, session.expiresAt - this.now());
if (!ttlMs) throw new CustomWidgetDomainError({ code: "NOT_FOUND", message: "Preview session expired" });
@@ -66,4 +66,47 @@ describe("preview sessions", () => {
});
expect((await service.getJournal(created.id, "user"))[0]).toMatchObject({ path: "/data", status: 200 });
});
it("applies source deployment values without restoring stale source metadata", async () => {
let id = 0;
const service = new CustomWidgetPreviewSessionService({
createId: () => `id-${++id}`,
encrypt: String,
decrypt: String,
});
const created = await service.create({
userId: "user",
sources: definition.sources,
requests: definition.requests,
name: definition.name,
template: definition.template,
optionDefinitions: definition.options,
options: { limit: 10 },
secrets: [],
});
await service.configureSource(
created.id,
"user",
"default",
{ baseUrl: "http://service.local", networkScope: "private", auth: "bearer" },
[{ sourceId: "default", kind: "apiKey", value: "secret" }],
);
const configured = await service.get(created.id, "user");
expect(configured.sources.default).toEqual({
baseUrl: "http://service.local",
networkScope: "private",
auth: "bearer",
});
await expect(
service.configureSource(
created.id,
"user",
"default",
{ baseUrl: "http://service.local", networkScope: "private", auth: "none" },
[],
),
).rejects.toThrow("authentication changed");
});
});
@@ -6,6 +6,9 @@ import {
customJsxRequestSchema,
getCustomWidgetDefaultOptions,
getCustomWidgetSecretRequirements,
getCustomWidgetSourceSetups,
hasSameCustomWidgetSourceAuthentication,
applyCustomWidgetSourceSetup,
} from "../core";
describe("lean Custom Widget schema", () => {
@@ -82,6 +85,65 @@ describe("lean Custom Widget schema", () => {
).toEqual(["default:apiKey", "admin:username", "admin:password"]);
});
it("requires installation confirmation for private and placeholder source URLs", () => {
const sources = {
default: { baseUrl: "https://pokeapi.co/api/v2", networkScope: "public" as const, auth: "none" as const },
tautulli: {
name: "Tautulli",
baseUrl: "http://tautulli.local:8181",
networkScope: "private" as const,
auth: { type: "apiKeyQuery" as const, name: "apikey" },
},
placeholder: {
baseUrl: "https://api.example.com",
networkScope: "public" as const,
auth: "none" as const,
},
};
const setups = getCustomWidgetSourceSetups(sources);
expect(setups.map(({ sourceId, requiresUrlConfirmation }) => [sourceId, requiresUrlConfirmation])).toEqual([
["default", false],
["tautulli", true],
["placeholder", true],
]);
expect(setups.find(({ sourceId }) => sourceId === "tautulli")?.credentialFields).toEqual([
{ kind: "apiKey", destination: "apikey", configured: false },
]);
});
it("applies source setup without changing source authentication", () => {
const sources = {
default: {
baseUrl: "http://tautulli.local:8181",
networkScope: "private" as const,
auth: { type: "apiKeyQuery" as const, name: "apikey" },
},
};
expect(
applyCustomWidgetSourceSetup(sources, {
default: { baseUrl: "http://192.168.1.20:8181", networkScope: "private" },
}).default,
).toEqual({
baseUrl: "http://192.168.1.20:8181",
networkScope: "private",
auth: { type: "apiKeyQuery", name: "apikey" },
});
});
it("detects stale source authentication snapshots", () => {
const bearer = { baseUrl: "https://example.com", networkScope: "public" as const, auth: "bearer" as const };
expect(hasSameCustomWidgetSourceAuthentication(bearer, { ...bearer, baseUrl: "https://api.example.com" })).toBe(
true,
);
expect(hasSameCustomWidgetSourceAuthentication(bearer, { ...bearer, auth: "none" })).toBe(false);
expect(
hasSameCustomWidgetSourceAuthentication(
{ ...bearer, auth: { type: "apiKeyHeader", name: "X-API-Key" } },
{ ...bearer, auth: { type: "apiKeyHeader", name: "Authorization" } },
),
).toBe(false);
});
it("supports official Mantine compound names and separates bigint diagnostics", () => {
expect(
customWidgetDefinitionSchema.safeParse({
@@ -1,5 +1,6 @@
import type { ReactNode } from "react";
import { Alert, Badge, Button, Code, Group, Modal, Paper, SimpleGrid, Stack, Text } from "@mantine/core";
import type { ModalProps } from "@mantine/core";
import { IconAlertTriangle } from "@tabler/icons-react";
import type { ImportReview } from "../core/import";
@@ -24,8 +25,11 @@ export interface ImportReviewDialogProps {
opened: boolean;
review: ImportReview | null;
pending: boolean;
confirmDisabled?: boolean;
messages: ImportReviewMessages;
children?: ReactNode;
stackId?: string;
zIndex?: ModalProps["zIndex"];
onClose(): void;
onConfirm(): void;
}
@@ -45,13 +49,24 @@ export function ImportReviewDialog({
opened,
review,
pending,
confirmDisabled,
messages,
children,
stackId,
zIndex,
onClose,
onConfirm,
}: ImportReviewDialogProps) {
return (
<Modal opened={opened} onClose={onClose} title={messages.title} centered size="lg">
<Modal
opened={opened}
onClose={onClose}
title={messages.title}
centered
size="lg"
stackId={stackId}
zIndex={zIndex}
>
{review && (
<Stack gap="md">
<Text size="sm" c="dimmed">
@@ -104,7 +119,7 @@ export function ImportReviewDialog({
<Button type="button" variant="default" onClick={onClose} disabled={pending}>
{messages.cancel}
</Button>
<Button type="button" onClick={onConfirm} loading={pending}>
<Button type="button" onClick={onConfirm} loading={pending} disabled={confirmDisabled}>
{messages.confirm}
</Button>
</Group>
@@ -12,6 +12,7 @@ export * from "./preview-diagnostics-panel";
export * from "./preview-header";
export * from "./preview-utils";
export * from "./request-references";
export * from "./source-setup";
export {
CUSTOM_WIDGET_AUTH_SECRET_FIELDS,
DEFAULT_CUSTOM_WIDGET_FORM_VALUES,
@@ -0,0 +1,189 @@
import { Alert, Badge, Checkbox, Group, PasswordInput, Select, Stack, Text, TextInput } from "@mantine/core";
import { IconCheck, IconKey, IconServer, IconX } from "@tabler/icons-react";
import type {
CustomWidgetSecretKind,
CustomWidgetSource,
CustomWidgetSourceSetup,
CustomWidgetSourceUrlIssue,
} from "../core";
import { getCustomWidgetSourceSetupIssue } from "../core";
export interface CustomWidgetSourceSetupValue {
baseUrl: string;
networkScope: CustomWidgetSource["networkScope"];
urlConfirmed: boolean;
secrets: Partial<Record<CustomWidgetSecretKind, string>>;
}
export interface CustomWidgetSourceSetupMessages {
title: string;
description: string;
suggestedUrl: string;
baseUrl: string;
networkScope: string;
authentication: string;
confirmUrl: string;
ready: string;
needsUrl: string;
credentialsMissing: string;
credentialsOptional: string;
configured: string;
secret(kind: CustomWidgetSecretKind): string;
urlError(issue: CustomWidgetSourceUrlIssue): string;
}
export interface CustomWidgetSourceSetupPanelProps {
setups: CustomWidgetSourceSetup[];
values: Record<string, CustomWidgetSourceSetupValue>;
messages: CustomWidgetSourceSetupMessages;
onChange(sourceId: string, value: CustomWidgetSourceSetupValue): void;
}
export function createCustomWidgetSourceSetupValues(
setups: readonly CustomWidgetSourceSetup[],
): Record<string, CustomWidgetSourceSetupValue> {
return Object.fromEntries(
setups.map((setup) => [
setup.sourceId,
{
baseUrl: setup.baseUrl,
networkScope: setup.networkScope,
urlConfirmed: !setup.requiresUrlConfirmation,
secrets: {} as Partial<Record<CustomWidgetSecretKind, string>>,
} satisfies CustomWidgetSourceSetupValue,
]),
);
}
export function isCustomWidgetSourceSetupReady(
setups: readonly CustomWidgetSourceSetup[],
values: Record<string, CustomWidgetSourceSetupValue>,
) {
return setups.every((setup) => {
const value = values[setup.sourceId];
return Boolean(value && !getCustomWidgetSourceSetupIssue(value) && value.urlConfirmed);
});
}
export function CustomWidgetSourceSetupPanel({
setups,
values,
messages,
onChange,
}: CustomWidgetSourceSetupPanelProps) {
if (setups.length === 0) return null;
return (
<Stack gap="sm">
<Alert icon={<IconServer size={16} />}>
<Text fw={600} size="sm">
{messages.title}
</Text>
<Text size="sm">{messages.description}</Text>
</Alert>
{setups.map((setup) => {
const value = values[setup.sourceId] ?? createCustomWidgetSourceSetupValues([setup])[setup.sourceId];
if (!value) return null;
const issue = getCustomWidgetSourceSetupIssue(value);
const missingCredentials = setup.credentialFields.filter(
(field) => !field.configured && !value.secrets[field.kind]?.trim(),
);
const urlReady = !issue && value.urlConfirmed;
return (
<Stack
key={setup.sourceId}
gap="sm"
p="md"
style={{
border: "1px solid var(--mantine-color-default-border)",
borderRadius: "var(--mantine-radius-md)",
}}
>
<Group justify="space-between" align="flex-start">
<div>
<Text fw={600}>{setup.sourceName}</Text>
<Text size="xs" c="dimmed">
{setup.sourceId}
</Text>
</div>
<Group gap="xs">
<Badge
variant="light"
color={urlReady ? "green" : "red"}
leftSection={urlReady ? <IconCheck size={11} /> : <IconX size={11} />}
>
{urlReady ? messages.ready : messages.needsUrl}
</Badge>
{missingCredentials.length > 0 && (
<Badge variant="light" color="yellow" leftSection={<IconKey size={11} />}>
{messages.credentialsMissing}
</Badge>
)}
</Group>
</Group>
<Text size="xs" c="dimmed">
{messages.suggestedUrl}: {setup.suggestedBaseUrl}
</Text>
<TextInput
label={messages.baseUrl}
type="url"
value={value.baseUrl}
error={issue ? messages.urlError(issue) : undefined}
onChange={(event) =>
onChange(setup.sourceId, { ...value, baseUrl: event.currentTarget.value, urlConfirmed: true })
}
/>
<Group grow align="start">
<Select
label={messages.networkScope}
data={["public", "private", "loopback"]}
value={value.networkScope}
allowDeselect={false}
onChange={(networkScope) =>
networkScope &&
onChange(setup.sourceId, {
...value,
networkScope: networkScope as CustomWidgetSource["networkScope"],
})
}
/>
<TextInput label={messages.authentication} value={setup.authType} readOnly />
</Group>
{setup.requiresUrlConfirmation && value.baseUrl === setup.suggestedBaseUrl && (
<Checkbox
checked={value.urlConfirmed}
label={messages.confirmUrl}
onChange={(event) => onChange(setup.sourceId, { ...value, urlConfirmed: event.currentTarget.checked })}
/>
)}
{setup.credentialFields.map((field) => {
const Input = field.kind === "username" ? TextInput : PasswordInput;
return (
<Input
key={field.kind}
label={messages.secret(field.kind)}
description={field.destination}
value={value.secrets[field.kind] ?? ""}
placeholder={field.configured ? messages.configured : undefined}
leftSection={<IconKey size={15} />}
autoComplete="off"
onChange={(event) =>
onChange(setup.sourceId, {
...value,
secrets: { ...value.secrets, [field.kind]: event.currentTarget.value },
})
}
/>
);
})}
{missingCredentials.length > 0 && (
<Text size="xs" c="yellow">
{messages.credentialsOptional}
</Text>
)}
</Stack>
);
})}
</Stack>
);
}