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
531dec33
Commit
531dec33
authored
Apr 07, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move cluster health data from helper to presenter
Implements
https://gitlab.com/gitlab-org/gitlab/-/issues/11355
parent
27b453cb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
64 deletions
+82
-64
app/presenters/clusters/cluster_presenter.rb
app/presenters/clusters/cluster_presenter.rb
+2
-0
ee/app/helpers/ee/clusters_helper.rb
ee/app/helpers/ee/clusters_helper.rb
+0
-16
ee/app/presenters/ee/clusters/cluster_presenter.rb
ee/app/presenters/ee/clusters/cluster_presenter.rb
+29
-0
ee/app/views/clusters/clusters/_health.html.haml
ee/app/views/clusters/clusters/_health.html.haml
+1
-1
ee/spec/helpers/ee/clusters_helper_spec.rb
ee/spec/helpers/ee/clusters_helper_spec.rb
+0
-47
ee/spec/presenters/ee/clusters/cluster_presenter_spec.rb
ee/spec/presenters/ee/clusters/cluster_presenter_spec.rb
+50
-0
No files found.
app/presenters/clusters/cluster_presenter.rb
View file @
531dec33
...
...
@@ -89,3 +89,5 @@ module Clusters
end
end
end
Clusters
::
ClusterPresenter
.
prepend_if_ee
(
'EE::Clusters::ClusterPresenter'
)
ee/app/helpers/ee/clusters_helper.rb
View file @
531dec33
...
...
@@ -12,21 +12,5 @@ module EE
def
show_cluster_health_graphs?
clusterable
.
feature_available?
(
:cluster_health
)
end
def
cluster_health_data
(
cluster
)
{
'clusters-path'
:
clusterable
.
index_path
,
'metrics-endpoint'
:
clusterable
.
metrics_cluster_path
(
cluster
,
format: :json
),
'dashboard-endpoint'
:
clusterable
.
metrics_dashboard_path
(
cluster
),
'documentation-path'
:
help_page_path
(
'user/project/clusters/index'
,
anchor:
'monitoring-your-kubernetes-cluster-ultimate'
),
'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'
),
'empty-unable-to-connect-svg-path'
:
image_path
(
'illustrations/monitoring/unable_to_connect.svg'
),
'settings-path'
:
''
,
'project-path'
:
''
,
'tags-path'
:
''
}
end
end
end
ee/app/presenters/ee/clusters/cluster_presenter.rb
0 → 100644
View file @
531dec33
# frozen_string_literal: true
module
EE
module
Clusters
module
ClusterPresenter
def
health_data
(
clusterable
)
{
'clusters-path'
:
clusterable
.
index_path
,
'metrics-endpoint'
:
clusterable
.
metrics_cluster_path
(
cluster
,
format: :json
),
'dashboard-endpoint'
:
clusterable
.
metrics_dashboard_path
(
cluster
),
'documentation-path'
:
help_page_path
(
'user/project/clusters/index'
,
anchor:
'monitoring-your-kubernetes-cluster-ultimate'
),
'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'
),
'empty-unable-to-connect-svg-path'
:
image_path
(
'illustrations/monitoring/unable_to_connect.svg'
),
'settings-path'
:
''
,
'project-path'
:
''
,
'tags-path'
:
''
}
end
private
def
image_path
(
path
)
ActionController
::
Base
.
helpers
.
image_path
(
path
)
end
end
end
end
ee/app/views/clusters/clusters/_health.html.haml
View file @
531dec33
%section
.settings.no-animate.expanded.cluster-health-graphs.qa-cluster-health-section
#cluster-health
-
if
@cluster
&
.
application_prometheus_available?
#prometheus-graphs
{
data:
cluster_health_data
(
@cluster
).
merge
({
"alerts-endpoint"
=>
(
'/'
if
Feature
.
enabled?
(
:prometheus_computed_alerts
)),
#prometheus-graphs
{
data:
@cluster
.
health_data
(
clusterable
).
merge
({
"alerts-endpoint"
=>
(
'/'
if
Feature
.
enabled?
(
:prometheus_computed_alerts
)),
"prometheus-alerts-available"
=>
(
'true'
if
Feature
.
enabled?
(
:prometheus_computed_alerts
))
})
}
-
else
...
...
ee/spec/helpers/ee/clusters_helper_spec.rb
View file @
531dec33
...
...
@@ -58,51 +58,4 @@ describe ClustersHelper do
it_behaves_like
'feature availablilty'
,
:cluster_health
end
end
describe
'#cluster_health_data'
do
shared_examples
'cluster health data'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:cluster_presenter
)
{
cluster
.
present
(
current_user:
user
)
}
let
(
:clusterable_presenter
)
do
ClusterablePresenter
.
fabricate
(
clusterable
,
current_user:
user
)
end
subject
{
helper
.
cluster_health_data
(
cluster_presenter
)
}
before
do
allow
(
helper
).
to
receive
(
:clusterable
).
and_return
(
clusterable_presenter
)
end
it
do
is_expected
.
to
match
(
'clusters-path'
:
clusterable_presenter
.
index_path
,
'metrics-endpoint'
:
clusterable_presenter
.
metrics_cluster_path
(
cluster
,
format: :json
),
'dashboard-endpoint'
:
clusterable_presenter
.
metrics_dashboard_path
(
cluster
),
'documentation-path'
:
help_page_path
(
'user/project/clusters/index'
,
anchor:
'monitoring-your-kubernetes-cluster-ultimate'
),
'empty-getting-started-svg-path'
:
match_asset_path
(
'/assets/illustrations/monitoring/getting_started.svg'
),
'empty-loading-svg-path'
:
match_asset_path
(
'/assets/illustrations/monitoring/loading.svg'
),
'empty-no-data-svg-path'
:
match_asset_path
(
'/assets/illustrations/monitoring/no_data.svg'
),
'empty-unable-to-connect-svg-path'
:
match_asset_path
(
'/assets/illustrations/monitoring/unable_to_connect.svg'
),
'settings-path'
:
''
,
'project-path'
:
''
,
'tags-path'
:
''
)
end
end
context
'with project cluster'
do
let
(
:cluster
)
{
create
(
:cluster
,
:project
,
:provided_by_gcp
)
}
let
(
:clusterable
)
{
cluster
.
project
}
it_behaves_like
'cluster health data'
end
context
'with group cluster'
do
let
(
:cluster
)
{
create
(
:cluster
,
:group
,
:provided_by_gcp
)
}
let
(
:clusterable
)
{
cluster
.
group
}
it_behaves_like
'cluster health data'
end
end
end
ee/spec/presenters/ee/clusters/cluster_presenter_spec.rb
0 → 100644
View file @
531dec33
# frozen_string_literal: true
require
'spec_helper'
describe
Clusters
::
ClusterPresenter
do
include
Gitlab
::
Routing
.
url_helpers
describe
'#health_data'
do
shared_examples
'cluster health data'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:cluster_presenter
)
{
cluster
.
present
(
current_user:
user
)
}
let
(
:clusterable_presenter
)
do
ClusterablePresenter
.
fabricate
(
clusterable
,
current_user:
user
)
end
subject
{
cluster_presenter
.
health_data
(
clusterable_presenter
)
}
it
do
is_expected
.
to
match
(
'clusters-path'
:
clusterable_presenter
.
index_path
,
'metrics-endpoint'
:
clusterable_presenter
.
metrics_cluster_path
(
cluster
,
format: :json
),
'dashboard-endpoint'
:
clusterable_presenter
.
metrics_dashboard_path
(
cluster
),
'documentation-path'
:
help_page_path
(
'user/project/clusters/index'
,
anchor:
'monitoring-your-kubernetes-cluster-ultimate'
),
'empty-getting-started-svg-path'
:
match_asset_path
(
'/assets/illustrations/monitoring/getting_started.svg'
),
'empty-loading-svg-path'
:
match_asset_path
(
'/assets/illustrations/monitoring/loading.svg'
),
'empty-no-data-svg-path'
:
match_asset_path
(
'/assets/illustrations/monitoring/no_data.svg'
),
'empty-unable-to-connect-svg-path'
:
match_asset_path
(
'/assets/illustrations/monitoring/unable_to_connect.svg'
),
'settings-path'
:
''
,
'project-path'
:
''
,
'tags-path'
:
''
)
end
end
context
'with project cluster'
do
let
(
:cluster
)
{
create
(
:cluster
,
:project
,
:provided_by_gcp
)
}
let
(
:clusterable
)
{
cluster
.
project
}
it_behaves_like
'cluster health data'
end
context
'with group cluster'
do
let
(
:cluster
)
{
create
(
:cluster
,
:group
,
:provided_by_gcp
)
}
let
(
:clusterable
)
{
cluster
.
group
}
it_behaves_like
'cluster health data'
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