Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(permission): add FullAccess permission and update permission handling logic

Victor Hugo dos Santosbf2da86437a5
diff --git a/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/OrgRoleWorkspaceRow.tsx b/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/OrgRoleWorkspaceRow.tsx
index 8fcd790de9..176ffb18dd 100644
--- a/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/OrgRoleWorkspaceRow.tsx
+++ b/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/OrgRoleWorkspaceRow.tsx
@@ -18,6 +18,7 @@ type Props = {
enum Permission {
NoAccess = "no-access",
+ FullAccess = "full-access",
Custom = "custom"
}
@@ -36,10 +37,14 @@ export const OrgRoleWorkspaceRow = ({ isEditable, control, setValue }: Props) =>
});
const selectedPermissionCategory = useMemo(() => {
- if (rule?.create || rule?.["request-access"]) {
- return Permission.Custom;
- }
- return Permission.NoAccess;
+ const actions = Object.keys(rule || {}) as Array<keyof typeof rule>;
+ const totalActions = PERMISSION_ACTIONS.length;
+ const score = actions.map((key) => (rule?.[key] ? 1 : 0)).reduce((a, b) => a + b, 0 as number);
+
+ if (isCustom) return Permission.Custom;
+ if (score === 0) return Permission.NoAccess;
+ if (score === totalActions) return Permission.FullAccess;
+ return Permission.Custom;
}, [rule, isCustom]);
useEffect(() => {
@@ -63,12 +68,29 @@ export const OrgRoleWorkspaceRow = ({ isEditable, control, setValue }: Props) =>
}
setIsCustom.off();
- if (val === Permission.NoAccess) {
- setValue(
- "permissions.project",
- { create: false, "request-access": false },
- { shouldDirty: true }
- );
+ switch (val) {
+ case Permission.NoAccess:
+ setValue(
+ "permissions.project",
+ {
+ [OrgPermissionProjectActions.Create]: false,
+ [OrgPermissionProjectActions.RequestAccess]: false
+ },
+ { shouldDirty: true }
+ );
+ break;
+ case Permission.FullAccess:
+ setValue(
+ "permissions.project",
+ {
+ [OrgPermissionProjectActions.Create]: true,
+ [OrgPermissionProjectActions.RequestAccess]: true
+ },
+ { shouldDirty: true }
+ );
+ break;
+ default:
+ break;
}
};
@@ -92,6 +114,7 @@ export const OrgRoleWorkspaceRow = ({ isEditable, control, setValue }: Props) =>
position="popper"
>
<SelectItem value={Permission.NoAccess}>No Access</SelectItem>
+ <SelectItem value={Permission.FullAccess}>Full Access</SelectItem>
<SelectItem value={Permission.Custom}>Custom</SelectItem>
</Select>
</Td>
@@ -119,7 +142,7 @@ export const OrgRoleWorkspaceRow = ({ isEditable, control, setValue }: Props) =>
}
field.onChange(e);
}}
- id={`permissions.organization-admin-console.${action}`}
+ id={`permissions.project.${action}`}
>
{label}
</Checkbox>