Role-targeted broadcast messages
What does this MR do and why?
Issue: gitlab-org/growth/team-tasks#461 (closed)
This MR implements role-targeted broadcast messages. It allows admins to create broadcast messages that will be shown only to users with the selected role(s) in group/sub-group/project pages.
Role-targeted broadcast messages will be shown in all pages where we can infer a project, group or sub-group from the URL using namespace_id
, id
, project_id
, or group_id
params. For example, assuming the current user has the target role, the following table shows some examples of where the broadcast message will be displayed/not displayed.
Page | URL | Display role-targeted broadcast message? |
---|---|---|
Project page | /my-group/my-project |
Yes |
Project members page | /my-group/my-project/-/project_members |
Yes |
Group page | /my-group |
Yes |
Sub-group page | /my-group/my-subgroup |
Yes |
Groups list page | /dashboard/groups |
No |
Database
rails db:migrate
$ rails db:migrate
== 20220128081329 AddTargetAccessLevelsToBroadcastMessages: migrating =========
-- add_column(:broadcast_messages, :target_access_levels, :integer, {:array=>true, :null=>false, :default=>[]})
-> 0.0049s
== 20220128081329 AddTargetAccessLevelsToBroadcastMessages: migrated (0.0050s)
rails db:rollback
$ rails db:rollback
== 20220128081329 AddTargetAccessLevelsToBroadcastMessages: reverting =========
-- remove_column(:broadcast_messages, :target_access_levels, :integer, {:array=>true, :null=>false, :default=>[]})
-> 0.0060s
== 20220128081329 AddTargetAccessLevelsToBroadcastMessages: reverted (0.0120s)
Screenshots or screen recordings
Demo
https://www.youtube.com/watch?v=2Sj_i1aJ8x8
Updates on the form
Created role-targeted broadcast message
How to set up and validate locally
Setup
- Enable the feature
Feature.enable(:role_targeted_broadcast_messages)
- Login as admin (GDK
root
user) - Go to http://127.0.0.1:3000/admin/broadcast_messages and create a broadcast message with
Target Role(s)
Validate
- Login with a non-admin user
- Go to a project/group/sub-group page where the role of the currently logged-in user matches one of the roles you set when you created the broadcast message
- Validate that the broadcast message is displayed
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.