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
a7395c71
Commit
a7395c71
authored
Dec 10, 2020
by
Alexander Turinske
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update promises to async/await
- change alert status mutation to use async await - clean up tests
parent
d3e4fa9f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
20 deletions
+17
-20
ee/app/assets/javascripts/threat_monitoring/components/alerts/alert_status.vue
...ipts/threat_monitoring/components/alerts/alert_status.vue
+15
-18
ee/spec/frontend/threat_monitoring/components/alerts/alert_status_spec.js
.../threat_monitoring/components/alerts/alert_status_spec.js
+2
-2
No files found.
ee/app/assets/javascripts/threat_monitoring/components/alerts/alert_status.vue
View file @
a7395c71
...
...
@@ -40,34 +40,31 @@ export default {
handleError
()
{
this
.
$emit
(
'
alert-error
'
,
this
.
$options
.
i18n
.
updateError
);
},
updateAlertStatus
(
status
)
{
async
updateAlertStatus
(
status
)
{
this
.
isUpdating
=
true
;
this
.
status
=
status
;
t
his
.
$apollo
.
mutate
({
t
ry
{
const
{
data
}
=
await
this
.
$apollo
.
mutate
({
mutation
:
updateAlertStatusMutation
,
variables
:
{
iid
:
this
.
alert
.
iid
,
status
:
status
.
toUpperCase
(),
projectPath
:
this
.
projectPath
,
},
})
.
then
(
resp
=>
{
const
errors
=
resp
.
data
?.
updateAlertStatus
?.
errors
||
[];
if
(
errors
[
0
])
{
this
.
handleError
();
}
});
this
.
$emit
(
'
alert-update
'
);
})
.
catch
(()
=>
{
this
.
status
=
this
.
alert
.
status
;
const
errors
=
data
?.
updateAlertStatus
?.
errors
||
[];
if
(
errors
[
0
])
{
this
.
handleError
();
})
.
finally
(()
=>
{
this
.
isUpdating
=
false
;
});
}
this
.
$emit
(
'
alert-update
'
);
}
catch
{
this
.
status
=
this
.
alert
.
status
;
this
.
handleError
();
}
finally
{
this
.
isUpdating
=
false
;
}
},
},
};
...
...
ee/spec/frontend/threat_monitoring/components/alerts/alert_status_spec.js
View file @
a7395c71
...
...
@@ -77,7 +77,7 @@ describe('AlertStatus', () => {
it
(
'
emits to the list to refetch alerts on a successful alert status change
'
,
async
()
=>
{
expect
(
wrapper
.
emitted
(
'
alert-update
'
)).
toBeUndefined
();
await
selectFirstStatusOption
();
expect
(
wrapper
.
emitted
(
'
alert-update
'
)
.
length
).
toBe
(
1
);
expect
(
wrapper
.
emitted
(
'
alert-update
'
)
).
toHaveLength
(
1
);
});
});
...
...
@@ -98,7 +98,7 @@ describe('AlertStatus', () => {
await
selectFirstStatusOption
();
await
wrapper
.
vm
.
$nextTick
();
await
selectFirstStatusOption
();
expect
(
wrapper
.
emitted
(
'
alert-error
'
).
length
>
1
).
toBe
(
true
);
expect
(
wrapper
.
emitted
(
'
alert-error
'
).
length
).
toBeGreaterThan
(
1
);
});
it
(
'
reverts the status of an alert on failure
'
,
async
()
=>
{
...
...
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