Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -0,0 +1,62 @@
import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/react";
import { MemoryRouter } from "react-router";
import { afterEach, describe, expect, it, vi } from "vitest";
let mockedPermissions = ["admin.metrics.view"];
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (value: string) => value }),
}));
vi.mock("~/utils/data/useAdminData", () => ({
useAdminData: () => ({
isSuperAdmin: false,
permissions: mockedPermissions,
}),
}));
import { AdminOperationsShell } from "./AdminOperationsShell";
function expectOperationsLink(name: RegExp, href: string) {
expect(screen.getAllByRole("link", { name }).some((link) => link.getAttribute("href") === href)).toBe(true);
}
describe("AdminOperationsShell", () => {
afterEach(() => {
mockedPermissions = ["admin.metrics.view"];
});
it("shows the overview and technical operation routes for metrics access", () => {
render(
<MemoryRouter initialEntries={["/system"]}>
<AdminOperationsShell>
<div>content</div>
</AdminOperationsShell>
</MemoryRouter>
);
expectOperationsLink(/shared\.overview/, "/system");
expectOperationsLink(/admin\.health\.subsystems\.system\.label/, "/system/health");
expectOperationsLink(/admin\.health\.subsystems\.deploy\.label/, "/system/deploys");
expectOperationsLink(/admin\.health\.subsystems\.queues\.label/, "/system/jobs");
expect(screen.queryByRole("link", { name: /admin\.health\.subsystems\.webhooks\.label/ })).not.toBeInTheDocument();
expect(screen.queryByRole("link", { name: /admin\.health\.subsystems\.billing\.label/ })).not.toBeInTheDocument();
});
it("shows Webhook Inbox and Billing-Sync only with their matching permissions", () => {
mockedPermissions = ["admin.events.view", "admin.account.subscription"];
render(
<MemoryRouter initialEntries={["/system/webhooks"]}>
<AdminOperationsShell>
<div>content</div>
</AdminOperationsShell>
</MemoryRouter>
);
expectOperationsLink(/admin\.health\.subsystems\.webhooks\.label/, "/system/webhooks");
expectOperationsLink(/admin\.health\.subsystems\.billing\.label/, "/system/billing");
expect(screen.queryByRole("link", { name: /shared\.overview/ })).not.toBeInTheDocument();
});
});
@@ -0,0 +1,85 @@
import type { ReactNode } from "react";
import { useTranslation } from "react-i18next";
import {
FeatherActivity,
FeatherCreditCard,
FeatherHeartPulse,
FeatherRadioTower,
FeatherRocket,
FeatherServer,
} from "@subframe/core";
import type { DefaultPermission } from "~/application/dtos/shared/DefaultPermissions";
import SidebarIconsLayout, { type IconDto } from "~/components/ui/layouts/SidebarIconsLayout";
import { ADMIN_AREA_ACCESS } from "~/services/admin/admin-access-contract";
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
import { useAdminData } from "~/utils/data/useAdminData";
import { getUserHasPermission } from "~/utils/helpers/PermissionsHelper";
type AdminOperationsNavigationItem = IconDto & {
permission: DefaultPermission;
};
function identifiedIcon(id: string, icon: ReactNode): ReactNode {
return <span data-ui-id={id}>{icon}</span>;
}
export function AdminOperationsShell({ children }: { children: ReactNode }) {
const { t } = useTranslation();
const adminData = useAdminData();
const routePath = (path: string) => adminPath(path, { mode: "host-aware" });
const items: AdminOperationsNavigationItem[] = [
{
name: t("shared.overview"),
href: routePath("system"),
exact: true,
icon: identifiedIcon("ui.nav.admin.operations.overview", <FeatherActivity className="size-5" aria-hidden="true" />),
iconSelected: identifiedIcon("ui.nav.admin.operations.overview", <FeatherActivity className="size-5" aria-hidden="true" />),
permission: ADMIN_AREA_ACCESS.health,
},
{
name: t("admin.health.subsystems.system.label"),
href: routePath("system/health"),
icon: identifiedIcon("ui.nav.admin.operations.system", <FeatherServer className="size-5" aria-hidden="true" />),
iconSelected: identifiedIcon("ui.nav.admin.operations.system", <FeatherServer className="size-5" aria-hidden="true" />),
permission: ADMIN_AREA_ACCESS.system,
},
{
name: t("admin.health.subsystems.deploy.label"),
href: routePath("system/deploys"),
icon: identifiedIcon("ui.nav.admin.operations.deploys", <FeatherRocket className="size-5" aria-hidden="true" />),
iconSelected: identifiedIcon("ui.nav.admin.operations.deploys", <FeatherRocket className="size-5" aria-hidden="true" />),
permission: ADMIN_AREA_ACCESS.deploys,
},
{
name: t("admin.health.subsystems.queues.label"),
href: routePath("system/jobs"),
icon: identifiedIcon("ui.nav.admin.operations.jobs", <FeatherRadioTower className="size-5" aria-hidden="true" />),
iconSelected: identifiedIcon("ui.nav.admin.operations.jobs", <FeatherRadioTower className="size-5" aria-hidden="true" />),
permission: ADMIN_AREA_ACCESS.jobs,
},
{
name: t("admin.health.subsystems.webhooks.label"),
href: routePath("system/webhooks"),
icon: identifiedIcon("ui.nav.admin.operations.webhooks", <FeatherHeartPulse className="size-5" aria-hidden="true" />),
iconSelected: identifiedIcon("ui.nav.admin.operations.webhooks", <FeatherHeartPulse className="size-5" aria-hidden="true" />),
permission: "admin.events.view",
},
{
name: t("admin.health.subsystems.billing.label"),
href: routePath("system/billing"),
icon: identifiedIcon("ui.nav.admin.operations.billing", <FeatherCreditCard className="size-5" aria-hidden="true" />),
iconSelected: identifiedIcon("ui.nav.admin.operations.billing", <FeatherCreditCard className="size-5" aria-hidden="true" />),
permission: "admin.account.subscription",
},
];
const visibleItems = items.filter((item) => getUserHasPermission(adminData, item.permission));
return (
<SidebarIconsLayout items={visibleItems} sticky>
{children}
</SidebarIconsLayout>
);
}