Skip to content

Commit 4db6430

Browse files
committed
Revert "fix: remove fallback permssions on organization Id. (#22769)"
This reverts commit 30061c0. Removes the manage permission concept and fallback logic to simplify permission checking back to direct role-based checks.
1 parent ebeb008 commit 4db6430

7 files changed

Lines changed: 20 additions & 411 deletions

File tree

apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/roles/_components/__tests__/usePermissions.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,5 @@ describe("usePermissions", () => {
4444

4545
expect(getResourcePermissionLevel("eventType", permissions)).toBe("all");
4646
});
47-
48-
it("should return 'all' for resource with manage permission", () => {
49-
const permissions = ["eventType.manage"];
50-
51-
expect(getResourcePermissionLevel("eventType", permissions)).toBe("all");
52-
});
53-
54-
it("should return 'all' for resource with manage permission even if other permissions are missing", () => {
55-
const permissions = ["eventType.manage", "eventType.read"]; // Has manage and read, but missing create, update, delete
56-
57-
expect(getResourcePermissionLevel("eventType", permissions)).toBe("all");
58-
});
5947
});
6048
});

apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/roles/_components/usePermissions.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,14 @@ export function usePermissions(): UsePermissionsReturn {
5151
return "all";
5252
}
5353

54-
// Check if user has manage permission for this resource
55-
const hasManagePermission = permissions.includes(`${resource}.manage`);
56-
if (hasManagePermission) {
57-
return "all";
58-
}
59-
60-
// Filter out internal keys like _resource and manage when checking for individual permissions
61-
const crudPermissions = Object.keys(resourceConfig)
62-
.filter((action) => !action.startsWith("_") && action !== "manage")
54+
// Filter out internal keys like _resource when checking permissions
55+
const allResourcePerms = Object.keys(resourceConfig)
56+
.filter((action) => !action.startsWith("_"))
6357
.map((action) => `${resource}.${action}`);
64-
const hasAllCrudPerms = crudPermissions.every((p) => permissions.includes(p));
58+
const hasAllPerms = allResourcePerms.every((p) => permissions.includes(p));
6559
const hasReadPerm = permissions.includes(`${resource}.${CrudAction.Read}`);
6660

67-
if (hasAllCrudPerms) return "all";
61+
if (hasAllPerms) return "all";
6862
if (hasReadPerm) return "read";
6963
return "none";
7064
};

apps/web/public/static/locales/en/common.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,7 +3320,6 @@
33203320
"pbac_desc_view_roles": "View roles",
33213321
"pbac_desc_update_roles": "Update roles",
33223322
"pbac_desc_delete_roles": "Delete roles",
3323-
"pbac_desc_manage_roles": "All actions on roles across organization teams",
33243323
"pbac_desc_create_workflows": "Create and set up new workflows",
33253324
"pbac_desc_view_workflows": "View existing workflows and their configurations",
33263325
"pbac_desc_update_workflows": "Edit and modify workflow settings",
@@ -3330,15 +3329,15 @@
33303329
"pbac_desc_view_event_types": "View event types",
33313330
"pbac_desc_update_event_types": "Update event types",
33323331
"pbac_desc_delete_event_types": "Delete event types",
3333-
"pbac_desc_manage_event_types": "All actions on event types across organization teams",
3332+
"pbac_desc_manage_event_types": "All actions on event types",
33343333
"pbac_desc_create_teams": "Create teams",
33353334
"pbac_desc_view_team_details": "View team details",
33363335
"pbac_desc_update_team_settings": "Update team settings",
33373336
"pbac_desc_delete_team": "Delete team",
33383337
"pbac_desc_invite_team_members": "Invite team members",
33393338
"pbac_desc_remove_team_members": "Remove team members",
33403339
"pbac_desc_change_team_member_role": "Change role of team members",
3341-
"pbac_desc_manage_teams": "All actions on teams across organization teams",
3340+
"pbac_desc_manage_teams": "All actions on teams",
33423341
"pbac_desc_create_organization": "Create organization",
33433342
"pbac_desc_view_organization_details": "View organization details",
33443343
"pbac_desc_list_organization_members": "List organization members",
@@ -3353,7 +3352,7 @@
33533352
"pbac_desc_view_organization_bookings": "View organization bookings",
33543353
"pbac_desc_view_booking_recordings": "View booking recordings",
33553354
"pbac_desc_update_bookings": "Update bookings",
3356-
"pbac_desc_manage_bookings": "All actions on bookings across organization teams",
3355+
"pbac_desc_manage_bookings": "All actions on bookings",
33573356
"pbac_desc_view_team_insights": "View team insights",
33583357
"pbac_desc_manage_team_insights": "Manage team insights",
33593358
"read_permission_auto_enabled_tooltip": "Read permission is automatically enabled when creating, updating, or deleting a resource",

packages/features/pbac/domain/types/permission-registry.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export enum CrudAction {
1717
Read = "read",
1818
Update = "update",
1919
Delete = "delete",
20-
Manage = "manage",
2120
}
2221

2322
export enum CustomAction {
@@ -142,13 +141,6 @@ export const PERMISSION_REGISTRY: PermissionRegistry = {
142141
i18nKey: "pbac_action_delete",
143142
descriptionI18nKey: "pbac_desc_delete_roles",
144143
},
145-
[CrudAction.Manage]: {
146-
description: "Manage roles on all sub-teams",
147-
category: "role",
148-
i18nKey: "pbac_action_manage",
149-
descriptionI18nKey: "pbac_desc_manage_roles",
150-
scope: [Scope.Organization], // Only organizations should have "Manage" permissions
151-
},
152144
},
153145
[Resource.EventType]: {
154146
_resource: {
@@ -178,13 +170,6 @@ export const PERMISSION_REGISTRY: PermissionRegistry = {
178170
i18nKey: "pbac_action_delete",
179171
descriptionI18nKey: "pbac_desc_delete_event_types",
180172
},
181-
[CrudAction.Manage]: {
182-
description: "Manage event types",
183-
category: "event",
184-
i18nKey: "pbac_action_manage",
185-
descriptionI18nKey: "pbac_desc_manage_event_types",
186-
scope: [Scope.Organization], // Only organizations should have "Manage" permissions
187-
},
188173
},
189174
[Resource.Team]: {
190175
_resource: {
@@ -233,13 +218,6 @@ export const PERMISSION_REGISTRY: PermissionRegistry = {
233218
i18nKey: "pbac_action_change_member_role",
234219
descriptionI18nKey: "pbac_desc_change_team_member_role",
235220
},
236-
[CrudAction.Manage]: {
237-
description: "Manage team members",
238-
category: "team",
239-
i18nKey: "pbac_action_manage",
240-
descriptionI18nKey: "pbac_desc_manage_team_members",
241-
scope: [Scope.Organization], // Only organizations should have "Manage" permissions
242-
},
243221
},
244222
[Resource.Organization]: {
245223
_resource: {
@@ -338,13 +316,6 @@ export const PERMISSION_REGISTRY: PermissionRegistry = {
338316
i18nKey: "pbac_action_update",
339317
descriptionI18nKey: "pbac_desc_update_bookings",
340318
},
341-
[CrudAction.Manage]: {
342-
description: "Manage bookings",
343-
category: "booking",
344-
i18nKey: "pbac_action_manage",
345-
descriptionI18nKey: "pbac_desc_manage_bookings",
346-
scope: [Scope.Organization], // Only organizations should have "Manage" permissions
347-
},
348319
},
349320
[Resource.Insights]: {
350321
_resource: {

0 commit comments

Comments
 (0)