Module: EnvironmentsHelper

Includes:
ActionView::Helpers::AssetUrlHelper
Included in:
MetricsDashboard
Defined in:
app/helpers/environments_helper.rb

Instance Method Summary collapse

Instance Method Details

#can_destroy_environment?(environment) ⇒ Boolean

Returns:

  • (Boolean)

44
45
46
# File 'app/helpers/environments_helper.rb', line 44

def can_destroy_environment?(environment)
  can?(current_user, :destroy_environment, environment)
end

#custom_metrics_available?(project) ⇒ Boolean

Returns:

  • (Boolean)

20
21
22
# File 'app/helpers/environments_helper.rb', line 20

def custom_metrics_available?(project)
  can?(current_user, :admin_project, project)
end

#environment_logs_data(project, environment) ⇒ Object


34
35
36
37
38
39
40
41
42
# File 'app/helpers/environments_helper.rb', line 34

def environment_logs_data(project, environment)
  {
    "environment_name": environment.name,
    "environments_path": project_environments_path(project, format: :json),
    "environment_id": environment.id,
    "cluster_applications_documentation_path" => help_page_path('user/clusters/applications.md', anchor: 'elastic-stack'),
    "clusters_path": project_clusters_path(project, format: :json)
  }
end

#environments_folder_list_view_dataObject


12
13
14
15
16
17
18
# File 'app/helpers/environments_helper.rb', line 12

def environments_folder_list_view_data
  {
    "endpoint" => folder_project_environments_path(@project, @folder, format: :json),
    "folder_name" => @folder,
    "can_read_environment" => can?(current_user, :read_environment, @project).to_s
  }
end

#environments_list_dataObject


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

def environments_list_data
  {
    endpoint: project_environments_path(@project, format: :json)
  }
end

#metrics_data(project, environment) ⇒ Object


24
25
26
27
28
29
30
31
32
# File 'app/helpers/environments_helper.rb', line 24

def metrics_data(project, environment)
  metrics_data = {}
  metrics_data.merge!(project_metrics_data(project)) if project
  metrics_data.merge!(environment_metrics_data(environment, project)) if environment
  metrics_data.merge!(project_and_environment_metrics_data(project, environment)) if project && environment
  metrics_data.merge!(static_metrics_data)

  metrics_data
end