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
9d117cd5
Commit
9d117cd5
authored
Apr 30, 2020
by
Gilang Gumilar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auto-select single metric alert
parent
f05e3d46
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletion
+45
-1
app/assets/javascripts/monitoring/components/alert_widget_form.vue
...s/javascripts/monitoring/components/alert_widget_form.vue
+8
-1
changelogs/unreleased/210232-select-the-first-option-if-there-is-only-one-metric-option-on-a.yml
...-first-option-if-there-is-only-one-metric-option-on-a.yml
+5
-0
spec/frontend/monitoring/components/alert_widget_form_spec.js
.../frontend/monitoring/components/alert_widget_form_spec.js
+32
-0
No files found.
app/assets/javascripts/monitoring/components/alert_widget_form.vue
View file @
9d117cd5
...
...
@@ -177,6 +177,13 @@ export default {
prometheus_metric_id
:
this
.
prometheusMetricId
,
});
},
handleShown
()
{
if
(
this
.
configuredAlert
)
{
this
.
selectQuery
(
this
.
configuredAlert
);
}
else
if
(
this
.
relevantQueries
.
length
===
1
)
{
this
.
selectQuery
(
this
.
relevantQueries
[
0
].
metricId
);
}
},
resetAlertData
()
{
this
.
operator
=
null
;
this
.
threshold
=
null
;
...
...
@@ -212,7 +219,7 @@ export default {
:ok-disabled=
"formDisabled"
@
ok=
"handleSubmit"
@
hidden=
"handleHidden"
@
shown=
"
selectQuery(configuredAlert)
"
@
shown=
"
handleShown
"
>
<div
v-if=
"errorMessage"
class=
"alert-modal-message danger_message"
>
{{
errorMessage
}}
</div>
<div
class=
"alert-form"
>
...
...
changelogs/unreleased/210232-select-the-first-option-if-there-is-only-one-metric-option-on-a.yml
0 → 100644
View file @
9d117cd5
---
title
:
Select the first option if there is only one metric option on alerts dropdown.
merge_request
:
29857
author
:
Gilang Gumilar
type
:
added
spec/frontend/monitoring/components/alert_widget_form_spec.js
View file @
9d117cd5
...
...
@@ -127,6 +127,38 @@ describe('AlertWidgetForm', () => {
expect
(
wrapper
.
vm
.
selectedAlert
).
toEqual
(
propsWithAlertData
.
alertsToManage
[
alertPath
]);
});
it
(
'
sets selectedAlert to the first relevantQueries if there is only one option on modal show
'
,
()
=>
{
createComponent
({
...
propsWithAlertData
,
configuredAlert
:
''
,
});
modal
().
vm
.
$emit
(
'
shown
'
);
expect
(
wrapper
.
vm
.
selectedAlert
).
toEqual
(
propsWithAlertData
.
alertsToManage
[
alertPath
]);
});
it
(
'
does not set selectedAlert to the first relevantQueries if there is more than one option on modal show
'
,
()
=>
{
createComponent
({
relevantQueries
:
[
{
metricId
:
'
8
'
,
alertPath
:
'
alert
'
,
label
:
'
alert-label
'
,
},
{
metricId
:
'
9
'
,
alertPath
:
'
alert
'
,
label
:
'
alert-label
'
,
},
],
});
modal
().
vm
.
$emit
(
'
shown
'
);
expect
(
wrapper
.
vm
.
selectedAlert
).
toEqual
({});
});
describe
(
'
with existing alert
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
(
propsWithAlertData
);
...
...
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