2020-04-21 11:21:10 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Projects::AlertManagementHelper
|
2020-04-27 14:09:41 -04:00
|
|
|
def alert_management_data(current_user, project)
|
2020-04-21 11:21:10 -04:00
|
|
|
{
|
2020-04-30 08:09:45 -04:00
|
|
|
'project-path' => project.full_path,
|
2020-07-13 11:09:08 -04:00
|
|
|
'enable-alert-management-path' => project_settings_operations_path(project, anchor: 'js-alert-management-settings'),
|
2020-08-19 08:10:17 -04:00
|
|
|
'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-04-27 14:09:41 -04:00
|
|
|
'empty-alert-svg-path' => image_path('illustrations/alert-management-empty-state.svg'),
|
2020-06-26 20:09:17 -04:00
|
|
|
'user-can-enable-alert-management' => can?(current_user, :admin_operations, project).to_s,
|
2020-10-15 14:08:43 -04:00
|
|
|
'alert-management-enabled' => alert_management_enabled?(project).to_s,
|
|
|
|
'text-query': params[:search],
|
|
|
|
'assignee-username-query': params[:assignee_username]
|
2020-04-21 11:21:10 -04:00
|
|
|
}
|
|
|
|
end
|
2020-05-06 11:09:42 -04:00
|
|
|
|
2020-05-08 14:09:55 -04:00
|
|
|
def alert_management_detail_data(project, alert_id)
|
2020-05-06 11:09:42 -04:00
|
|
|
{
|
|
|
|
'alert-id' => alert_id,
|
2020-05-08 14:09:55 -04:00
|
|
|
'project-path' => project.full_path,
|
2020-06-17 05:08:38 -04:00
|
|
|
'project-id' => project.id,
|
2020-05-20 20:08:06 -04:00
|
|
|
'project-issues-path' => project_issues_path(project)
|
2020-05-06 11:09:42 -04:00
|
|
|
}
|
|
|
|
end
|
2020-06-17 20:08:35 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def alert_management_enabled?(project)
|
2020-11-20 13:09:37 -05:00
|
|
|
!!(
|
2020-12-07 22:09:37 -05:00
|
|
|
project.alert_management_alerts.any? ||
|
2020-11-20 13:09:37 -05:00
|
|
|
project.prometheus_service_active? ||
|
|
|
|
AlertManagement::HttpIntegrationsFinder.new(project, active: true).execute.any?
|
|
|
|
)
|
2020-06-17 20:08:35 -04:00
|
|
|
end
|
2020-04-21 11:21:10 -04:00
|
|
|
end
|
2020-07-15 02:09:35 -04:00
|
|
|
|
|
|
|
Projects::AlertManagementHelper.prepend_if_ee('EE::Projects::AlertManagementHelper')
|