mirror of https://github.com/zulip/zulip.git
settings: Rename can_edit_all_user_groups to use `manage`.
Having both `manage` and `edit` terminologies was confusing, so this commit ensures that we use `manage` wherever applicable.
This commit is contained in:
parent
4d06626b6f
commit
91edf59873
|
@ -188,7 +188,7 @@ export function user_can_move_messages_between_streams(): boolean {
|
|||
return user_has_permission(realm.realm_move_messages_between_streams_policy);
|
||||
}
|
||||
|
||||
export function user_can_edit_all_user_groups(): boolean {
|
||||
export function user_can_manage_all_groups(): boolean {
|
||||
if (page_params.is_spectator) {
|
||||
return false;
|
||||
}
|
||||
|
@ -199,12 +199,12 @@ export function user_can_edit_all_user_groups(): boolean {
|
|||
);
|
||||
}
|
||||
|
||||
export function can_edit_user_group(group_id: number): boolean {
|
||||
export function can_manage_user_group(group_id: number): boolean {
|
||||
if (page_params.is_spectator) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let can_edit_all_user_groups = user_can_edit_all_user_groups();
|
||||
let can_manage_all_groups = user_can_manage_all_groups();
|
||||
|
||||
const group = user_groups.get_user_group_from_id(group_id);
|
||||
|
||||
|
@ -221,10 +221,10 @@ export function can_edit_user_group(group_id: number): boolean {
|
|||
!current_user.is_moderator &&
|
||||
!user_groups.is_direct_member_of(current_user.user_id, group_id)
|
||||
) {
|
||||
can_edit_all_user_groups = false;
|
||||
can_manage_all_groups = false;
|
||||
}
|
||||
|
||||
if (can_edit_all_user_groups) {
|
||||
if (can_manage_all_groups) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ function update_add_members_elements(group) {
|
|||
const $input_element = $add_members_container.find(".input").expectOne();
|
||||
const $button_element = $add_members_container.find('button[name="add_member"]').expectOne();
|
||||
|
||||
if (settings_data.can_edit_user_group(group.id)) {
|
||||
if (settings_data.can_manage_user_group(group.id)) {
|
||||
$input_element.prop("contenteditable", true);
|
||||
$button_element.prop("disabled", false);
|
||||
$button_element.css("pointer-events", "");
|
||||
|
@ -120,7 +120,7 @@ function update_group_permission_settings_elements(group) {
|
|||
|
||||
const $permission_pill_container_elements = $group_permission_settings.find(".pill-container");
|
||||
|
||||
if (settings_data.can_edit_user_group(group.id)) {
|
||||
if (settings_data.can_manage_user_group(group.id)) {
|
||||
$permission_dropdown_elements.prop("disabled", false);
|
||||
$permission_pill_container_elements.find(".input").prop("contenteditable", true);
|
||||
$permission_pill_container_elements.removeClass("group_setting_disabled");
|
||||
|
@ -187,7 +187,7 @@ function show_general_settings(group) {
|
|||
function update_general_panel_ui(group) {
|
||||
const $edit_container = get_edit_container(group);
|
||||
|
||||
if (settings_data.can_edit_user_group(group.id)) {
|
||||
if (settings_data.can_manage_user_group(group.id)) {
|
||||
$edit_container.find(".group-header .button-group").show();
|
||||
$(`.group_settings_header[data-group-id='${CSS.escape(group.id)}'] .deactivate`).show();
|
||||
} else {
|
||||
|
@ -258,7 +258,7 @@ function update_group_membership_button(group_id) {
|
|||
$group_settings_button.text($t({defaultMessage: "Join group"}));
|
||||
}
|
||||
|
||||
if (settings_data.can_edit_user_group(group_id)) {
|
||||
if (settings_data.can_manage_user_group(group_id)) {
|
||||
$group_settings_button.prop("disabled", false);
|
||||
$group_settings_button.css("pointer-events", "");
|
||||
const $group_settings_button_wrapper = $group_settings_button.closest(
|
||||
|
@ -298,7 +298,7 @@ export function handle_member_edit_event(group_id, user_ids) {
|
|||
// is added to it. The whole list is redrawed to
|
||||
// maintain the sorted order of groups.
|
||||
redraw_user_group_list();
|
||||
} else if (!settings_data.can_edit_user_group(group_id)) {
|
||||
} else if (!settings_data.can_manage_user_group(group_id)) {
|
||||
// We remove the group row immediately only if the
|
||||
// user cannot join the group again themselves.
|
||||
const group_row = row_for_group_id(group_id);
|
||||
|
@ -315,7 +315,7 @@ export function handle_member_edit_event(group_id, user_ids) {
|
|||
|
||||
const item = group;
|
||||
item.is_member = user_groups.is_user_in_group(group_id, people.my_current_user_id());
|
||||
item.can_edit = settings_data.can_edit_user_group(item.id);
|
||||
item.can_edit = settings_data.can_manage_user_group(item.id);
|
||||
const html = render_browse_user_groups_list_item(item);
|
||||
const $new_row = $(html);
|
||||
|
||||
|
@ -831,7 +831,7 @@ export function setup_page(callback) {
|
|||
people.my_current_user_id(),
|
||||
item.id,
|
||||
);
|
||||
item.can_edit = settings_data.can_edit_user_group(item.id);
|
||||
item.can_edit = settings_data.can_manage_user_group(item.id);
|
||||
return render_browse_user_groups_list_item(item);
|
||||
},
|
||||
filter: {
|
||||
|
@ -956,7 +956,7 @@ export function initialize() {
|
|||
const group_id = active_group_data.id;
|
||||
const user_group = user_groups.get_user_group_from_id(group_id);
|
||||
|
||||
if (!user_group || !settings_data.can_edit_user_group(group_id)) {
|
||||
if (!user_group || !settings_data.can_manage_user_group(group_id)) {
|
||||
return;
|
||||
}
|
||||
function deactivate_user_group() {
|
||||
|
|
|
@ -61,7 +61,7 @@ function format_member_list_elem(person: User): string {
|
|||
user_id: person.user_id,
|
||||
is_current_user: person.user_id === current_user.user_id,
|
||||
email: person.delivery_email,
|
||||
can_remove_subscribers: settings_data.can_edit_user_group(current_group_id),
|
||||
can_remove_subscribers: settings_data.can_manage_user_group(current_group_id),
|
||||
for_user_group_members: true,
|
||||
img_src: people.small_avatar_url_for_person(person),
|
||||
});
|
||||
|
@ -147,7 +147,7 @@ export function rerender_members_list({
|
|||
}): void {
|
||||
$parent_container.find(".member-list-box").html(
|
||||
render_user_group_members_table({
|
||||
can_edit: settings_data.can_edit_user_group(group.id),
|
||||
can_edit: settings_data.can_manage_user_group(group.id),
|
||||
}),
|
||||
);
|
||||
member_list_widget = make_list_widget({
|
||||
|
@ -356,7 +356,7 @@ function remove_member({
|
|||
});
|
||||
}
|
||||
|
||||
if (people.is_my_user_id(target_user_id) && !settings_data.can_edit_user_group(group_id)) {
|
||||
if (people.is_my_user_id(target_user_id) && !settings_data.can_manage_user_group(group_id)) {
|
||||
const html_body = render_leave_user_group_modal({
|
||||
message: $t({
|
||||
defaultMessage: "Once you leave this group, you will not be able to rejoin.",
|
||||
|
|
|
@ -339,7 +339,7 @@ run_test("user_can_create_multiuse_invite", () => {
|
|||
);
|
||||
});
|
||||
|
||||
run_test("can_edit_user_group", () => {
|
||||
run_test("can_manage_user_group", () => {
|
||||
const admins = {
|
||||
description: "Administrators",
|
||||
name: "role:administrators",
|
||||
|
@ -396,12 +396,12 @@ run_test("can_edit_user_group", () => {
|
|||
});
|
||||
|
||||
page_params.is_spectator = true;
|
||||
assert.ok(!settings_data.can_edit_user_group(students.id));
|
||||
assert.ok(!settings_data.can_manage_user_group(students.id));
|
||||
|
||||
page_params.is_spectator = false;
|
||||
realm.realm_can_manage_all_groups = admins.id;
|
||||
current_user.user_id = 3;
|
||||
assert.ok(!settings_data.can_edit_user_group(students.id));
|
||||
assert.ok(!settings_data.can_manage_user_group(students.id));
|
||||
|
||||
// non-admin group_creator
|
||||
current_user.user_id = 4;
|
||||
|
@ -409,22 +409,22 @@ run_test("can_edit_user_group", () => {
|
|||
|
||||
// admin user
|
||||
current_user.user_id = 1;
|
||||
assert.ok(settings_data.can_edit_user_group(students.id));
|
||||
assert.ok(settings_data.can_manage_user_group(students.id));
|
||||
|
||||
// moderator user
|
||||
current_user.user_id = 2;
|
||||
assert.ok(!settings_data.can_edit_user_group(students.id));
|
||||
assert.ok(!settings_data.can_manage_user_group(students.id));
|
||||
|
||||
realm.realm_can_manage_all_groups = members.id;
|
||||
current_user.user_id = 3;
|
||||
assert.ok(!settings_data.can_edit_user_group(students.id));
|
||||
assert.ok(!settings_data.can_manage_user_group(students.id));
|
||||
|
||||
current_user.user_id = 2;
|
||||
assert.ok(settings_data.can_edit_user_group(students.id));
|
||||
assert.ok(settings_data.can_manage_user_group(students.id));
|
||||
|
||||
realm.realm_can_manage_all_groups = admins.id;
|
||||
current_user.user_id = 2;
|
||||
assert.ok(!settings_data.can_edit_user_group(students.id));
|
||||
assert.ok(!settings_data.can_manage_user_group(students.id));
|
||||
|
||||
const event = {
|
||||
group_id: students.id,
|
||||
|
@ -433,10 +433,10 @@ run_test("can_edit_user_group", () => {
|
|||
},
|
||||
};
|
||||
user_groups.update(event);
|
||||
assert.ok(settings_data.can_edit_user_group(students.id));
|
||||
assert.ok(settings_data.can_manage_user_group(students.id));
|
||||
|
||||
current_user.user_id = 3;
|
||||
assert.ok(settings_data.can_edit_user_group(students.id));
|
||||
assert.ok(settings_data.can_manage_user_group(students.id));
|
||||
});
|
||||
|
||||
run_test("type_id_to_string", () => {
|
||||
|
@ -506,10 +506,10 @@ run_test("user_can_create_user_groups", () => {
|
|||
test_realm_group_settings("realm_can_create_groups", settings_data.user_can_create_user_groups);
|
||||
});
|
||||
|
||||
run_test("user_can_edit_all_user_groups", () => {
|
||||
run_test("user_can_manage_all_groups", () => {
|
||||
test_realm_group_settings(
|
||||
"realm_can_manage_all_groups",
|
||||
settings_data.user_can_edit_all_user_groups,
|
||||
settings_data.user_can_manage_all_groups,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ def check_permission_for_managing_all_groups(
|
|||
) -> bool:
|
||||
"""
|
||||
Given a user and a group in the same realm, checks if the user
|
||||
can manage the group through the legacy can_edit_all_user_groups
|
||||
can manage the group through the legacy can_manage_all_groups
|
||||
permission, which is a permission that requires either certain roles
|
||||
or membership in the group itself to be used.
|
||||
"""
|
||||
|
@ -146,8 +146,8 @@ def check_permission_for_managing_all_groups(
|
|||
if user_group.creator and user_group.creator.id == user_profile.id:
|
||||
return True
|
||||
|
||||
can_edit_all_user_groups = user_profile.can_edit_all_user_groups()
|
||||
if can_edit_all_user_groups:
|
||||
can_manage_all_groups = user_profile.can_manage_all_groups()
|
||||
if can_manage_all_groups:
|
||||
if user_profile.is_realm_admin or user_profile.is_moderator:
|
||||
return True
|
||||
|
||||
|
|
|
@ -874,7 +874,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings):
|
|||
def can_create_user_groups(self) -> bool:
|
||||
return self.has_permission("can_create_groups")
|
||||
|
||||
def can_edit_all_user_groups(self) -> bool:
|
||||
def can_manage_all_groups(self) -> bool:
|
||||
return self.has_permission("can_manage_all_groups")
|
||||
|
||||
def can_move_messages_to_another_topic(self) -> bool:
|
||||
|
|
Loading…
Reference in New Issue