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
2a043397
Commit
2a043397
authored
May 06, 2020
by
lauraMon
Committed by
Olena Horal-Koretska
May 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update status for alert in alert management list
parent
1c702f54
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
139 additions
and
17 deletions
+139
-17
app/assets/javascripts/alert_management/components/alert_management_list.vue
...pts/alert_management/components/alert_management_list.vue
+50
-9
app/assets/javascripts/alert_management/graphql/mutations/update_alert_status.graphql
..._management/graphql/mutations/update_alert_status.graphql
+9
-0
app/assets/javascripts/alert_management/list.js
app/assets/javascripts/alert_management/list.js
+15
-1
ee/spec/frontend/security_dashboard/components/selection_summary_spec.js
...d/security_dashboard/components/selection_summary_spec.js
+0
-1
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/frontend/alert_management/components/alert_management_list_spec.js
...alert_management/components/alert_management_list_spec.js
+59
-3
spec/frontend/alert_management/mocks/alerts.json
spec/frontend/alert_management/mocks/alerts.json
+3
-3
No files found.
app/assets/javascripts/alert_management/components/alert_management_list.vue
View file @
2a043397
...
@@ -5,17 +5,21 @@ import {
...
@@ -5,17 +5,21 @@ import {
GlLoadingIcon
,
GlLoadingIcon
,
GlTable
,
GlTable
,
GlAlert
,
GlAlert
,
GlNewDropdown
,
GlIcon
,
GlNewDropdownItem
,
GlDropdown
,
GlDropdownItem
,
GlTabs
,
GlTabs
,
GlTab
,
GlTab
,
GlBadge
,
GlBadge
,
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
createFlash
from
'
~/flash
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
}
from
'
~/locale
'
;
import
TimeAgo
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
TimeAgo
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
getAlerts
from
'
../graphql/queries/getAlerts.query.graphql
'
;
import
getAlerts
from
'
../graphql/queries/getAlerts.query.graphql
'
;
import
{
ALERTS_STATUS
,
ALERTS_STATUS_TABS
}
from
'
../constants
'
;
import
{
ALERTS_STATUS
,
ALERTS_STATUS_TABS
}
from
'
../constants
'
;
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
updateAlertStatus
from
'
../graphql/mutations/update_alert_status.graphql
'
;
import
{
capitalizeFirstCharacter
}
from
'
~/lib/utils/text_utility
'
;
const
tdClass
=
'
table-col d-flex d-md-table-cell align-items-center
'
;
const
tdClass
=
'
table-col d-flex d-md-table-cell align-items-center
'
;
...
@@ -53,6 +57,8 @@ export default {
...
@@ -53,6 +57,8 @@ export default {
},
},
{
{
key
:
'
status
'
,
key
:
'
status
'
,
thClass
:
'
w-15p
'
,
trClass
:
'
w-15p
'
,
label
:
s__
(
'
AlertManagement|Status
'
),
label
:
s__
(
'
AlertManagement|Status
'
),
tdClass
:
`
${
tdClass
}
rounded-bottom text-capitalize`
,
tdClass
:
`
${
tdClass
}
rounded-bottom text-capitalize`
,
},
},
...
@@ -70,8 +76,9 @@ export default {
...
@@ -70,8 +76,9 @@ export default {
GlAlert
,
GlAlert
,
GlDeprecatedButton
,
GlDeprecatedButton
,
TimeAgo
,
TimeAgo
,
GlNewDropdown
,
GlDropdown
,
GlNewDropdownItem
,
GlDropdownItem
,
GlIcon
,
GlTabs
,
GlTabs
,
GlTab
,
GlTab
,
GlBadge
,
GlBadge
,
...
@@ -140,6 +147,25 @@ export default {
...
@@ -140,6 +147,25 @@ export default {
filterALertsByStatus
(
tabIndex
)
{
filterALertsByStatus
(
tabIndex
)
{
this
.
statusFilter
=
this
.
$options
.
statusTabs
[
tabIndex
].
status
;
this
.
statusFilter
=
this
.
$options
.
statusTabs
[
tabIndex
].
status
;
},
},
capitalizeFirstCharacter
,
updateAlertStatus
(
status
,
iid
)
{
this
.
$apollo
.
mutate
({
mutation
:
updateAlertStatus
,
variables
:
{
iid
,
status
:
status
.
toUpperCase
(),
projectPath
:
this
.
projectPath
,
},
})
.
catch
(()
=>
{
createFlash
(
s__
(
'
AlertManagement|There was an error while updating the status of the alert. Please try again.
'
,
),
);
});
},
},
},
};
};
</
script
>
</
script
>
...
@@ -190,11 +216,26 @@ export default {
...
@@ -190,11 +216,26 @@ export default {
</
template
>
</
template
>
<
template
#cell(status)=
"{ item }"
>
<
template
#cell(status)=
"{ item }"
>
<gl-new-dropdown
:text=
"item.status"
>
<gl-dropdown
<gl-new-dropdown-item
v-for=
"(label, field) in $options.statuses"
:key=
"field"
>
:text=
"capitalizeFirstCharacter(item.status.toLowerCase())"
{{
label
}}
class=
"w-100"
</gl-new-dropdown-item>
right
</gl-new-dropdown>
>
<gl-dropdown-item
v-for=
"(label, field) in $options.statuses"
:key=
"field"
@
click=
"updateAlertStatus(label, item.iid)"
>
<span
class=
"d-flex"
>
<gl-icon
class=
"flex-shrink-0 append-right-4"
:class=
"
{ invisible: label.toUpperCase() !== item.status }"
name="mobile-issue-close"
/>
{{
label
}}
</span>
</gl-dropdown-item>
</gl-dropdown>
</
template
>
</
template
>
<
template
#empty
>
<
template
#empty
>
...
...
app/assets/javascripts/alert_management/graphql/mutations/update_alert_status.graphql
0 → 100644
View file @
2a043397
mutation
(
$projectPath
:
ID
!,
$status
:
AlertManagementStatus
!,
$iid
:
String
!)
{
updateAlertStatus
(
input
:
{
iid
:
$iid
,
status
:
$status
,
projectPath
:
$projectPath
})
{
errors
alert
{
iid
,
status
,
}
}
}
app/assets/javascripts/alert_management/list.js
View file @
2a043397
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
import
{
defaultDataIdFromObject
}
from
'
apollo-cache-inmemory
'
;
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
AlertManagementList
from
'
./components/alert_management_list.vue
'
;
import
AlertManagementList
from
'
./components/alert_management_list.vue
'
;
...
@@ -17,7 +18,20 @@ export default () => {
...
@@ -17,7 +18,20 @@ export default () => {
userCanEnableAlertManagement
=
parseBoolean
(
userCanEnableAlertManagement
);
userCanEnableAlertManagement
=
parseBoolean
(
userCanEnableAlertManagement
);
const
apolloProvider
=
new
VueApollo
({
const
apolloProvider
=
new
VueApollo
({
defaultClient
:
createDefaultClient
(),
defaultClient
:
createDefaultClient
(
{},
{
cacheConfig
:
{
dataIdFromObject
:
object
=>
{
// eslint-disable-next-line no-underscore-dangle
if
(
object
.
__typename
===
'
AlertManagementAlert
'
)
{
return
object
.
iid
;
}
return
defaultDataIdFromObject
(
object
);
},
},
},
),
});
});
return
new
Vue
({
return
new
Vue
({
...
...
ee/spec/frontend/security_dashboard/components/selection_summary_spec.js
View file @
2a043397
...
@@ -25,7 +25,6 @@ describe('Selection Summary component', () => {
...
@@ -25,7 +25,6 @@ describe('Selection Summary component', () => {
const
dismissButton
=
()
=>
wrapper
.
find
(
GlButton
);
const
dismissButton
=
()
=>
wrapper
.
find
(
GlButton
);
const
dismissMessage
=
()
=>
wrapper
.
find
({
ref
:
'
dismiss-message
'
});
const
dismissMessage
=
()
=>
wrapper
.
find
({
ref
:
'
dismiss-message
'
});
const
formSelect
=
()
=>
wrapper
.
find
(
GlFormSelect
);
const
formSelect
=
()
=>
wrapper
.
find
(
GlFormSelect
);
const
createComponent
=
({
props
=
{},
data
=
defaultData
,
mocks
=
defaultMocks
})
=>
{
const
createComponent
=
({
props
=
{},
data
=
defaultData
,
mocks
=
defaultMocks
})
=>
{
if
(
wrapper
)
{
if
(
wrapper
)
{
throw
new
Error
(
'
Please avoid recreating components in the same spec
'
);
throw
new
Error
(
'
Please avoid recreating components in the same spec
'
);
...
...
locale/gitlab.pot
View file @
2a043397
...
@@ -1790,6 +1790,9 @@ msgstr ""
...
@@ -1790,6 +1790,9 @@ msgstr ""
msgid "AlertManagement|There was an error displaying the alerts. Confirm your endpoint's configuration details to ensure alerts appear."
msgid "AlertManagement|There was an error displaying the alerts. Confirm your endpoint's configuration details to ensure alerts appear."
msgstr ""
msgstr ""
msgid "AlertManagement|There was an error while updating the status of the alert. Please try again."
msgstr ""
msgid "AlertManagement|Tool"
msgid "AlertManagement|Tool"
msgstr ""
msgstr ""
...
...
spec/frontend/alert_management/components/alert_management_list_spec.js
View file @
2a043397
...
@@ -4,16 +4,20 @@ import {
...
@@ -4,16 +4,20 @@ import {
GlTable
,
GlTable
,
GlAlert
,
GlAlert
,
GlLoadingIcon
,
GlLoadingIcon
,
Gl
New
Dropdown
,
GlDropdown
,
GlBadge
,
GlBadge
,
GlTab
,
GlTab
,
GlDropdownItem
,
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
TimeAgo
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
TimeAgo
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
createFlash
from
'
~/flash
'
;
import
AlertManagementList
from
'
~/alert_management/components/alert_management_list.vue
'
;
import
AlertManagementList
from
'
~/alert_management/components/alert_management_list.vue
'
;
import
{
ALERTS_STATUS_TABS
}
from
'
../../../../app/assets/javascripts/alert_management/constants
'
;
import
{
ALERTS_STATUS_TABS
}
from
'
../../../../app/assets/javascripts/alert_management/constants
'
;
import
updateAlertStatus
from
'
~/alert_management/graphql/mutations/update_alert_status.graphql
'
;
import
mockAlerts
from
'
../mocks/alerts.json
'
;
import
mockAlerts
from
'
../mocks/alerts.json
'
;
jest
.
mock
(
'
~/flash
'
);
describe
(
'
AlertManagementList
'
,
()
=>
{
describe
(
'
AlertManagementList
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
...
@@ -21,10 +25,11 @@ describe('AlertManagementList', () => {
...
@@ -21,10 +25,11 @@ describe('AlertManagementList', () => {
const
findAlerts
=
()
=>
wrapper
.
findAll
(
'
table tbody tr
'
);
const
findAlerts
=
()
=>
wrapper
.
findAll
(
'
table tbody tr
'
);
const
findAlert
=
()
=>
wrapper
.
find
(
GlAlert
);
const
findAlert
=
()
=>
wrapper
.
find
(
GlAlert
);
const
findLoader
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findLoader
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findStatusDropdown
=
()
=>
wrapper
.
find
(
Gl
New
Dropdown
);
const
findStatusDropdown
=
()
=>
wrapper
.
find
(
GlDropdown
);
const
findStatusFilterTabs
=
()
=>
wrapper
.
findAll
(
GlTab
);
const
findStatusFilterTabs
=
()
=>
wrapper
.
findAll
(
GlTab
);
const
findNumberOfAlertsBadge
=
()
=>
wrapper
.
findAll
(
GlBadge
);
const
findNumberOfAlertsBadge
=
()
=>
wrapper
.
findAll
(
GlBadge
);
const
findDateFields
=
()
=>
wrapper
.
findAll
(
TimeAgo
);
const
findDateFields
=
()
=>
wrapper
.
findAll
(
TimeAgo
);
const
findFirstStatusOption
=
()
=>
findStatusDropdown
().
find
(
GlDropdownItem
);
function
mountComponent
({
function
mountComponent
({
props
=
{
props
=
{
...
@@ -51,6 +56,7 @@ describe('AlertManagementList', () => {
...
@@ -51,6 +56,7 @@ describe('AlertManagementList', () => {
},
},
mocks
:
{
mocks
:
{
$apollo
:
{
$apollo
:
{
mutate
:
jest
.
fn
(),
queries
:
{
queries
:
{
alerts
:
{
alerts
:
{
loading
,
loading
,
...
@@ -191,6 +197,7 @@ describe('AlertManagementList', () => {
...
@@ -191,6 +197,7 @@ describe('AlertManagementList', () => {
alerts
:
[
alerts
:
[
{
{
iid
:
1
,
iid
:
1
,
status
:
'
acknowledged
'
,
startedAt
:
'
2020-03-17T23:18:14.996Z
'
,
startedAt
:
'
2020-03-17T23:18:14.996Z
'
,
endedAt
:
'
2020-04-17T23:18:14.996Z
'
,
endedAt
:
'
2020-04-17T23:18:14.996Z
'
,
},
},
...
@@ -209,6 +216,7 @@ describe('AlertManagementList', () => {
...
@@ -209,6 +216,7 @@ describe('AlertManagementList', () => {
alerts
:
[
alerts
:
[
{
{
iid
:
1
,
iid
:
1
,
status
:
'
acknowledged
'
,
startedAt
:
null
,
startedAt
:
null
,
endedAt
:
null
,
endedAt
:
null
,
},
},
...
@@ -221,4 +229,52 @@ describe('AlertManagementList', () => {
...
@@ -221,4 +229,52 @@ describe('AlertManagementList', () => {
});
});
});
});
});
});
describe
(
'
updating the alert status
'
,
()
=>
{
const
iid
=
'
1527542
'
;
const
mockUpdatedMutationResult
=
{
data
:
{
updateAlertStatus
:
{
errors
:
[],
alert
:
{
iid
,
status
:
'
acknowledged
'
,
},
},
},
};
beforeEach
(()
=>
{
mountComponent
({
props
:
{
alertManagementEnabled
:
true
,
userCanEnableAlertManagement
:
true
},
data
:
{
alerts
:
mockAlerts
,
errored
:
false
},
loading
:
false
,
});
});
it
(
'
calls `$apollo.mutate` with `updateAlertStatus` mutation and variables containing `iid`, `status`, & `projectPath`
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockResolvedValue
(
mockUpdatedMutationResult
);
findFirstStatusOption
().
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
vm
.
$apollo
.
mutate
).
toHaveBeenCalledWith
({
mutation
:
updateAlertStatus
,
variables
:
{
iid
,
status
:
'
TRIGGERED
'
,
projectPath
:
'
gitlab-org/gitlab
'
,
},
});
});
it
(
'
calls `createFlash` when request fails
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockReturnValue
(
Promise
.
reject
(
new
Error
()));
findFirstStatusOption
().
vm
.
$emit
(
'
click
'
);
setImmediate
(()
=>
{
expect
(
createFlash
).
toHaveBeenCalledWith
(
'
There was an error while updating the status of the alert. Please try again.
'
,
);
});
});
});
});
});
spec/frontend/alert_management/mocks/alerts.json
View file @
2a043397
...
@@ -9,8 +9,8 @@
...
@@ -9,8 +9,8 @@
"status"
:
"triggered"
"status"
:
"triggered"
},
},
{
{
"iid"
:
"152754
2
"
,
"iid"
:
"152754
3
"
,
"title"
:
"Some other
r alert Some otherr alert Some otherr alert Some otherr alert Some otherr alert Some other
r alert"
,
"title"
:
"Some other
alert Some other alert Some other alert Some other alert Some other alert Some othe
r alert"
,
"severity"
:
"MEDIUM"
,
"severity"
:
"MEDIUM"
,
"eventCount"
:
1
,
"eventCount"
:
1
,
"startedAt"
:
"2020-04-17T23:18:14.996Z"
,
"startedAt"
:
"2020-04-17T23:18:14.996Z"
,
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
"status"
:
"acknowledged"
"status"
:
"acknowledged"
},
},
{
{
"iid"
:
"152754
2
"
,
"iid"
:
"152754
4
"
,
"title"
:
"SyntaxError: Invalid or unexpected token"
,
"title"
:
"SyntaxError: Invalid or unexpected token"
,
"severity"
:
"LOW"
,
"severity"
:
"LOW"
,
"eventCount"
:
4
,
"eventCount"
:
4
,
...
...
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