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
1b7464ed
Commit
1b7464ed
authored
Jun 14, 2019
by
Sarah Yasonik
Committed by
Mayra Cabrera
Jun 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Specify a dropdown name for dashboards
parent
ae853dba
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
3 deletions
+55
-3
lib/gitlab/metrics/dashboard/project_dashboard_service.rb
lib/gitlab/metrics/dashboard/project_dashboard_service.rb
+12
-1
lib/gitlab/metrics/dashboard/system_dashboard_service.rb
lib/gitlab/metrics/dashboard/system_dashboard_service.rb
+2
-0
spec/lib/gitlab/metrics/dashboard/finder_spec.rb
spec/lib/gitlab/metrics/dashboard/finder_spec.rb
+2
-2
spec/lib/gitlab/metrics/dashboard/project_dashboard_service_spec.rb
...itlab/metrics/dashboard/project_dashboard_service_spec.rb
+25
-0
spec/lib/gitlab/metrics/dashboard/system_dashboard_service_spec.rb
...gitlab/metrics/dashboard/system_dashboard_service_spec.rb
+14
-0
No files found.
lib/gitlab/metrics/dashboard/project_dashboard_service.rb
View file @
1b7464ed
...
...
@@ -13,12 +13,23 @@ module Gitlab
def
all_dashboard_paths
(
project
)
file_finder
(
project
)
.
list_files_for
(
DASHBOARD_ROOT
)
.
map
{
|
filepath
|
{
path:
filepath
,
default:
false
}
}
.
map
do
|
filepath
|
{
path:
filepath
,
display_name:
name_for_path
(
filepath
),
default:
false
}
end
end
def
file_finder
(
project
)
Gitlab
::
Template
::
Finders
::
RepoTemplateFinder
.
new
(
project
,
DASHBOARD_ROOT
,
'.yml'
)
end
# Grabs the filepath after the base directory.
def
name_for_path
(
filepath
)
filepath
.
delete_prefix
(
"
#{
DASHBOARD_ROOT
}
/"
)
end
end
private
...
...
lib/gitlab/metrics/dashboard/system_dashboard_service.rb
View file @
1b7464ed
...
...
@@ -7,11 +7,13 @@ module Gitlab
module
Dashboard
class
SystemDashboardService
<
Gitlab
::
Metrics
::
Dashboard
::
BaseService
SYSTEM_DASHBOARD_PATH
=
'config/prometheus/common_metrics.yml'
SYSTEM_DASHBOARD_NAME
=
'Default'
class
<<
self
def
all_dashboard_paths
(
_project
)
[{
path:
SYSTEM_DASHBOARD_PATH
,
display_name:
SYSTEM_DASHBOARD_NAME
,
default:
true
}]
end
...
...
spec/lib/gitlab/metrics/dashboard/finder_spec.rb
View file @
1b7464ed
...
...
@@ -49,7 +49,7 @@ describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store_cachi
describe
'.find_all_paths'
do
let
(
:all_dashboard_paths
)
{
described_class
.
find_all_paths
(
project
)
}
let
(
:system_dashboard
)
{
{
path:
system_dashboard_path
,
default:
true
}
}
let
(
:system_dashboard
)
{
{
path:
system_dashboard_path
,
d
isplay_name:
'Default'
,
d
efault:
true
}
}
it
'includes only the system dashboard by default'
do
expect
(
all_dashboard_paths
).
to
eq
([
system_dashboard
])
...
...
@@ -60,7 +60,7 @@ describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store_cachi
let
(
:project
)
{
project_with_dashboard
(
dashboard_path
)
}
it
'includes system and project dashboards'
do
project_dashboard
=
{
path:
dashboard_path
,
default:
false
}
project_dashboard
=
{
path:
dashboard_path
,
d
isplay_name:
'test.yml'
,
d
efault:
false
}
expect
(
all_dashboard_paths
).
to
contain_exactly
(
system_dashboard
,
project_dashboard
)
end
...
...
spec/lib/gitlab/metrics/dashboard/project_dashboard_service_spec.rb
View file @
1b7464ed
...
...
@@ -59,4 +59,29 @@ describe Gitlab::Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_m
it_behaves_like
'misconfigured dashboard service response'
,
:unprocessable_entity
end
end
describe
'::all_dashboard_paths'
do
let
(
:all_dashboards
)
{
described_class
.
all_dashboard_paths
(
project
)
}
context
'when there are no project dashboards'
do
it
'returns an empty array'
do
expect
(
all_dashboards
).
to
be_empty
end
end
context
'when there are project dashboards available'
do
let
(
:dashboard_path
)
{
'.gitlab/dashboards/test.yml'
}
let
(
:project
)
{
project_with_dashboard
(
dashboard_path
)
}
it
'returns the dashboard attributes'
do
expect
(
all_dashboards
).
to
eq
(
[{
path:
dashboard_path
,
display_name:
'test.yml'
,
default:
false
}]
)
end
end
end
end
spec/lib/gitlab/metrics/dashboard/system_dashboard_service_spec.rb
View file @
1b7464ed
...
...
@@ -29,4 +29,18 @@ describe Gitlab::Metrics::Dashboard::SystemDashboardService, :use_clean_rails_me
it_behaves_like
'valid dashboard service response'
end
end
describe
'::all_dashboard_paths'
do
it
'returns the dashboard attributes'
do
all_dashboards
=
described_class
.
all_dashboard_paths
(
project
)
expect
(
all_dashboards
).
to
eq
(
[{
path:
described_class
::
SYSTEM_DASHBOARD_PATH
,
display_name:
described_class
::
SYSTEM_DASHBOARD_NAME
,
default:
true
}]
)
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