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,
|
2021-01-03 14:25:43 +05:30
|
|
|
'alert-management-enabled' => alert_management_enabled?(project).to_s,
|
|
|
|
'text-query': params[:search],
|
|
|
|
'assignee-username-query': params[:assignee_username]
|
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)
|
2021-01-29 00:20:46 +05:30
|
|
|
!!(
|
2021-02-22 17:27:13 +05:30
|
|
|
project.alert_management_alerts.any? ||
|
2021-01-29 00:20:46 +05:30
|
|
|
project.prometheus_service_active? ||
|
|
|
|
AlertManagement::HttpIntegrationsFinder.new(project, active: true).execute.any?
|
|
|
|
)
|
2020-07-28 23:09:34 +05:30
|
|
|
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')
|