File
Blob: src/shared/entitlements/site-publishing.ts
| 1 | import { isWorkspaceAdminOrOwnerRole, type ResolvedWorkspaceRole } from "@/shared/entitlements/common"; |
| 2 | |
| 3 | export interface SitePublishingEntitlements { |
| 4 | manageSite: boolean; |
| 5 | // Read-only access to a single page's publish status. Owner/admin manage |
| 6 | // publication; canonical non-guest members get this read so the ShareDialog |
| 7 | // Publish tab can render a badge and public URL without exposing site |
| 8 | // inventory or mutation paths. |
| 9 | viewPagePublishStatus: boolean; |
| 10 | } |
| 11 | |
| 12 | const ADMIN: SitePublishingEntitlements = { |
| 13 | manageSite: true, |
| 14 | viewPagePublishStatus: true, |
| 15 | }; |
| 16 | |
| 17 | const MEMBER: SitePublishingEntitlements = { |
| 18 | manageSite: false, |
| 19 | viewPagePublishStatus: true, |
| 20 | }; |
| 21 | |
| 22 | const DENY: SitePublishingEntitlements = { |
| 23 | manageSite: false, |
| 24 | viewPagePublishStatus: false, |
| 25 | }; |
| 26 | |
| 27 | export function getSitePublishingEntitlements(role: ResolvedWorkspaceRole): SitePublishingEntitlements { |
| 28 | if (isWorkspaceAdminOrOwnerRole(role)) return ADMIN; |
| 29 | if (role === "member") return MEMBER; |
| 30 | return DENY; |
| 31 | } |