summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 12:09:34 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 12:09:34 +0000
commit903ccf7c93eb9490c76857bffe744249cc07de09 (patch)
tree603a3162e91999160e4efc74f351f9405f422d61 /app/helpers
parent41cb558299b483b44b45351730ee4c0e9fe4ca2c (diff)
downloadgitlab-ce-903ccf7c93eb9490c76857bffe744249cc07de09.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/custom_metrics_helper.rb20
-rw-r--r--app/helpers/environments_helper.rb9
2 files changed, 28 insertions, 1 deletions
diff --git a/app/helpers/custom_metrics_helper.rb b/app/helpers/custom_metrics_helper.rb
new file mode 100644
index 00000000000..fbea6d2050f
--- /dev/null
+++ b/app/helpers/custom_metrics_helper.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+module CustomMetricsHelper
+ def custom_metrics_data(project, metric)
+ custom_metrics_path = project.namespace.becomes(::Namespace)
+
+ {
+ 'custom-metrics-path' => url_for([custom_metrics_path, project, metric]),
+ 'metric-persisted' => metric.persisted?.to_s,
+ 'edit-project-service-path' => edit_project_service_path(project, PrometheusService),
+ 'validate-query-path' => validate_query_project_prometheus_metrics_path(project),
+ 'title' => metric.title.to_s,
+ 'query' => metric.query.to_s,
+ 'y-label' => metric.y_label.to_s,
+ 'unit' => metric.unit.to_s,
+ 'group' => metric.group.to_s,
+ 'legend' => metric.legend.to_s
+ }
+ end
+end
diff --git a/app/helpers/environments_helper.rb b/app/helpers/environments_helper.rb
index fcf99644e66..5b640ea6538 100644
--- a/app/helpers/environments_helper.rb
+++ b/app/helpers/environments_helper.rb
@@ -18,6 +18,10 @@ module EnvironmentsHelper
}
end
+ def custom_metrics_available?(project)
+ can?(current_user, :admin_project, project)
+ end
+
def metrics_data(project, environment)
{
"settings-path" => edit_project_service_path(project, 'prometheus'),
@@ -39,7 +43,10 @@ module EnvironmentsHelper
"has-metrics" => "#{environment.has_metrics?}",
"prometheus-status" => "#{environment.prometheus_status}",
"external-dashboard-url" => project.metrics_setting_external_dashboard_url,
- "environment-state" => "#{environment.state}"
+ "environment-state" => "#{environment.state}",
+ "custom-metrics-path" => project_prometheus_metrics_path(project),
+ "validate-query-path" => validate_query_project_prometheus_metrics_path(project),
+ "custom-metrics-available" => "#{custom_metrics_available?(project)}"
}
end