Read about our upcoming Code of Conduct on this issue

environments_helper.rb 2.08 KB
Newer Older
1
2
# frozen_string_literal: true

Filipa Lacerda's avatar
Filipa Lacerda committed
3
module EnvironmentsHelper
4
5
  prepend_if_ee('::EE::EnvironmentsHelper') # rubocop: disable Cop/InjectEnterpriseEditionModule

Filipa Lacerda's avatar
Filipa Lacerda committed
6
  def environments_list_data
Filipa Lacerda's avatar
Filipa Lacerda committed
7
    {
8
      endpoint: project_environments_path(@project, format: :json)
Filipa Lacerda's avatar
Filipa Lacerda committed
9
10
    }
  end
11

12
13
14
15
  def environments_folder_list_view_data
    {
      "endpoint" => folder_project_environments_path(@project, @folder, format: :json),
      "folder-name" => @folder,
Scott Hampton's avatar
Scott Hampton committed
16
      "can-read-environment" => can?(current_user, :read_environment, @project).to_s
17
18
19
    }
  end

20
21
22
23
24
25
26
27
28
  def metrics_data(project, environment)
    {
      "settings-path" => edit_project_service_path(project, 'prometheus'),
      "clusters-path" => project_clusters_path(project),
      "current-environment-name": environment.name,
      "documentation-path" => help_page_path('administration/monitoring/prometheus/index.md'),
      "empty-getting-started-svg-path" => image_path('illustrations/monitoring/getting_started.svg'),
      "empty-loading-svg-path" => image_path('illustrations/monitoring/loading.svg'),
      "empty-no-data-svg-path" => image_path('illustrations/monitoring/no_data.svg'),
29
      "empty-no-data-small-svg-path" => image_path('illustrations/chart-empty-state-small.svg'),
30
31
      "empty-unable-to-connect-svg-path" => image_path('illustrations/monitoring/unable_to_connect.svg'),
      "metrics-endpoint" => additional_metrics_project_environment_path(project, environment, format: :json),
32
      "dashboards-endpoint" => project_performance_monitoring_dashboards_path(project, format: :json),
33
      "dashboard-endpoint" => metrics_dashboard_project_environment_path(project, environment, format: :json),
34
      "deployments-endpoint" => project_environment_deployments_path(project, environment, format: :json),
35
      "default-branch" => project.default_branch,
36
37
      "project-path" => project_path(project),
      "tags-path" => project_tags_path(project),
38
      "has-metrics" => "#{environment.has_metrics?}",
39
      "prometheus-status" => "#{environment.prometheus_status}",
40
      "external-dashboard-url" => project.metrics_setting_external_dashboard_url
41
42
    }
  end
Filipa Lacerda's avatar
Filipa Lacerda committed
43
end