(core) add a checkbox for owner "boss mode"

Summary:
Implement a checkbox that grants owners full access to tables by default, when creating new table/column rules.
 * Checkbox appears above default rules.
 * When set, a rule giving owners full access will be inserted in any new rule set started for tables or columns.
 * The checkbox can be expanded to allow customization of the rules.

https://gristlabs.getgrist.com/doc/check-ins/p/3#a1.s7.r2251.c19

Test Plan: added tests

Reviewers: jarek

Reviewed By: jarek

Subscribers: anaisconce

Differential Revision: https://phab.getgrist.com/D3756
This commit is contained in:
Paul Fitzpatrick
2023-01-09 12:49:58 -05:00
parent b59829d57e
commit e6692c2793
6 changed files with 318 additions and 73 deletions

View File

@@ -64,6 +64,11 @@ const SPECIAL_RULE_SETS: Record<string, RuleSet> = {
permissions: parsePermissions('-R'),
permissionsText: '-R',
}],
},
SeedRule: {
tableId: SPECIAL_RULES_TABLE_ID,
colIds: ['SeedRule'],
body: [],
}
};
@@ -179,9 +184,13 @@ export class ACLRuleCollection {
const specialType = String(ruleSet.colIds);
const specialDefault = specialRuleSets.get(specialType);
if (!specialDefault) {
throw new Error(`Invalid rule for ${ruleSet.tableId}:${ruleSet.colIds}`);
// Log that we are seeing an invalid rule, but don't fail.
// (Historically, older versions of the Grist app will attempt to
// open newer documents).
options.log.error(`Invalid rule for ${ruleSet.tableId}:${ruleSet.colIds}`);
} else {
specialRuleSets.set(specialType, {...ruleSet, body: [...ruleSet.body, ...specialDefault.body]});
}
specialRuleSets.set(specialType, {...ruleSet, body: [...ruleSet.body, ...specialDefault.body]});
}
}