Add automatic Docker container discovery during onboarding to pre-select and pre-fill integrations. Introduce base URL templating with subdomain/port modes, API key settings path links, and a curated onboarding list that hides niche integrations (GitHub, npm, Docker Hub, etc.). Prevent duplicate widget seeding and remove the timetable widget from defaults.
31 lines
920 B
TypeScript
31 lines
920 B
TypeScript
import { integrationIconSlugs } from "./docker-integration-match";
|
|
import type { IntegrationKind } from "./integration";
|
|
import { getIntegrationDefaultPort } from "./integration";
|
|
|
|
export type UrlTemplateMode = "hostPort" | "subdomain";
|
|
|
|
const getSlugForKind = (kind: IntegrationKind): string =>
|
|
integrationIconSlugs[kind] ?? kind.toLowerCase();
|
|
|
|
export const buildIntegrationUrl = (
|
|
kind: IntegrationKind,
|
|
baseHost: string,
|
|
mode: UrlTemplateMode,
|
|
dockerPort?: number,
|
|
): string => {
|
|
const host = baseHost.trim().replace(/\/+$/, "");
|
|
if (!host) return "";
|
|
|
|
const slug = getSlugForKind(kind);
|
|
|
|
const modeBuilders: Record<UrlTemplateMode, () => string> = {
|
|
subdomain: () => `http://${slug}.${host}`,
|
|
hostPort: () => {
|
|
const port = dockerPort ?? getIntegrationDefaultPort(kind);
|
|
return port ? `http://${host}:${port}` : `http://${host}`;
|
|
},
|
|
};
|
|
|
|
return modeBuilders[mode]();
|
|
};
|