user_group: Disable leave checkmark if user isn't a direct member.

If the user is not a direct member, but a member via a subgroup, we will
show the list of subgroups beloging to that group which the current user
is a direct member of in a tooltip. The cursor on the checkmark will be
default in this case instead of a pointer.
This commit is contained in:
Shubham Padia
2024-11-27 04:39:03 +00:00
committed by Tim Abbott
parent 8a28b31be3
commit bf73e1711d
5 changed files with 112 additions and 2 deletions

View File

@@ -418,6 +418,25 @@ export function is_user_in_group(
return false;
}
export function get_associated_subgroups(user_group: UserGroup, user_id: number): UserGroup[] {
const subgroup_ids = get_recursive_subgroups(user_group)!;
if (subgroup_ids === undefined) {
return [];
}
const subgroups = [];
for (const group_id of subgroup_ids) {
if (is_direct_member_of(user_id, group_id)) {
subgroups.push(user_group_by_id_dict.get(group_id)!);
}
}
return subgroups;
}
export function group_list_to_comma_seperated_name(user_groups: UserGroup[]): string {
return user_groups.map((user_group) => user_group.name).join(", ");
}
export function is_user_in_setting_group(
setting_group: GroupSettingValue,
user_id: number,