settings: Add group_permission_settings.ts.

This commit adds a new module group_permission_settings.ts
which is used to define configuration options like
allow_owners_group, allow_nobody_group, etc. for group-based
settings similar to GroupPermissionSetting dataclass we have
in backend.
This commit is contained in:
Sahil Batra 2023-04-06 12:56:48 +05:30 committed by Tim Abbott
parent 66693f2101
commit a5cbf95c12
2 changed files with 29 additions and 0 deletions

View File

@ -91,6 +91,7 @@ EXEMPT_FILES = make_set(
"web/src/gear_menu.ts",
"web/src/giphy.js",
"web/src/global.d.ts",
"web/src/group_permission_settings.ts",
"web/src/hash_util.js",
"web/src/hashchange.js",
"web/src/hbs.d.ts",

View File

@ -0,0 +1,28 @@
type GroupPermissionSetting = {
require_system_group: boolean;
allow_internet_group: boolean;
allow_owners_group: boolean;
allow_nobody_group: boolean;
};
const group_permission_config_dict: Map<string, GroupPermissionSetting> = new Map([
[
"can_remove_subscribers_group",
{
require_system_group: true,
allow_internet_group: false,
allow_owners_group: false,
allow_nobody_group: false,
},
],
]);
export function get_group_permission_setting_config(
setting_name: string,
): GroupPermissionSetting | undefined {
const permission_config_dict = group_permission_config_dict.get(setting_name);
if (!permission_config_dict) {
throw new Error(`Invalid setting: ${setting_name}`);
}
return permission_config_dict;
}