Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(web): map admin roles on desktop organizations and branding edits
Richie McIlroye6610bda54d2
diff --git a/apps/web/app/api/desktop/[...route]/organization-branding.ts b/apps/web/app/api/desktop/[...route]/organization-branding.tsindex ab78d4f0c..5380e87aa 100644--- a/apps/web/app/api/desktop/[...route]/organization-branding.ts+++ b/apps/web/app/api/desktop/[...route]/organization-branding.ts@@ -7,6 +7,10 @@ import {OrganizationHexColor,type OrganizationLogoUpdate,} from "@cap/web-api-contract";+import {+ getEffectiveOrganizationRole,+ normalizeOrganizationRole,+} from "@/lib/permissions/roles";export const EMPTY_ORGANIZATION_BRAND_COLORS = {primary: null,@@ -39,7 +43,7 @@ export type DesktopOrganizationRow = {tombstoneAt: Date | null;iconUrl: string | null;metadata: unknown;- role: "owner" | "member" | null;+ role: "owner" | "admin" | "member" | null;};export type DecodedOrganizationLogoUpdate =@@ -160,7 +164,7 @@ export function filterAccessibleOrganizationRows(return rows.filter((row) =>row.tombstoneAt === null &&- (row.ownerId === userId || row.role === "owner" || row.role === "member"),+ (row.ownerId === userId || normalizeOrganizationRole(row.role) !== null),);}@@ -170,14 +174,18 @@ export function toDesktopOrganization(iconUrl: string | null,): DesktopOrganization {const role =- row.ownerId === userId || row.role === "owner" ? "owner" : "member";+ getEffectiveOrganizationRole({+ userId,+ ownerId: row.ownerId,+ memberRole: row.role,+ }) ?? "member";return DesktopOrganizationSchema.parse({id: row.id,name: row.name,ownerId: row.ownerId,role,- canEditBrand: role === "owner",+ canEditBrand: role === "owner" || role === "admin",iconUrl,brandColors: organizationBrandColorsFromMetadata(row.metadata),});@@ -187,9 +195,12 @@ export function canEditOrganizationBranding(row: DesktopOrganizationRow,userId: string,) {- return (- row.tombstoneAt === null && (row.ownerId === userId || row.role === "owner")- );+ const role = getEffectiveOrganizationRole({+ userId,+ ownerId: row.ownerId,+ memberRole: row.role,+ });+ return row.tombstoneAt === null && (role === "owner" || role === "admin");}export function normalizeOrganizationBrandingPatchBody(diff --git a/apps/web/app/api/desktop/[...route]/root.ts b/apps/web/app/api/desktop/[...route]/root.tsindex 9ee5f729d..f2e9927e3 100644--- a/apps/web/app/api/desktop/[...route]/root.ts+++ b/apps/web/app/api/desktop/[...route]/root.ts@@ -505,7 +505,7 @@ app.patch(if (!canEditOrganizationBranding(row, user.id)) {return c.json(- { error: "Only organization owners can edit branding" },+ { error: "Only organization admins and owners can edit branding" },{ status: 403 },);}