This commit moves get_realm_user_groups_for_setting and
get_realm_user_groups_for_dropdown_list_widget functions
from user_groups.ts to group_permission_settings.ts.
This change is needed to avoid import cycles in further
commits to add "Permissions" panel for groups.
We now pass group in functions called while handling group update
events, instead of fetching the groups in those function as we
will need the old setting value in future commits.
There is no reason to show "Everyone on internet" group in
group members, stream subscribers, silent mention and DM
recipient typeaheads since specatators cannot be added to
groups or streams, cannot be involved in DMs and cannot be
mentioned.
Previously, all the non-system groups were shown in the DM
recipient typeahead. Now, we show system groups as well but
do not show groups with more than 20 members.
"max_user_group_name_length" is now defined in user_groups.ts
instead of user_group_edit.ts because we would use that value
in further commits in user_group_create.ts and importing it
from user_group_edit.ts would result in import cycle.
Since the variable value can also be an object if setting is
set to an anonymous group, it is better to rename the variable
in user_has_permission_for_group_setting from setting_group_id
to setting_value.
Similary in is_user_in_setting_group, setting_group variable is
renamed to setting_value since value passed is not a UserGroup
object.
There was a comment mentioning get_all_realm_user_groups
was only used in tests, but we now use it to get potential
subgroups of a group, so that comment is removed.
This commit adds code to live update the checkmark in left panel
on updating the user's membership even for groups whose membership
is not updated directly but has updated group as its subgroup.
This commit adds code to live update the membership status text
if subgroups of a group, either the active group or one of the
subgroup of active group.
Fixes#32485.
This commit adds code to live update the membership status text
when a user is added or removed from a group that is subgroup
of the group opened in the right panel of groups UI.
As we now allow anonymous groups and settings can be set to any
set of users, there is no benefit in not allowing a setting to
be set to "Owners" group.
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.
In `Group settings` -> `Your groups` and `User Profile Popover` -> `User
groups`, we only listed groups that a user was a direct member of. Now,
we will also list groups that a user is not a direct member of, but
associated via a subgroup.
Fixes#32486.
We already have the code to ignore the deactivated groups before
sending the request and show appropriate message. This commit
just adds code to not show them in the typeahead and also not
create its pill if user types the full group name.
Previously, all members of the group, including members of
recursive groups, were shown in the the popover. Now only
direct members are shown along with the direct subgroups
of the group.
Fixes#32088.
We do not show groups that will break the DAG constraint
on being added to a group as subgroups in the typeahead
shown in the members edit UI.
Fixes#32087.
This commit updates the code, which checks if user is member of
the group before adding them to the group, to consider only
direct members and now allows members of subgroups to be added
as direct members of the group.
Removed "type"/"Type" from schema and type names used
for group settings because we want to use "type"/"Type"
only for "type of a type" cases.
So, this commit renames-
- anonymous_group_type => anonymous_group_schema
- group_setting_type_schema => group_setting_value_schema
- GroupSettingType => GroupSettingValue
We also had duplicate definitions for GroupSettingType, in
state_data.ts and in settings_components.ts. So, removed it
from settings_components.ts.
This commit adds code to show typeahead for group setting
pill container. We add a separate function as we only
want to show groups and users in the typeahead and the
options are also sorted in a different order compared
to other typeaheads.
Instead of showing the actual names like "role:everyone",
"role:moderators", etc. for system groups, we show
"Everyone", "Moderators", etc. for system user group in
pills, typeaheads and popovers.
Though system groups are not shown in typeahead as of
this commit, we update the typeahead code as well to
not conside "role:" prefix while matching with the
query as we would soon show system groups in typeahead
when we would add new UI for group-based settings.
Previously, only "role:everyone" group was shown as
"Everyone" in popover and pills but for other system
groups their original names for shown and this commit
changes that behavior to be same for all system groups.
The original display_name field for
settings_config.system_user_groups_list objects, which
was used for dropdown widgets, is also renamed so that
we can use display_name field for the names to be used
in other places.
This commit refactors the code to get groups to be used for settings
as we would now have two UIs for settings for some time - dropdown
widget and pills, so we can just have a single function which just
returns the valid UserGroup objects and then a separate function to
get the appropriate format to be used for dropdown widgets and pills.
We previously passed the UserGroupRaw type object received in
the user group creation event to user_group_edit.add_group_to_table
instead of the UserGroup type object.
The add_group_to_table function is called after receiving creation
event only, but other functions called later in the flow are called
at other times as well like when opening edit panel for a particular
group and they expect UserGroup type object, so this commit fixes it.
This commit introduced 'creator' and 'date_created'
fields in user groups, allowing users to view who
created the groups and when.
Both fields can be null for groups without creator data.
For system groups, the directive is that we should use the description
as the display name. But in case of `role:everyone`, the description is
`Admins, moderators, members and guests`, while for the
`user_group_pill`, we want to display a simpler and succinct message:
`Everyone`. We've only hardcoded this for user_group_pill since we don't
want to display the name as `Everyone` anywhere else yet.
We've also exposed a method called `get_display_group_name` which will
be used in later commits to get the group display name.
This function goes through all subgroups recursively and returns the
resultant set of the members of those subgroups in addition to the
members of our target_group.
This function is required in order to add the `everyone` pill to create
channel flow.
For the tests written in this commit, it uses the same pattern as the
`get_recursive_subgroups` test.
`is_user_in_group` could have been technically refactored to use
`get_recursive_group_members`, but since the former returns early for
direct members, I've let it be for now.