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
2eee08f4
Commit
2eee08f4
authored
Feb 07, 2019
by
Simon Knox
Committed by
Fatih Acet
Feb 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't show Alert widget for non-licensed users
parent
f4dadfcd
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
116 additions
and
14 deletions
+116
-14
app/assets/javascripts/monitoring/components/dashboard.vue
app/assets/javascripts/monitoring/components/dashboard.vue
+4
-4
app/assets/javascripts/pages/projects/environments/metrics/index.js
.../javascripts/pages/projects/environments/metrics/index.js
+1
-1
ee/app/assets/javascripts/monitoring/components/dashboard_mixin.js
...sets/javascripts/monitoring/components/dashboard_mixin.js
+5
-0
ee/app/assets/javascripts/monitoring/monitoring_bundle.js
ee/app/assets/javascripts/monitoring/monitoring_bundle.js
+23
-0
ee/changelogs/unreleased/8346-hide-unlicensed-alerts.yml
ee/changelogs/unreleased/8346-hide-unlicensed-alerts.yml
+5
-0
ee/spec/javascripts/monitoring/components/dashboard_spec.js
ee/spec/javascripts/monitoring/components/dashboard_spec.js
+71
-0
spec/javascripts/monitoring/dashboard_spec.js
spec/javascripts/monitoring/dashboard_spec.js
+7
-9
No files found.
app/assets/javascripts/monitoring/components/dashboard.vue
View file @
2eee08f4
...
...
@@ -182,7 +182,8 @@ export default {
{{
s__
(
'
Metrics|Environment
'
)
}}
<div
class=
"dropdown prepend-left-10"
>
<button
class=
"dropdown-menu-toggle"
data-toggle=
"dropdown"
type=
"button"
>
<span>
{{
currentEnvironmentName
}}
</span>
<icon
name=
"chevron-down"
/>
<span>
{{
currentEnvironmentName
}}
</span>
<icon
name=
"chevron-down"
/>
</button>
<div
v-if=
"store.environmentsData.length > 0"
...
...
@@ -194,9 +195,8 @@ export default {
:href=
"environment.metrics_path"
:class=
"
{ 'is-active': environment.name == currentEnvironmentName }"
class="dropdown-item"
>
{{
environment
.
name
}}
</a
>
{{
environment
.
name
}}
</a>
</li>
</ul>
</div>
...
...
@@ -219,7 +219,7 @@ export default {
>
<!-- EE content -->
<alert-widget
v-if=
"alertsEndpoint && graphData.id"
v-if=
"
prometheusAlertsAvailable &&
alertsEndpoint && graphData.id"
:alerts-endpoint=
"alertsEndpoint"
:label=
"getGraphLabel(graphData)"
:current-alerts=
"getQueryAlerts(graphData)"
...
...
app/assets/javascripts/pages/projects/environments/metrics/index.js
View file @
2eee08f4
import
monitoringBundle
from
'
~
/monitoring/monitoring_bundle
'
;
import
monitoringBundle
from
'
ee_else_ce
/monitoring/monitoring_bundle
'
;
document
.
addEventListener
(
'
DOMContentLoaded
'
,
monitoringBundle
);
ee/app/assets/javascripts/monitoring/components/dashboard_mixin.js
View file @
2eee08f4
...
...
@@ -10,6 +10,11 @@ export default {
required
:
false
,
default
:
null
,
},
prometheusAlertsAvailable
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
data
()
{
return
{
...
...
ee/app/assets/javascripts/monitoring/monitoring_bundle.js
0 → 100644
View file @
2eee08f4
import
Vue
from
'
vue
'
;
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
Dashboard
from
'
~/monitoring/components/dashboard.vue
'
;
export
default
()
=>
{
const
el
=
document
.
getElementById
(
'
prometheus-graphs
'
);
if
(
el
&&
el
.
dataset
)
{
// eslint-disable-next-line no-new
new
Vue
({
el
,
render
(
createElement
)
{
return
createElement
(
Dashboard
,
{
props
:
{
...
el
.
dataset
,
hasMetrics
:
parseBoolean
(
el
.
dataset
.
hasMetrics
),
prometheusAlertsAvailable
:
parseBoolean
(
el
.
dataset
.
prometheusAlertsAvailable
),
},
});
},
});
}
};
ee/changelogs/unreleased/8346-hide-unlicensed-alerts.yml
0 → 100644
View file @
2eee08f4
---
title
:
Don't show Alert widget for non-licensed users
merge_request
:
9224
author
:
type
:
fixed
ee/spec/javascripts/monitoring/components/dashboard_spec.js
0 → 100644
View file @
2eee08f4
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
Dashboard
from
'
~/monitoring/components/dashboard.vue
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
metricsGroupsAPIResponse
,
mockApiEndpoint
}
from
'
spec/monitoring/mock_data
'
;
import
propsData
from
'
spec/monitoring/dashboard_spec
'
;
import
AlertWidget
from
'
ee/monitoring/components/alert_widget.vue
'
;
describe
(
'
Dashboard
'
,
()
=>
{
let
Component
;
let
mock
;
let
vm
;
const
localVue
=
createLocalVue
();
beforeEach
(()
=>
{
setFixtures
(
`
<div class="prometheus-graphs"></div>
<div class="layout-page"></div>
`
);
mock
=
new
MockAdapter
(
axios
);
Component
=
localVue
.
extend
(
Dashboard
);
});
afterEach
(()
=>
{
mock
.
restore
();
});
describe
(
'
metrics with alert
'
,
()
=>
{
describe
(
'
with license
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
mockApiEndpoint
).
reply
(
200
,
metricsGroupsAPIResponse
);
vm
=
shallowMount
(
Component
,
{
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
prometheusAlertsAvailable
:
true
,
alertsEndpoint
:
'
/endpoint
'
,
},
});
});
it
(
'
shows alert widget
'
,
done
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
find
(
AlertWidget
).
exists
()).
toBe
(
true
);
done
();
});
});
});
describe
(
'
without license
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
mockApiEndpoint
).
reply
(
200
,
metricsGroupsAPIResponse
);
vm
=
shallowMount
(
Component
,
{
propsData
:
{
...
propsData
,
hasMetrics
:
true
,
prometheusAlertsAvailable
:
false
,
alertsEndpoint
:
'
/endpoint
'
,
},
});
});
it
(
'
does not show alert widget
'
,
done
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
find
(
AlertWidget
).
exists
()).
toBe
(
false
);
done
();
});
});
});
});
});
spec/javascripts/monitoring/dashboard_spec.js
View file @
2eee08f4
...
...
@@ -25,15 +25,22 @@ export default propsData;
describe
(
'
Dashboard
'
,
()
=>
{
let
DashboardComponent
;
let
mock
;
beforeEach
(()
=>
{
setFixtures
(
`
<div class="prometheus-graphs"></div>
<div class="layout-page"></div>
`
);
mock
=
new
MockAdapter
(
axios
);
DashboardComponent
=
Vue
.
extend
(
Dashboard
);
});
afterEach
(()
=>
{
mock
.
restore
();
});
describe
(
'
no metrics are available yet
'
,
()
=>
{
it
(
'
shows a getting started empty state when no metrics are present
'
,
()
=>
{
const
component
=
new
DashboardComponent
({
...
...
@@ -47,16 +54,10 @@ describe('Dashboard', () => {
});
describe
(
'
requests information to the server
'
,
()
=>
{
let
mock
;
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
(
mockApiEndpoint
).
reply
(
200
,
metricsGroupsAPIResponse
);
});
afterEach
(()
=>
{
mock
.
restore
();
});
it
(
'
shows up a loading state
'
,
done
=>
{
const
component
=
new
DashboardComponent
({
el
:
document
.
querySelector
(
'
.prometheus-graphs
'
),
...
...
@@ -171,15 +172,12 @@ describe('Dashboard', () => {
});
describe
(
'
when the window resizes
'
,
()
=>
{
let
mock
;
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
(
mockApiEndpoint
).
reply
(
200
,
metricsGroupsAPIResponse
);
jasmine
.
clock
().
install
();
});
afterEach
(()
=>
{
mock
.
restore
();
jasmine
.
clock
().
uninstall
();
});
...
...
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