2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-14 08:15:29 -04:00
|
|
|
module EnvironmentsHelper
|
2020-02-14 13:08:45 -05:00
|
|
|
include ActionView::Helpers::AssetUrlHelper
|
2019-09-13 09:26:31 -04:00
|
|
|
prepend_if_ee('::EE::EnvironmentsHelper') # rubocop: disable Cop/InjectEnterpriseEditionModule
|
|
|
|
|
2016-11-15 05:12:59 -05:00
|
|
|
def environments_list_data
|
2016-10-14 08:15:29 -04:00
|
|
|
{
|
2017-06-29 13:06:35 -04:00
|
|
|
endpoint: project_environments_path(@project, format: :json)
|
2016-10-14 08:15:29 -04:00
|
|
|
}
|
|
|
|
end
|
2018-06-25 05:57:29 -04:00
|
|
|
|
2019-01-11 11:14:49 -05:00
|
|
|
def environments_folder_list_view_data
|
|
|
|
{
|
|
|
|
"endpoint" => folder_project_environments_path(@project, @folder, format: :json),
|
|
|
|
"folder-name" => @folder,
|
2019-01-11 11:36:31 -05:00
|
|
|
"can-read-environment" => can?(current_user, :read_environment, @project).to_s
|
2019-01-11 11:14:49 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-06-25 05:57:29 -04:00
|
|
|
def metrics_data(project, environment)
|
|
|
|
{
|
|
|
|
"settings-path" => edit_project_service_path(project, 'prometheus'),
|
|
|
|
"clusters-path" => project_clusters_path(project),
|
2020-02-14 13:08:45 -05:00
|
|
|
"current-environment-name" => environment.name,
|
2018-06-25 05:57:29 -04:00
|
|
|
"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'),
|
2019-12-11 04:08:12 -05:00
|
|
|
"empty-no-data-small-svg-path" => image_path('illustrations/chart-empty-state-small.svg'),
|
2018-06-25 05:57:29 -04:00
|
|
|
"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),
|
2020-01-16 13:08:46 -05:00
|
|
|
"dashboards-endpoint" => project_performance_monitoring_dashboards_path(project, format: :json),
|
2019-06-05 18:03:30 -04:00
|
|
|
"dashboard-endpoint" => metrics_dashboard_project_environment_path(project, environment, format: :json),
|
2019-06-14 03:59:42 -04:00
|
|
|
"deployments-endpoint" => project_environment_deployments_path(project, environment, format: :json),
|
2020-01-16 13:08:46 -05:00
|
|
|
"default-branch" => project.default_branch,
|
2018-06-25 05:57:29 -04:00
|
|
|
"project-path" => project_path(project),
|
|
|
|
"tags-path" => project_tags_path(project),
|
2019-05-29 09:36:36 -04:00
|
|
|
"has-metrics" => "#{environment.has_metrics?}",
|
2019-10-21 20:06:05 -04:00
|
|
|
"prometheus-status" => "#{environment.prometheus_status}",
|
2019-05-29 09:36:36 -04:00
|
|
|
"external-dashboard-url" => project.metrics_setting_external_dashboard_url
|
2018-06-25 05:57:29 -04:00
|
|
|
}
|
|
|
|
end
|
2016-10-20 07:09:35 -04:00
|
|
|
end
|