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
+19
-33
@@ -26,11 +26,6 @@ function rootData(tenantApiKeys = true, admin = false, routingConfig?: typeof ro
|
||||
function appData(options?: { admin?: boolean; permissions?: string[]; tenantApiKeys?: boolean }) {
|
||||
return {
|
||||
currentTenant: { id: "tenant_1", slug: "acme" },
|
||||
entities: [
|
||||
{ name: "company", titlePlural: "models.company.plural", slug: "companies", showInSidebar: true },
|
||||
{ name: "contact", titlePlural: "models.contact.plural", slug: "contacts", showInSidebar: true },
|
||||
{ name: "opportunity", titlePlural: "models.opportunity.plural", slug: "opportunities", showInSidebar: true },
|
||||
],
|
||||
myTenants: [{ id: "tenant_2", slug: "other" }],
|
||||
permissions: options?.permissions ?? [
|
||||
"app.settings.members.view",
|
||||
@@ -38,9 +33,6 @@ function appData(options?: { admin?: boolean; permissions?: string[]; tenantApiK
|
||||
"app.settings.account.view",
|
||||
"app.settings.apiKeys.view",
|
||||
"app.settings.auditTrails.view",
|
||||
"entity.company.view",
|
||||
"entity.contact.view",
|
||||
"entity.opportunity.view",
|
||||
],
|
||||
isSuperAdmin: false,
|
||||
user: { id: "user_1", admin: options?.admin ?? true },
|
||||
@@ -104,24 +96,6 @@ describe("command registry", () => {
|
||||
expect(actions.some((action) => action.id === "events")).toBe(false);
|
||||
});
|
||||
|
||||
it("filters tenant entity commands through permission-aware scope metadata", () => {
|
||||
const actions = getCommandRegistryActions({
|
||||
layout: "app",
|
||||
t,
|
||||
navigate: navigateMock(),
|
||||
appData: appData({ permissions: ["entity.company.view"] }),
|
||||
rootData: rootData(),
|
||||
});
|
||||
|
||||
expect(actions.find((action) => action.id === "entity-company")?.scope).toMatchObject({
|
||||
layout: "app",
|
||||
tenantSlug: "acme",
|
||||
permission: "entity.company.view",
|
||||
});
|
||||
expect(actions.some((action) => action.id === "entity-contact")).toBe(false);
|
||||
expect(actions.some((action) => action.id === "entity-opportunity")).toBe(false);
|
||||
});
|
||||
|
||||
it("omits CRM command while the CRM route tree is disabled", () => {
|
||||
const disabled = getCommandRegistryActions({
|
||||
layout: "app",
|
||||
@@ -197,9 +171,15 @@ describe("command registry", () => {
|
||||
expect(actions.every((action) => action.scope.layout === "admin")).toBe(true);
|
||||
});
|
||||
|
||||
it("builds admin commands with host-aware paths and app fallback switch", () => {
|
||||
it("builds admin commands with host-aware paths and tenant selector switch", () => {
|
||||
const navigate = navigateMock();
|
||||
const actions = getCommandRegistryActions({ layout: "admin", t, navigate, rootData: rootData(true, true) });
|
||||
const actions = getCommandRegistryActions({
|
||||
layout: "admin",
|
||||
t,
|
||||
navigate,
|
||||
rootData: rootData(true, true),
|
||||
appData: { ...appData({ admin: true, permissions: ["admin.accounts.view"] }), currentTenant: null, isSuperAdmin: true } as any,
|
||||
});
|
||||
|
||||
perform(actions.find((action) => action.id === "/dashboard")!);
|
||||
perform(actions.find((action) => action.id === "/settings/profile")!);
|
||||
@@ -207,7 +187,7 @@ describe("command registry", () => {
|
||||
|
||||
expect(navigate).toHaveBeenNthCalledWith(1, "/dashboard");
|
||||
expect(navigate).toHaveBeenNthCalledWith(2, "/settings/profile");
|
||||
expect(navigate).toHaveBeenNthCalledWith(3, "/");
|
||||
expect(navigate).toHaveBeenNthCalledWith(3, "/select-tenant");
|
||||
expect(actions.find((action) => action.id === "/dashboard")?.scope).toMatchObject({ layout: "admin", platform: true, adminOnly: true });
|
||||
expect(actions.find((action) => action.name === "admin.switchToApp")?.scope).toMatchObject({ layout: "admin", platform: true, adminOnly: true });
|
||||
expectNoLegacyPrefixes(navigate.mock.calls.map(([target]) => target));
|
||||
@@ -269,11 +249,17 @@ describe("command registry", () => {
|
||||
expect(actions.find((action) => action.id === "/settings/profile")?.subtitle).toBe("Settings");
|
||||
});
|
||||
|
||||
it("builds admin public-app commands with absolute app-host URLs when routing is configured", () => {
|
||||
it("builds admin tenant selector commands and public-app create URLs when routing is configured", () => {
|
||||
const navigate = navigateMock();
|
||||
const actions = getCommandRegistryActions({ layout: "admin", t, navigate, rootData: rootData(true, true, routing) });
|
||||
const actions = getCommandRegistryActions({
|
||||
layout: "admin",
|
||||
t,
|
||||
navigate,
|
||||
rootData: rootData(true, true, routing),
|
||||
appData: { ...appData({ admin: true, permissions: ["admin.accounts.view"] }), currentTenant: null, isSuperAdmin: true } as any,
|
||||
});
|
||||
|
||||
expect(actions.find((action) => action.name === "admin.switchToApp")?.id).toBe("https://app.example.test/");
|
||||
expect(actions.find((action) => action.name === "admin.switchToApp")?.id).toBe("/select-tenant");
|
||||
|
||||
vi.stubGlobal("window", undefined);
|
||||
try {
|
||||
@@ -283,7 +269,7 @@ describe("command registry", () => {
|
||||
vi.unstubAllGlobals();
|
||||
}
|
||||
|
||||
expect(navigate).toHaveBeenNthCalledWith(1, "https://app.example.test/");
|
||||
expect(navigate).toHaveBeenNthCalledWith(1, "/select-tenant");
|
||||
expect(navigate).toHaveBeenNthCalledWith(2, "https://app.example.test/new-account");
|
||||
});
|
||||
|
||||
|
||||
+1
-14
@@ -10,7 +10,6 @@ import { getDocCommands } from "~/utils/services/docsService";
|
||||
import { appPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { absoluteAdminPath, absoluteAppRootPath, isAbsoluteHttpUrl, type PublicDomainRoutingConfig } from "~/utils/app/CrossHostUrls";
|
||||
import { filterCommandActions } from "~/services/search/commandSearch";
|
||||
import { translateLabel } from "~/utils/i18n/translateLabel";
|
||||
|
||||
// Registry marker: services/command-registry paths are app-relative for package verification.
|
||||
export type CommandRegistryLayout = "app" | "admin" | "docs";
|
||||
@@ -70,7 +69,7 @@ function getUnfilteredCommandRegistryActions(context: CommandRegistryContext): S
|
||||
return getDocsCommandActions(context);
|
||||
}
|
||||
|
||||
function getAppCommandActions({ t, i18n, navigate, submitLogout, appData, rootData }: CommandRegistryContext): ScopedCommandAction[] {
|
||||
function getAppCommandActions({ t, navigate, submitLogout, appData, rootData }: CommandRegistryContext): ScopedCommandAction[] {
|
||||
if (!appData || !rootData) {
|
||||
return [];
|
||||
}
|
||||
@@ -89,18 +88,6 @@ function getAppCommandActions({ t, i18n, navigate, submitLogout, appData, rootDa
|
||||
},
|
||||
];
|
||||
|
||||
appData.entities
|
||||
.filter((entity) => entity.showInSidebar)
|
||||
.forEach((entity) => {
|
||||
const permission = typeof entity.name === "string" && entity.name.trim() ? `entity.${entity.name}.view` : undefined;
|
||||
actions.push({
|
||||
id: "entity-" + entity.name,
|
||||
name: translateLabel(t, i18n, entity.titlePlural),
|
||||
scope: tenantScope({ permission }),
|
||||
perform: () => navigate(tenantPath(entity.slug)),
|
||||
});
|
||||
});
|
||||
|
||||
actions.push({
|
||||
id: "profile",
|
||||
shortcut: [],
|
||||
|
||||
Reference in new issue
Block a user