mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Implement checkbox for SchemaEdit permission in Access Rules UI.
Summary: - Introduces a fictitious "*SPECIAL:SchemaEdit" resource in UI only. - Hides "S" bit for the default rule section. - Shows a checkbox UI similar to other checkboxes, with an additional dismissable warning. Test Plan: Added a browser test Reviewers: paulfitz, georgegevoian Reviewed By: paulfitz, georgegevoian Differential Revision: https://phab.getgrist.com/D3765
This commit is contained in:
@@ -190,3 +190,25 @@ export function summarizePermissions(perms: MixedPermissionValue[]): MixedPermis
|
||||
const perm = perms[0];
|
||||
return perms.some(p => p !== perm) ? 'mixed' : perm;
|
||||
}
|
||||
|
||||
|
||||
function isEmpty(permissions: PartialPermissionSet): boolean {
|
||||
return Object.values(permissions).every(v => v === "");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Divide up a PartialPermissionSet into two: one containing only the 'schemaEdit' permission bit,
|
||||
* and the other containing everything else. Empty parts will be returned as undefined, except
|
||||
* when both are empty, in which case nonSchemaEdit will be returned as an empty permission set.
|
||||
*/
|
||||
export function splitSchemaEditPermissionSet(permissions: PartialPermissionSet):
|
||||
{schemaEdit?: PartialPermissionSet, nonSchemaEdit?: PartialPermissionSet} {
|
||||
|
||||
const schemaEdit = {...emptyPermissionSet(), schemaEdit: permissions.schemaEdit};
|
||||
const nonSchemaEdit: PartialPermissionSet = {...permissions, schemaEdit: ""};
|
||||
return {
|
||||
schemaEdit: !isEmpty(schemaEdit) ? schemaEdit : undefined,
|
||||
nonSchemaEdit: !isEmpty(nonSchemaEdit) || isEmpty(schemaEdit) ? nonSchemaEdit : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user