Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
56e1d45c
Commit
56e1d45c
authored
Mar 11, 2020
by
Allison Browne
Committed by
Michael Kozono
Mar 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "The same chart appears twice for different embeds"
parent
34a5ddc2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
6 deletions
+32
-6
changelogs/unreleased/210008-the-same-chart-appears-twice-for-different-embeds.yml
...008-the-same-chart-appears-twice-for-different-embeds.yml
+5
-0
ee/lib/banzai/filter/inline_cluster_metrics_filter.rb
ee/lib/banzai/filter/inline_cluster_metrics_filter.rb
+3
-2
lib/banzai/filter/inline_embeds_filter.rb
lib/banzai/filter/inline_embeds_filter.rb
+1
-4
spec/features/markdown/metrics_spec.rb
spec/features/markdown/metrics_spec.rb
+23
-0
No files found.
changelogs/unreleased/210008-the-same-chart-appears-twice-for-different-embeds.yml
0 → 100644
View file @
56e1d45c
---
title
:
Fix embeds so that a chart appears only once
merge_request
:
26997
author
:
type
:
fixed
ee/lib/banzai/filter/inline_cluster_metrics_filter.rb
View file @
56e1d45c
...
...
@@ -5,9 +5,10 @@ module Banzai
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
(
url
)
.
include?
(
param
)
@query_params
.
include?
(
param
)
end
link_pattern
.
match
(
url
)
{
|
m
|
m
.
named_captures
}.
symbolize_keys
...
...
@@ -32,7 +33,7 @@ module Banzai
cluster_type: :project
,
embedded:
true
,
format: :json
,
**
query_params
(
params
[
'url'
])
**
@query_params
)
end
end
...
...
lib/banzai/filter/inline_embeds_filter.rb
View file @
56e1d45c
...
...
@@ -6,7 +6,6 @@ module Banzai
# a given link format. To transform references to DB
# resources in place, prefer to inherit from AbstractReferenceFilter.
class
InlineEmbedsFilter
<
HTML
::
Pipeline
::
Filter
include
Gitlab
::
Utils
::
StrongMemoize
# Find every relevant link, create a new node based on
# the link, and insert this node after any html content
# surrounding the link.
...
...
@@ -74,10 +73,8 @@ module Banzai
# Ex) 'https://<root>/<project>/<environment>/metrics?title=Title&group=Group'
# --> { title: 'Title', group: 'Group' }
def
query_params
(
url
)
strong_memoize
(
:query_params
)
do
Gitlab
::
Metrics
::
Dashboard
::
Url
.
parse_query
(
url
)
end
end
# Implement in child class.
#
...
...
spec/features/markdown/metrics_spec.rb
View file @
56e1d45c
...
...
@@ -62,6 +62,29 @@ describe 'Metrics rendering', :js, :use_clean_rails_memory_store_caching, :sidek
expect
(
page
).
to
have_text
(
chart_params
[
:title
])
expect
(
page
).
to
have_text
(
chart_params
[
:y_label
])
end
context
'when two dashboard urls are included'
do
let
(
:chart_params_2
)
do
{
group:
'System metrics (Kubernetes)'
,
title:
'Core Usage (Total)'
,
y_label:
'Total Cores'
}
end
let
(
:metrics_url_2
)
{
urls
.
metrics_project_environment_url
(
project
,
environment
,
**
chart_params_2
)
}
let
(
:description
)
{
"See [metrics dashboard](
#{
metrics_url
}
) for info.
\n
See [metrics dashboard](
#{
metrics_url_2
}
) for info."
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
description:
description
)
}
it
'shows embedded metrics for both urls'
do
visit
project_issue_path
(
project
,
issue
)
expect
(
page
).
to
have_css
(
'div.prometheus-graph'
)
expect
(
page
).
to
have_text
(
chart_params
[
:title
])
expect
(
page
).
to
have_text
(
chart_params
[
:y_label
])
expect
(
page
).
to
have_text
(
chart_params_2
[
:title
])
expect
(
page
).
to
have_text
(
chart_params_2
[
:y_label
])
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment