blob: 5ef68388ea98853cd2535a402124a24b4b9c4172 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# frozen_string_literal: true
module Banzai
module Filter
class InlineClusterMetricsFilter < ::Banzai::Filter::InlineEmbedsFilter
def embed_params(node)
url = node['href']
@query_params = query_params(url)
return unless [:group, :title, :y_label].all? do |param|
@query_params.include?(param)
end
link_pattern.match(url) { |m| m.named_captures }.symbolize_keys
end
def xpath_search
"descendant-or-self::a[contains(@href,'clusters') and \
starts-with(@href, '#{::Gitlab.config.gitlab.url}')]"
end
def link_pattern
::Gitlab::Metrics::Dashboard::Url.clusters_regex
end
def metrics_dashboard_url(params)
::Gitlab::Routing.url_helpers.metrics_dashboard_namespace_project_cluster_url(
params[:namespace],
params[:project],
params[:cluster_id],
# Only Project clusters are supported for now
# admin and group cluster types may be supported in the future
cluster_type: :project,
embedded: true,
format: :json,
**@query_params
)
end
end
end
end
|