diff --git a/shared/utils/scopeDefinitions.test.ts b/shared/utils/scopeDefinitions.test.ts index 5139645bb..0ac1f1ba8 100644 --- a/shared/utils/scopeDefinitions.test.ts +++ b/shared/utils/scopeDefinitions.test.ts @@ -599,15 +599,16 @@ describe("ROLE_SCOPES", () => { expect(ROLE_SCOPES.sales.length).toBe(7); }); - test("member contains all :read scopes, no :write", () => { - expect(ROLE_SCOPES.member.length).toBe(RESOURCES.length); + test("member contains expected :read scopes, no :write", () => { + expect(ROLE_SCOPES.member.length).toBe(RESOURCES.length - 1); for (const s of ROLE_SCOPES.member) { expect(s.endsWith(":read")).toBe(true); expect(s.endsWith(":write")).toBe(false); } - for (const r of RESOURCES) { + for (const r of RESOURCES.filter((r) => r !== "migrations")) { expect(ROLE_SCOPES.member).toContain(`${r}:read` as ScopeString); } + expect(ROLE_SCOPES.member).not.toContain(Scopes.Migrations.Read); }); }); diff --git a/shared/utils/scopeDefinitions.ts b/shared/utils/scopeDefinitions.ts index 1f9b50d32..616c405fb 100644 --- a/shared/utils/scopeDefinitions.ts +++ b/shared/utils/scopeDefinitions.ts @@ -402,7 +402,6 @@ export const ROLE_SCOPES: Record = { Scopes.Rewards.Read, Scopes.Balances.Read, Scopes.Billing.Read, - Scopes.Migrations.Read, Scopes.Analytics.Read, Scopes.ApiKeys.Read, Scopes.Platform.Read, diff --git a/vite/src/components/v2/selects/RoleSelect.tsx b/vite/src/components/v2/selects/RoleSelect.tsx index d8503614a..e21aa5fac 100644 --- a/vite/src/components/v2/selects/RoleSelect.tsx +++ b/vite/src/components/v2/selects/RoleSelect.tsx @@ -23,17 +23,17 @@ const ROLE_META: Record = { owner: { label: "Owner", description: - "Write on everything (organisation, customers, features, plans, rewards, balances, billing, API keys, platform) + read analytics. Can delete the org and manage ownership.", + "Write on everything (organisation, customers, features, plans, rewards, balances, billing, migrations, API keys, platform) + read analytics. Can delete the org and manage ownership.", }, admin: { label: "Admin", description: - "Write on everything (organisation, customers, features, plans, rewards, balances, billing, API keys, platform) + read analytics. Cannot delete the org or transfer ownership.", + "Write on everything (organisation, customers, features, plans, rewards, balances, billing, migrations, API keys, platform) + read analytics. Cannot delete the org or transfer ownership.", }, developer: { label: "Developer", description: - "Write on customers, features, plans, rewards, balances, billing, API keys, and platform. Read organisation and analytics.", + "Write on customers, features, plans, rewards, balances, billing, migrations, API keys, and platform. Read organisation and analytics.", }, sales: { label: "Sales", @@ -43,7 +43,7 @@ const ROLE_META: Record = { member: { label: "Member", description: - "Read-only on everything: organisation, customers, features, plans, rewards, balances, billing, analytics, API keys, platform. No write access.", + "Read-only on organisation, customers, features, plans, rewards, balances, billing, analytics, API keys, and platform. No migrations access.", }, }; diff --git a/vite/src/views/main-sidebar/MainSidebar.tsx b/vite/src/views/main-sidebar/MainSidebar.tsx index fff238e53..5ba4d0355 100644 --- a/vite/src/views/main-sidebar/MainSidebar.tsx +++ b/vite/src/views/main-sidebar/MainSidebar.tsx @@ -13,6 +13,7 @@ import { UsersIcon, WebhooksLogoIcon, } from "@phosphor-icons/react"; +import { Scopes } from "@autumn/shared"; import { PanelLeft } from "lucide-react"; import { useHotkeys } from "react-hotkeys-hook"; import { BetaBadge } from "@/components/v2/badges/BetaBadge"; @@ -23,7 +24,6 @@ import { useLocalStorage } from "@/hooks/common/useLocalStorage"; import { useScopes } from "@/hooks/useScopes"; import { cn } from "@/lib/utils"; import { useEnv } from "@/utils/envUtils"; -import { useAdmin } from "@/views/admin/hooks/useAdmin"; import { CollapsibleNavGroup } from "./CollapsibleNavGroup"; import { OrgDropdown } from "./components/OrgDropdown"; import { EnvDropdown } from "./EnvDropdown"; @@ -92,8 +92,8 @@ export const MainSidebar = ({ const flags = useAutumnFlags(); const { has } = useScopes(); - const { isAdmin } = useAdmin(); - const canSeeDev = has("apiKeys:read"); + const canSeeDev = has(Scopes.ApiKeys.Read); + const canSeeMigrations = has(Scopes.Migrations.Read); const [storedExpanded, setExpanded] = useLocalStorage( "sidebar.expanded", @@ -183,7 +183,7 @@ export const MainSidebar = ({ }, ]} /> - {isAdmin ? ( + {canSeeMigrations ? ( }