2020-04-21 15:21:10 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Projects::AlertManagementHelper
|
2020-04-27 18:09:41 +00:00
|
|
|
def alert_management_data(current_user, project)
|
2020-04-21 15:21:10 +00:00
|
|
|
{
|
2020-04-30 12:09:45 +00:00
|
|
|
'project-path' => project.full_path,
|
2020-07-13 15:09:08 +00:00
|
|
|
'enable-alert-management-path' => project_settings_operations_path(project, anchor: 'js-alert-management-settings'),
|
2021-02-06 21:09:10 +00:00
|
|
|
'alerts-help-url' => help_page_url('operations/incident_management/alerts.md'),
|
|
|
|
'populating-alerts-help-url' => help_page_url('operations/incident_management/integrations.md', anchor: 'configuration'),
|
2020-04-27 18:09:41 +00:00
|
|
|
'empty-alert-svg-path' => image_path('illustrations/alert-management-empty-state.svg'),
|
2020-06-27 00:09:17 +00:00
|
|
|
'user-can-enable-alert-management' => can?(current_user, :admin_operations, project).to_s,
|
2020-10-15 18:08:43 +00:00
|
|
|
'alert-management-enabled' => alert_management_enabled?(project).to_s,
|
|
|
|
'text-query': params[:search],
|
|
|
|
'assignee-username-query': params[:assignee_username]
|
2020-04-21 15:21:10 +00:00
|
|
|
}
|
|
|
|
end
|
2020-05-06 15:09:42 +00:00
|
|
|
|
2022-04-16 12:08:27 +00:00
|
|
|
def alert_management_detail_data(current_user, project, alert_id)
|
2020-05-06 15:09:42 +00:00
|
|
|
{
|
|
|
|
'alert-id' => alert_id,
|
2020-05-08 18:09:55 +00:00
|
|
|
'project-path' => project.full_path,
|
2020-06-17 09:08:38 +00:00
|
|
|
'project-id' => project.id,
|
2021-02-12 12:09:02 +00:00
|
|
|
'project-issues-path' => project_issues_path(project),
|
2022-10-21 00:10:26 +00:00
|
|
|
'project-alert-management-details-path' => details_project_alert_management_path(project, alert_id),
|
2022-04-16 12:08:27 +00:00
|
|
|
'page' => 'OPERATIONS',
|
|
|
|
'can-update' => can?(current_user, :update_alert_management_alert, project).to_s
|
2020-05-06 15:09:42 +00:00
|
|
|
}
|
|
|
|
end
|
2020-06-18 00:08:35 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def alert_management_enabled?(project)
|
2020-11-20 18:09:37 +00:00
|
|
|
!!(
|
2020-12-08 03:09:37 +00:00
|
|
|
project.alert_management_alerts.any? ||
|
2021-06-18 21:10:06 +00:00
|
|
|
project.prometheus_integration_active? ||
|
2020-11-20 18:09:37 +00:00
|
|
|
AlertManagement::HttpIntegrationsFinder.new(project, active: true).execute.any?
|
|
|
|
)
|
2020-06-18 00:08:35 +00:00
|
|
|
end
|
2020-04-21 15:21:10 +00:00
|
|
|
end
|