Module: OperationsHelper

Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/helpers/operations_helper.rb

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Instance Method Details

#alerts_serviceObject


12
13
14
15
16
# File 'app/helpers/operations_helper.rb', line 12

def alerts_service
  strong_memoize(:alerts_service) do
    @project.find_or_initialize_service(::AlertsService.to_param)
  end
end

#alerts_settings_data(disabled: false) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/helpers/operations_helper.rb', line 18

def alerts_settings_data(disabled: false)
  {
    'prometheus_activated' => prometheus_service.manual_configuration?.to_s,
    'activated' => alerts_service.activated?.to_s,
    'prometheus_form_path' => scoped_integration_path(prometheus_service),
    'form_path' => scoped_integration_path(alerts_service),
    'prometheus_reset_key_path' => reset_alerting_token_project_settings_operations_path(@project),
    'prometheus_authorization_key' => @project.alerting_setting&.token,
    'prometheus_api_url' => prometheus_service.api_url,
    'authorization_key' => alerts_service.token,
    'prometheus_url' => notify_project_prometheus_alerts_url(@project, format: :json),
    'url' => alerts_service.url,
    'alerts_setup_url' => help_page_path('user/project/integrations/generic_alerts.md', anchor: 'setting-up-generic-alerts'),
    'alerts_usage_url' => project_alert_management_index_path(@project),
    'disabled' => disabled.to_s
  }
end

#operations_settings_dataObject


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/helpers/operations_helper.rb', line 36

def operations_settings_data
  setting = project_incident_management_setting
  templates = setting.available_issue_templates.map { |t| { key: t.key, name: t.name } }

  {
    operations_settings_endpoint: project_settings_operations_path(@project),
    templates: templates.to_json,
    create_issue: setting.create_issue.to_s,
    issue_template_key: setting.issue_template_key.to_s,
    send_email: setting.send_email.to_s,
    auto_close_incident: setting.auto_close_incident.to_s,
    pagerduty_active: setting.pagerduty_active.to_s,
    pagerduty_token: setting.pagerduty_token.to_s,
    pagerduty_webhook_url: project_incidents_integrations_pagerduty_url(@project, token: setting.pagerduty_token),
    pagerduty_reset_key_path: reset_pagerduty_token_project_settings_operations_path(@project)
  }
end

#prometheus_serviceObject


6
7
8
9
10
# File 'app/helpers/operations_helper.rb', line 6

def prometheus_service
  strong_memoize(:prometheus_service) do
    @project.find_or_initialize_service(::PrometheusService.to_param)
  end
end