settings: Add moderators and full members options in user-group setting.

This commit adds moderators and full members options for user group
settings in frontend.
This commit is contained in:
sahil839
2021-06-03 19:17:03 +05:30
committed by Tim Abbott
parent 50240ca71b
commit e736d9d275
9 changed files with 34 additions and 48 deletions

View File

@@ -10,6 +10,7 @@ import {$t, $t_html} from "./i18n";
import {page_params} from "./page_params";
import * as people from "./people";
import * as pill_typeahead from "./pill_typeahead";
import * as settings_data from "./settings_data";
import * as ui_report from "./ui_report";
import * as user_groups from "./user_groups";
import * as user_pill from "./user_pill";
@@ -32,21 +33,18 @@ export function reload() {
populate_user_groups();
}
const USER_GROUP_EDIT_POLICY_MEMBERS = 1;
export function can_edit(group_id) {
if (page_params.is_admin) {
if (!settings_data.user_can_edit_user_groups()) {
return false;
}
// Admins and moderators are allowed to edit user groups even if they
// are not a member of that user group. Members can edit user groups
// only if they belong to that group.
if (page_params.is_admin || page_params.is_moderator) {
return true;
}
if (page_params.is_guest) {
return false;
}
if (page_params.realm_user_group_edit_policy !== USER_GROUP_EDIT_POLICY_MEMBERS) {
return false;
}
return user_groups.is_member_of(group_id, people.my_current_user_id());
}