Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+37
-8
@@ -3,25 +3,40 @@
|
||||
// Module off -> locked empty; missing integrations.read -> 404. Renders the
|
||||
// interim IntegrationsCatalogPage from ~/ui (AD-28); final optic = D-P5 delta.
|
||||
|
||||
import { type LoaderFunctionArgs, useLoaderData } from "react-router";
|
||||
import { redirect, type LoaderFunctionArgs, useLoaderData } from "react-router";
|
||||
import { buildIntegrationCatalogVM, integrationCategoryKey, type CatalogAppRow, type IntegrationCatalogVM } from "@hivegrid/view-models";
|
||||
import { INTEGRATION_CATALOG } from "@hivegrid/integrations";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { loadIntegrationsContext, integrationsHasPermission, notFoundResponse, requireIntegrationsPermission } from "~/utils/integrations/integrationsAccess.server";
|
||||
import {
|
||||
loadIntegrationsContext,
|
||||
integrationsHasPermission,
|
||||
notFoundResponse,
|
||||
requireIntegrationsPermission,
|
||||
} from "~/utils/integrations/integrationsAccess.server";
|
||||
import { listConnections } from "~/utils/integrations/appsEngineService.server";
|
||||
import { integrationsAppPath, INTEGRATIONS_MODULE_KEY } from "~/utils/integrations/integrationsRoutePaths";
|
||||
import { integrationsAppPath, INTEGRATIONS_MODULE_KEY, legacyIntegrationsRedirectPath } from "~/utils/integrations/integrationsRoutePaths";
|
||||
import { telephonySettingsPath } from "~/modules/telephony/routes/telephonyRoutePaths";
|
||||
import { calendarConnectionsPath } from "~/modules/calendar/routes/calendarRoutePaths";
|
||||
import { hasKwpIntegrationModule } from "~/modules/kwp/routes/kwpAccess.server";
|
||||
import { IntegrationsCatalogPage } from "~/components/screens/integrations/IntegrationsCatalogPage";
|
||||
import ServerError from "~/components/ui/errors/ServerError";
|
||||
|
||||
type LoaderData = { title: string; vm: IntegrationCatalogVM };
|
||||
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
const legacyRedirect = legacyIntegrationsRedirectPath(request.url, params.tenant ?? "");
|
||||
if (legacyRedirect) {
|
||||
throw redirect(legacyRedirect);
|
||||
}
|
||||
const { t } = await getTranslations(request);
|
||||
const ctx = await loadIntegrationsContext({ request, params });
|
||||
const tenantSlug = params.tenant ?? "";
|
||||
|
||||
if (!ctx.hasModule) {
|
||||
return Response.json({ title: `${t("integrations.catalog.title")} | ${process.env.APP_NAME}`, vm: buildIntegrationCatalogVM({ rows: [], canConnect: false }) } satisfies LoaderData);
|
||||
return Response.json({
|
||||
title: `${t("integrations.catalog.title")} | ${process.env.APP_NAME}`,
|
||||
vm: buildIntegrationCatalogVM({ rows: [], canConnect: false }),
|
||||
} satisfies LoaderData);
|
||||
}
|
||||
try {
|
||||
requireIntegrationsPermission(ctx, "integrations.read");
|
||||
@@ -30,20 +45,34 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
}
|
||||
|
||||
// Live connection counts per app (tenant-scoped, no credentials selected).
|
||||
const connections = await listConnections(ctx.tenantId);
|
||||
const [connections, hasKwpIntegration] = await Promise.all([
|
||||
listConnections(ctx.tenantId),
|
||||
hasKwpIntegrationModule(ctx),
|
||||
]);
|
||||
const countByApp = new Map<string, number>();
|
||||
for (const connection of connections) {
|
||||
countByApp.set(connection.appId, (countByApp.get(connection.appId) ?? 0) + 1);
|
||||
}
|
||||
|
||||
const rows: CatalogAppRow[] = INTEGRATION_CATALOG.map((app) => ({
|
||||
const rows: CatalogAppRow[] = INTEGRATION_CATALOG.filter(
|
||||
(app) => !app.internal && (app.key !== "kwp" || hasKwpIntegration),
|
||||
).map((app) => ({
|
||||
key: app.key,
|
||||
titleKey: app.titleKey,
|
||||
category: app.category,
|
||||
categoryKey: integrationCategoryKey(app.category),
|
||||
connectionType: app.connectionType,
|
||||
connectionCount: countByApp.get(app.key) ?? 0,
|
||||
detailHref: integrationsAppPath(tenantSlug, app.key),
|
||||
// Telephony providers and calendar have dedicated lifecycles (provider
|
||||
// setup, webhook authentication and optional user bindings; calendar:
|
||||
// per-user CalendarConnection rows via the Google OAuth flow) — link their
|
||||
// cards straight to those surfaces instead of generic DataConnection detail.
|
||||
detailHref:
|
||||
app.key === "aircall" || app.key === "hallopetra"
|
||||
? telephonySettingsPath(tenantSlug)
|
||||
: app.key === "google-calendar"
|
||||
? calendarConnectionsPath(tenantSlug)
|
||||
: integrationsAppPath(tenantSlug, app.key),
|
||||
}));
|
||||
|
||||
const vm = buildIntegrationCatalogVM({ rows, canConnect: integrationsHasPermission(ctx, "integrations.connect") });
|
||||
@@ -52,7 +81,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
|
||||
export default function IntegrationsCatalogRoute() {
|
||||
const { vm } = useLoaderData<LoaderData>();
|
||||
return <IntegrationsCatalogPage vm={vm} />;
|
||||
return <IntegrationsCatalogPage vm={vm} embedded />;
|
||||
}
|
||||
|
||||
export function ErrorBoundary() {
|
||||
|
||||
Reference in new issue
Block a user