mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 13:27:46 +00:00
Improve Audit Log Org Permission Label
This commit is contained in:
-19
@@ -18,8 +18,6 @@ type Props = {
|
|||||||
|
|
||||||
enum Permission {
|
enum Permission {
|
||||||
NoAccess = "no-access",
|
NoAccess = "no-access",
|
||||||
ReadOnly = "read-only",
|
|
||||||
FullAccess = "full-access",
|
|
||||||
Custom = "custom"
|
Custom = "custom"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,13 +39,10 @@ export const OrgPermissionAuditLogsRow = ({ isEditable, control, setValue }: Pro
|
|||||||
|
|
||||||
const selectedPermissionCategory = useMemo(() => {
|
const selectedPermissionCategory = useMemo(() => {
|
||||||
const actions = Object.keys(rule || {}) as Array<keyof typeof rule>;
|
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);
|
const score = actions.map((key) => (rule?.[key] ? 1 : 0)).reduce((a, b) => a + b, 0 as number);
|
||||||
|
|
||||||
if (isCustom) return Permission.Custom;
|
if (isCustom) return Permission.Custom;
|
||||||
if (score === 0) return Permission.NoAccess;
|
if (score === 0) return Permission.NoAccess;
|
||||||
if (score === totalActions) return Permission.FullAccess;
|
|
||||||
if (score === 1 && rule?.[OrgPermissionAuditLogsActions.Read]) return Permission.ReadOnly;
|
|
||||||
|
|
||||||
return Permission.Custom;
|
return Permission.Custom;
|
||||||
}, [rule, isCustom]);
|
}, [rule, isCustom]);
|
||||||
@@ -74,18 +69,6 @@ export const OrgPermissionAuditLogsRow = ({ isEditable, control, setValue }: Pro
|
|||||||
setIsCustom.off();
|
setIsCustom.off();
|
||||||
|
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case Permission.FullAccess:
|
|
||||||
case Permission.ReadOnly:
|
|
||||||
// For audit logs, both full access and read-only are the same - just read access
|
|
||||||
setValue(
|
|
||||||
"permissions.audit-logs",
|
|
||||||
{
|
|
||||||
[OrgPermissionAuditLogsActions.Read]: true
|
|
||||||
},
|
|
||||||
{ shouldDirty: true }
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Permission.NoAccess:
|
case Permission.NoAccess:
|
||||||
default:
|
default:
|
||||||
setValue(
|
setValue(
|
||||||
@@ -118,8 +101,6 @@ export const OrgPermissionAuditLogsRow = ({ isEditable, control, setValue }: Pro
|
|||||||
position="popper"
|
position="popper"
|
||||||
>
|
>
|
||||||
<SelectItem value={Permission.NoAccess}>No Access</SelectItem>
|
<SelectItem value={Permission.NoAccess}>No Access</SelectItem>
|
||||||
<SelectItem value={Permission.ReadOnly}>Read Only</SelectItem>
|
|
||||||
<SelectItem value={Permission.FullAccess}>Full Access</SelectItem>
|
|
||||||
<SelectItem value={Permission.Custom}>Custom</SelectItem>
|
<SelectItem value={Permission.Custom}>Custom</SelectItem>
|
||||||
</Select>
|
</Select>
|
||||||
</Td>
|
</Td>
|
||||||
|
|||||||
Reference in New Issue
Block a user