mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(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:
@@ -18,11 +18,13 @@ const parser = new Parser({
|
||||
nsSeparator: null,
|
||||
});
|
||||
|
||||
async function* walk(dir) {
|
||||
for await (const d of await fs.promises.opendir(dir)) {
|
||||
const entry = path.join(dir, d.name);
|
||||
if (d.isDirectory()) yield* walk(entry);
|
||||
else if (d.isFile()) yield entry;
|
||||
async function* walk(dirs) {
|
||||
for (const dir of dirs) {
|
||||
for await (const d of await fs.promises.opendir(dir)) {
|
||||
const entry = path.join(dir, d.name);
|
||||
if (d.isDirectory()) yield* walk([entry]);
|
||||
else if (d.isFile()) yield entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +40,15 @@ const customHandler = (fileName) => (key, options) => {
|
||||
}
|
||||
};
|
||||
|
||||
function sort(obj) {
|
||||
if (typeof obj !== "object" || Array.isArray(obj))
|
||||
return obj;
|
||||
const sortedObject = {};
|
||||
const keys = Object.keys(obj).sort();
|
||||
keys.forEach(key => sortedObject[key] = sort(obj[key]));
|
||||
return sortedObject;
|
||||
}
|
||||
|
||||
const getKeysFromFile = (filePath, fileName) => {
|
||||
const content = fs.readFileSync(filePath, "utf-8");
|
||||
parser.parseFuncFromString(
|
||||
@@ -54,19 +65,20 @@ const getKeysFromFile = (filePath, fileName) => {
|
||||
return keys;
|
||||
};
|
||||
|
||||
async function walkTranslation(dirPath) {
|
||||
for await (const p of walk(dirPath)) {
|
||||
async function walkTranslation(dirs) {
|
||||
for await (const p of walk(dirs)) {
|
||||
const { name } = path.parse(p);
|
||||
if (p.endsWith('.map')) { continue; }
|
||||
getKeysFromFile(p, name);
|
||||
}
|
||||
const keys = parser.get({ sort: true });
|
||||
const newTranslations = _.merge(keys.en.translation, englishKeys);
|
||||
await fs.promises.writeFile(
|
||||
"static/locales/en.client.json",
|
||||
JSON.stringify(newTranslations, null, 2),
|
||||
JSON.stringify(sort(newTranslations), null, 2),
|
||||
"utf-8"
|
||||
);
|
||||
return keys;
|
||||
}
|
||||
|
||||
walkTranslation("app/client");
|
||||
walkTranslation(["_build/app/client", ...process.argv.slice(2)]);
|
||||
|
||||
Reference in New Issue
Block a user