Module: Admin::BroadcastMessagesHelper
- Includes:
- Gitlab::Utils::StrongMemoize
- Included in:
- BroadcastMessagesController
- Defined in:
- app/helpers/admin/broadcast_messages_helper.rb
Instance Method Summary collapse
- #admin_broadcast_messages_data(broadcast_messages) ⇒ Object
- #broadcast_message(message, opts = {}) ⇒ Object
- #broadcast_message_data(broadcast_message) ⇒ Object
- #broadcast_message_status(broadcast_message) ⇒ Object
- #current_broadcast_banner_messages ⇒ Object
- #current_broadcast_notification_message ⇒ Object
- #render_broadcast_message(broadcast_message) ⇒ Object
- #target_access_level_options ⇒ Object
- #target_access_levels_display(access_levels) ⇒ Object
Instance Method Details
#admin_broadcast_messages_data(broadcast_messages) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/helpers/admin/broadcast_messages_helper.rb', line 66 def () .map do || { id: .id, status: (), message: ., theme: .theme, broadcast_type: .broadcast_type, dismissable: .dismissable, starts_at: .starts_at.iso8601, ends_at: .ends_at.iso8601, target_roles: target_access_levels_display(.target_access_levels), target_path: .target_path, type: .broadcast_type.capitalize, edit_path: (), delete_path: "#{()}.js" } end.to_json end |
#broadcast_message(message, opts = {}) ⇒ Object
26 27 28 29 30 |
# File 'app/helpers/admin/broadcast_messages_helper.rb', line 26 def (, opts = {}) return unless .present? render "shared/broadcast_message", { message: , **opts } end |
#broadcast_message_data(broadcast_message) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'app/helpers/admin/broadcast_messages_helper.rb', line 86 def () { id: .id, message: ., broadcast_type: .broadcast_type, theme: .theme, dismissable: .dismissable.to_s, target_access_levels: .target_access_levels, messages_path: , preview_path: , target_path: .target_path, starts_at: .starts_at.iso8601, ends_at: .ends_at.iso8601, target_access_level_options: .to_json, show_in_cli: .show_in_cli.to_s } end |
#broadcast_message_status(broadcast_message) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/helpers/admin/broadcast_messages_helper.rb', line 32 def () if .active? 'Active' elsif .ended? 'Expired' else 'Pending' end end |
#current_broadcast_banner_messages ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/helpers/admin/broadcast_messages_helper.rb', line 7 def System::BroadcastMessage.( current_path: request.path, user_access_level: current_user_access_level_for_project_or_group ).select do || ["hide_broadcast_message_#{.id}"].blank? end end |
#current_broadcast_notification_message ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/admin/broadcast_messages_helper.rb', line 16 def = System::BroadcastMessage.( current_path: request.path, user_access_level: current_user_access_level_for_project_or_group ).select do || ["hide_broadcast_message_#{.id}"].blank? end .last end |
#render_broadcast_message(broadcast_message) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/admin/broadcast_messages_helper.rb', line 42 def () if .notification? Banzai.render_field_and_post_process(, :message, { current_user: current_user, skip_project_check: true, broadcast_message_placeholders: true }).html_safe else Banzai.render_field(, :message).html_safe end end |
#target_access_level_options ⇒ Object
54 55 56 57 58 |
# File 'app/helpers/admin/broadcast_messages_helper.rb', line 54 def System::BroadcastMessage::ALLOWED_TARGET_ACCESS_LEVELS.map do |access_level| [Gitlab::Access.human_access(access_level), access_level] end end |
#target_access_levels_display(access_levels) ⇒ Object
60 61 62 63 64 |
# File 'app/helpers/admin/broadcast_messages_helper.rb', line 60 def target_access_levels_display(access_levels) access_levels.map do |access_level| Gitlab::Access.human_access(access_level) end.join(', ') end |