Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+62
@@ -0,0 +1,62 @@
|
||||
// R-P5 (P5) §P3 — integrations catalog route. Loader builds IntegrationCatalogVM
|
||||
// from the code catalog (@hivegrid/integrations) + per-app live connection counts.
|
||||
// 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 { 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 { listConnections } from "~/utils/integrations/appsEngineService.server";
|
||||
import { integrationsAppPath, INTEGRATIONS_MODULE_KEY } from "~/utils/integrations/integrationsRoutePaths";
|
||||
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 { 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);
|
||||
}
|
||||
try {
|
||||
requireIntegrationsPermission(ctx, "integrations.read");
|
||||
} catch {
|
||||
throw notFoundResponse();
|
||||
}
|
||||
|
||||
// Live connection counts per app (tenant-scoped, no credentials selected).
|
||||
const connections = await listConnections(ctx.tenantId);
|
||||
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) => ({
|
||||
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),
|
||||
}));
|
||||
|
||||
const vm = buildIntegrationCatalogVM({ rows, canConnect: integrationsHasPermission(ctx, "integrations.connect") });
|
||||
return Response.json({ title: `${t("integrations.catalog.title")} | ${process.env.APP_NAME}`, vm } satisfies LoaderData);
|
||||
};
|
||||
|
||||
export default function IntegrationsCatalogRoute() {
|
||||
const { vm } = useLoaderData<LoaderData>();
|
||||
return <IntegrationsCatalogPage vm={vm} />;
|
||||
}
|
||||
|
||||
export function ErrorBoundary() {
|
||||
return <ServerError />;
|
||||
}
|
||||
|
||||
export const handle = { moduleKey: INTEGRATIONS_MODULE_KEY };
|
||||
Reference in new issue
Block a user