Commit Graph

74 Commits

Author SHA1 Message Date
Sahil Batra
143b4d30d3 user_groups: Fix group_has_permission function.
When setting was set to a single group, group_has_permission
did not return true if group was subgroup of the setting group.
2025-01-28 10:06:31 -08:00
Sahil Batra
893cdc8069 settings: Show realm permissions that group has in permissions panel. 2025-01-27 15:32:15 -08:00
Sahil Batra
52fbca65ce group-settings: Move functions used for group settings.
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.
2025-01-24 14:51:51 -08:00
Sahil Batra
255eee255b events: Pass group in functions called for updating the group.
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.
2025-01-24 14:51:51 -08:00
Sahil Batra
1c07c013ae groups: Do not include "Everyone on internet" group in typeaheads.
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.
2025-01-23 15:41:19 -08:00
Sahil Batra
2e4d4c1d6a compose: Show all groups with at most 20 members in DM typeahead.
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.
2025-01-16 14:25:01 -08:00
Sahil Batra
42fe2690e3 user-groups: Define max_user_group_name_length in user_groups.ts.
"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.
2025-01-12 12:32:32 -08:00
Sahil Batra
cf59071d42 settings: Rename setting_group_id and setting_group variables.
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.
2025-01-06 11:20:38 -08:00
Anders Kaseorg
2548430af3 types: Extract and correct user_group_update_event_schema.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-12-30 09:42:26 -08:00
Sahil Batra
8815e7ac79 user_groups: Remove incorrect comment.
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.
2024-12-30 09:37:32 -08:00
Sahil Batra
f498201141 group-settings: Allow system groups as subgroups when creating groups.
System groups should be shown in typeahead when adding members
to a group during its creation.
2024-12-30 09:37:32 -08:00
Sahil Batra
ab67b87db3 user_group_edit: Fix live update of checkmark in left panel.
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.
2024-12-17 12:36:23 -08:00
Anders Kaseorg
77f97762c6 eslint: Fix unicorn/explicit-length-check. (#32666)
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-12-11 09:19:46 -08:00
Sahil Batra
9be0eee446 group-settings: Live update membership status text on subgroup update.
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.
2024-12-05 10:35:41 -08:00
Sahil Batra
cbada036a9 user-groups: Live update membership status text.
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.
2024-12-05 10:35:41 -08:00
Shubham Padia
08e1a44ce6 user_group: Use Intl.listformat instead of manually inserting commas.
In some other languages, ", " isn't the best way to do a list and
Intl.listformat is a better choice in those cases.
2024-12-04 16:02:20 -08:00
Sahil Batra
121df45cc4 groups: Remove allow_owners_group field from GroupPermissionSetting.
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.
2024-12-04 11:12:28 -08:00
Shubham Padia
bf73e1711d 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.
2024-12-02 17:59:18 -08:00
Shubham Padia
8a28b31be3 user_group: List groups that a user is associated via subgroups.
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.
2024-12-02 17:59:18 -08:00
Sahil Batra
da02135f88 group-settings: Use new setting for controlling removing members. 2024-12-02 17:38:46 -08:00
Shubham Padia
00bbde8edb user_group: Show display_name instead of name for direct subgroups.
For a system group, we were showing it's name, e.g. `role:members` when
we want to show it's display_name instead i.e `Members` in the user
group popover.

Fixes https://chat.zulip.org/#narrow/channel/9-issues/topic/system.20group.20subgroup.20display.20in.20group.20popovers/near/1986632
2024-11-25 13:11:35 -08:00
Anders Kaseorg
ec3177c834 web: Add explicit extensions to imports.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-11-13 09:18:56 -08:00
Sahil Batra
dce229ba17 settings: Use new pills UI for DM permission settings.
We now use pills UI for direct_message_initiator_group
and direct_message_permission_group setting.
2024-10-30 12:03:36 -07:00
Sahil Batra
caf919fca2 user_groups: Don't allow adding deactivated groups as subgroups in UI.
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.
2024-10-29 11:02:03 -07:00
Sahil Batra
98255677d7 user_groups: Extract function to check if group can be used as subgroup.
We would use the same function in further commit to not add pills
for invalid subgroups by typing the full group name.
2024-10-29 11:02:03 -07:00
Sahil Batra
7fe927c61b user_group: Show subgroups in popover.
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.
2024-10-24 08:24:14 -07:00
Tim Abbott
29aad5c940 user_groups: Clean up members field comment. 2024-10-23 11:24:02 -07:00
Sahil Batra
9a72d6e72e user_groups: Do not show invalid subgroups in typeahead.
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.
2024-10-23 11:24:02 -07:00
Sahil Batra
a3b7d956bc user_groups: Allow adding users who are members of subgroups.
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.
2024-10-22 10:23:36 -07:00
Shubham Padia
8055617900 user_groups: Use group picker for can_mention_group. 2024-10-16 13:43:03 -07:00
evykassirer
269066e10a settings_org: Convert module to typescript. 2024-10-14 15:33:01 -07:00
evykassirer
39137e67f7 user_groups: Generate UserGroup type from a schema.
This will be useful for later when we'll need the schema for
converting settings_org to typescript.
2024-10-14 15:33:01 -07:00
Shubham Padia
1862c3b333 user_groups: Use can_leave_group setting to check permisison.
This commit adds code to use can_leave_group setting when
checking permission to leave group in webapp.
2024-10-14 11:44:27 -07:00
Shubham Padia
8a2a8b64aa user_groups: Add can_add_members_group field to group create/edit. 2024-10-11 16:31:18 -07:00
Sahil Batra
7db6de340f settings: Clean schemas and types used for group settings.
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.
2024-10-11 11:22:47 -07:00
Sahil Batra
701e391def user_groups: Use can_join_group setting to check permisison.
This commit adds code to use can_join_group setting when
checking permission to join group in webapp.

Fixes part of #25938.
2024-10-08 12:18:13 -07:00
Sahil Batra
8068b6e55e group_setting_pill: Add code for showing typeahead.
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.
2024-09-19 09:08:33 -07:00
Sahil Batra
def78ddf09 user_groups: Do not show "role:" prefix for system groups.
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.
2024-09-19 09:08:33 -07:00
Sahil Batra
2fff124ec9 settings: Add new module to handle pills for group settings.
This commit creates a new module similar to add_subscribers_pill
for handling the pill widget to be used for group settings.
2024-09-19 09:08:33 -07:00
Sahil Batra
6a739e263f user_groups: Allow deactivating groups from webapp. 2024-09-18 13:41:13 -07:00
Sahil Batra
c53563d0e7 user_groups: Handle deactivated groups in webapp. 2024-09-18 13:41:13 -07:00
Sahil Batra
ccddbba7a3 user_groups: Extract code to check system groups allowed for setting. 2024-09-16 16:28:52 -07:00
Sahil Batra
5fda195eab user_groups: Refactor function to get groups to be used for settings.
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.
2024-09-16 16:28:52 -07:00
Sahil Batra
6482f0c2ea user_groups: Pass correct group object for adding new group to UI.
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.
2024-09-16 16:28:52 -07:00
Sahil Batra
f3fafc719f settings: Add function to check permission for anonymous setting group. 2024-09-16 16:28:52 -07:00
sujal shah
614caf111e user_groups: Add creator and date_created field in user groups.
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.
2024-09-13 18:44:58 -07:00
Ujjawal Modi
20229d0d3d user_groups: Add can_manage_group field to user_group object.
This commit adds can_manage_group field in user_group
object in frontend and also adds code to update the field
value from server events.
2024-08-20 09:28:05 -07:00
Vector73
28ce2684bb user_groups: Add is_empty_group function to check for nobody group.
Removes hardcoded checks for "role:nobody" by checking if the given group
is empty.
2024-07-14 22:29:18 -07:00
Shubham Padia
be5e0d4648 user_group_pill: Hardcode Everyone in display name.
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.
2024-07-12 15:22:50 -07:00
Shubham Padia
9f7dc596f8 user_groups: Add get_recursive_group_members.
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.
2024-07-12 15:22:50 -07:00