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'),
|
2021-03-11 19:13:27 +05:30
|
|
|
'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-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
|
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
def alert_management_detail_data(current_user, project, alert_id)
|
2020-05-24 23:13:21 +05:30
|
|
|
{
|
|
|
|
'alert-id' => alert_id,
|
|
|
|
'project-path' => project.full_path,
|
2020-07-28 23:09:34 +05:30
|
|
|
'project-id' => project.id,
|
2021-03-11 19:13:27 +05:30
|
|
|
'project-issues-path' => project_issues_path(project),
|
2022-06-21 17:19:12 +05:30
|
|
|
'page' => 'OPERATIONS',
|
|
|
|
'can-update' => can?(current_user, :update_alert_management_alert, project).to_s
|
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-09-30 23:02:18 +05:30
|
|
|
project.prometheus_integration_active? ||
|
2021-01-29 00:20:46 +05:30
|
|
|
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
|