debian-mirror-gitlab/app/helpers/projects/alert_management_helper.rb

33 lines
1.2 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
module Projects::AlertManagementHelper
def alert_management_data(current_user, project)
{
'project-path' => project.full_path,
2020-07-28 23:09:34 +05:30
'enable-alert-management-path' => project_settings_operations_path(project, anchor: 'js-alert-management-settings'),
2020-10-24 23:57:45 +05:30
'alerts-help-url' => help_page_url('operations/incident_management/index.md'),
'populating-alerts-help-url' => help_page_url('operations/incident_management/index.md', anchor: 'enable-alert-management'),
2020-05-24 23:13:21 +05:30
'empty-alert-svg-path' => image_path('illustrations/alert-management-empty-state.svg'),
2020-07-28 23:09:34 +05:30
'user-can-enable-alert-management' => can?(current_user, :admin_operations, project).to_s,
'alert-management-enabled' => alert_management_enabled?(project).to_s
2020-05-24 23:13:21 +05:30
}
end
def alert_management_detail_data(project, alert_id)
{
'alert-id' => alert_id,
'project-path' => project.full_path,
2020-07-28 23:09:34 +05:30
'project-id' => project.id,
2020-06-23 00:09:42 +05:30
'project-issues-path' => project_issues_path(project)
2020-05-24 23:13:21 +05:30
}
end
2020-07-28 23:09:34 +05:30
private
def alert_management_enabled?(project)
!!(project.alerts_service_activated? || project.prometheus_service_active?)
end
2020-05-24 23:13:21 +05:30
end
2020-07-28 23:09:34 +05:30
Projects::AlertManagementHelper.prepend_if_ee('EE::Projects::AlertManagementHelper')