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
5c088584
Commit
5c088584
authored
May 29, 2019
by
Reuben Pereira
Committed by
Bob Van Landuyt
May 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make external_dashboard_url available to frontend
- On Operations settings page - On Metrics dashboard page
parent
b7bf9a28
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
2 deletions
+79
-2
app/helpers/environments_helper.rb
app/helpers/environments_helper.rb
+2
-1
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+4
-0
app/models/project.rb
app/models/project.rb
+1
-0
app/views/projects/settings/operations/_external_dashboard.html.haml
...rojects/settings/operations/_external_dashboard.html.haml
+1
-1
spec/helpers/environments_helper_spec.rb
spec/helpers/environments_helper_spec.rb
+49
-0
spec/helpers/projects_helper_spec.rb
spec/helpers/projects_helper_spec.rb
+22
-0
No files found.
app/helpers/environments_helper.rb
View file @
5c088584
...
...
@@ -30,7 +30,8 @@ module EnvironmentsHelper
"environments-endpoint"
:
project_environments_path
(
project
,
format: :json
),
"project-path"
=>
project_path
(
project
),
"tags-path"
=>
project_tags_path
(
project
),
"has-metrics"
=>
"
#{
environment
.
has_metrics?
}
"
"has-metrics"
=>
"
#{
environment
.
has_metrics?
}
"
,
"external-dashboard-url"
=>
project
.
metrics_setting_external_dashboard_url
}
end
end
app/helpers/projects_helper.rb
View file @
5c088584
...
...
@@ -343,6 +343,10 @@ module ProjectsHelper
description
.
html_safe
%
{
project_name:
project
.
name
}
end
def
metrics_external_dashboard_url
@project
.
metrics_setting_external_dashboard_url
end
private
def
get_project_nav_tabs
(
project
,
current_user
)
...
...
app/models/project.rb
View file @
5c088584
...
...
@@ -309,6 +309,7 @@ class Project < ApplicationRecord
delegate
:group_clusters_enabled?
,
to: :group
,
allow_nil:
true
delegate
:root_ancestor
,
to: :namespace
,
allow_nil:
true
delegate
:last_pipeline
,
to: :commit
,
allow_nil:
true
delegate
:external_dashboard_url
,
to: :metrics_setting
,
allow_nil:
true
,
prefix:
true
# Validations
validates
:creator
,
presence:
true
,
on: :create
...
...
app/views/projects/settings/operations/_external_dashboard.html.haml
View file @
5c088584
.js-operation-settings
{
data:
{
external_dashboard:
{
path:
''
,
.js-operation-settings
{
data:
{
external_dashboard:
{
path:
metrics_external_dashboard_url
,
help_page_path:
help_page_path
(
'user/project/operations/link_to_external_dashboard'
)
}
}
}
spec/helpers/environments_helper_spec.rb
0 → 100644
View file @
5c088584
# frozen_string_literal: true
require
'spec_helper'
describe
EnvironmentsHelper
do
set
(
:environment
)
{
create
(
:environment
)
}
set
(
:project
)
{
environment
.
project
}
set
(
:user
)
{
create
(
:user
)
}
describe
'#metrics_data'
do
before
do
# This is so that this spec also passes in EE.
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
helper
).
to
receive
(
:can?
).
and_return
(
true
)
end
let
(
:metrics_data
)
{
helper
.
metrics_data
(
project
,
environment
)
}
it
'returns data'
do
expect
(
metrics_data
).
to
include
(
'settings-path'
=>
edit_project_service_path
(
project
,
'prometheus'
),
'clusters-path'
=>
project_clusters_path
(
project
),
'current-environment-name'
:
environment
.
name
,
'documentation-path'
=>
help_page_path
(
'administration/monitoring/prometheus/index.md'
),
'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'
),
'metrics-endpoint'
=>
additional_metrics_project_environment_path
(
project
,
environment
,
format: :json
),
'deployment-endpoint'
=>
project_environment_deployments_path
(
project
,
environment
,
format: :json
),
'environments-endpoint'
:
project_environments_path
(
project
,
format: :json
),
'project-path'
=>
project_path
(
project
),
'tags-path'
=>
project_tags_path
(
project
),
'has-metrics'
=>
"
#{
environment
.
has_metrics?
}
"
,
'external-dashboard-url'
=>
nil
)
end
context
'with metrics_setting'
do
before
do
create
(
:project_metrics_setting
,
project:
project
,
external_dashboard_url:
'http://gitlab.com'
)
end
it
'adds external_dashboard_url'
do
expect
(
metrics_data
[
'external-dashboard-url'
]).
to
eq
(
'http://gitlab.com'
)
end
end
end
end
spec/helpers/projects_helper_spec.rb
View file @
5c088584
...
...
@@ -819,4 +819,26 @@ describe ProjectsHelper do
expect
(
helper
.
can_import_members?
).
to
eq
true
end
end
describe
'#metrics_external_dashboard_url'
do
let
(
:project
)
{
create
(
:project
)
}
before
do
helper
.
instance_variable_set
(
:@project
,
project
)
end
context
'metrics_setting exists'
do
it
'returns external_dashboard_url'
do
metrics_setting
=
create
(
:project_metrics_setting
,
project:
project
)
expect
(
helper
.
metrics_external_dashboard_url
).
to
eq
(
metrics_setting
.
external_dashboard_url
)
end
end
context
'metrics_setting does not exist'
do
it
'returns nil'
do
expect
(
helper
.
metrics_external_dashboard_url
).
to
eq
(
nil
)
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