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
3af502dc
Commit
3af502dc
authored
Jun 18, 2020
by
Tristan Read
Committed by
Kushal Pandya
Jun 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search plain text in alert list frontend
parent
15efe30e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
6 deletions
+68
-6
app/assets/javascripts/alert_management/components/alert_management_list.vue
...pts/alert_management/components/alert_management_list.vue
+30
-4
app/assets/javascripts/alert_management/graphql/queries/get_alerts.query.graphql
...alert_management/graphql/queries/get_alerts.query.graphql
+2
-0
app/assets/javascripts/alert_management/graphql/queries/get_count_by_status.query.graphql
...agement/graphql/queries/get_count_by_status.query.graphql
+7
-2
changelogs/unreleased/tr-alert-text-search.yml
changelogs/unreleased/tr-alert-text-search.yml
+5
-0
spec/frontend/alert_management/components/alert_management_list_spec.js
...alert_management/components/alert_management_list_spec.js
+24
-0
No files found.
app/assets/javascripts/alert_management/components/alert_management_list.vue
View file @
3af502dc
...
@@ -13,10 +13,12 @@ import {
...
@@ -13,10 +13,12 @@ import {
GlTab
,
GlTab
,
GlBadge
,
GlBadge
,
GlPagination
,
GlPagination
,
GlSearchBoxByType
,
GlSprintf
,
GlSprintf
,
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
__
,
s__
}
from
'
~/locale
'
;
import
{
debounce
,
trim
}
from
'
lodash
'
;
import
{
joinPaths
,
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
joinPaths
,
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
fetchPolicies
}
from
'
~/lib/graphql
'
;
import
{
fetchPolicies
}
from
'
~/lib/graphql
'
;
import
TimeAgo
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
TimeAgo
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
...
@@ -54,6 +56,7 @@ export default {
...
@@ -54,6 +56,7 @@ export default {
errorMsg
:
s__
(
errorMsg
:
s__
(
"
AlertManagement|There was an error displaying the alerts. Confirm your endpoint's configuration details to ensure alerts appear.
"
,
"
AlertManagement|There was an error displaying the alerts. Confirm your endpoint's configuration details to ensure alerts appear.
"
,
),
),
searchPlaceholder
:
__
(
'
Search or filter results...
'
),
},
},
fields
:
[
fields
:
[
{
{
...
@@ -126,6 +129,7 @@ export default {
...
@@ -126,6 +129,7 @@ export default {
GlTab
,
GlTab
,
GlBadge
,
GlBadge
,
GlPagination
,
GlPagination
,
GlSearchBoxByType
,
GlSprintf
,
GlSprintf
,
},
},
props
:
{
props
:
{
...
@@ -160,6 +164,7 @@ export default {
...
@@ -160,6 +164,7 @@ export default {
query
:
getAlerts
,
query
:
getAlerts
,
variables
()
{
variables
()
{
return
{
return
{
searchTerm
:
this
.
searchTerm
,
projectPath
:
this
.
projectPath
,
projectPath
:
this
.
projectPath
,
statuses
:
this
.
statusFilter
,
statuses
:
this
.
statusFilter
,
sort
:
this
.
sort
,
sort
:
this
.
sort
,
...
@@ -186,6 +191,7 @@ export default {
...
@@ -186,6 +191,7 @@ export default {
query
:
getAlertsCountByStatus
,
query
:
getAlertsCountByStatus
,
variables
()
{
variables
()
{
return
{
return
{
searchTerm
:
this
.
searchTerm
,
projectPath
:
this
.
projectPath
,
projectPath
:
this
.
projectPath
,
};
};
},
},
...
@@ -196,6 +202,7 @@ export default {
...
@@ -196,6 +202,7 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
searchTerm
:
''
,
errored
:
false
,
errored
:
false
,
isAlertDismissed
:
false
,
isAlertDismissed
:
false
,
isErrorAlertDismissed
:
false
,
isErrorAlertDismissed
:
false
,
...
@@ -211,7 +218,11 @@ export default {
...
@@ -211,7 +218,11 @@ export default {
computed
:
{
computed
:
{
showNoAlertsMsg
()
{
showNoAlertsMsg
()
{
return
(
return
(
!
this
.
errored
&&
!
this
.
loading
&&
this
.
alertsCount
?.
all
===
0
&&
!
this
.
isAlertDismissed
!
this
.
errored
&&
!
this
.
loading
&&
this
.
alertsCount
?.
all
===
0
&&
!
this
.
searchTerm
&&
!
this
.
isAlertDismissed
);
);
},
},
showErrorMsg
()
{
showErrorMsg
()
{
...
@@ -257,6 +268,13 @@ export default {
...
@@ -257,6 +268,13 @@ export default {
this
.
resetPagination
();
this
.
resetPagination
();
this
.
sort
=
`
${
sortingColumn
}
_
${
sortingDirection
}
`
;
this
.
sort
=
`
${
sortingColumn
}
_
${
sortingDirection
}
`
;
},
},
onInputChange
:
debounce
(
function
debounceSearch
(
input
)
{
const
trimmedInput
=
trim
(
input
);
if
(
trimmedInput
!==
this
.
searchTerm
)
{
this
.
resetPagination
();
this
.
searchTerm
=
trimmedInput
;
}
},
500
),
updateAlertStatus
(
status
,
iid
)
{
updateAlertStatus
(
status
,
iid
)
{
this
.
$apollo
this
.
$apollo
.
mutate
({
.
mutate
({
...
@@ -343,7 +361,7 @@ export default {
...
@@ -343,7 +361,7 @@ export default {
{{ $options.i18n.errorMsg }}
{{ $options.i18n.errorMsg }}
</gl-alert>
</gl-alert>
<gl-tabs
@
input=
"filterAlertsByStatus"
>
<gl-tabs
content-class=
"gl-p-0"
@
input=
"filterAlertsByStatus"
>
<gl-tab
v-for=
"tab in $options.statusTabs"
:key=
"tab.status"
>
<gl-tab
v-for=
"tab in $options.statusTabs"
:key=
"tab.status"
>
<
template
slot=
"title"
>
<
template
slot=
"title"
>
<span>
{{
tab
.
title
}}
</span>
<span>
{{
tab
.
title
}}
</span>
...
@@ -354,11 +372,19 @@ export default {
...
@@ -354,11 +372,19 @@ export default {
</gl-tab>
</gl-tab>
</gl-tabs>
</gl-tabs>
<div
class=
"gl-bg-gray-10 gl-p-5 gl-border-b-solid gl-border-b-1 gl-border-gray-100"
>
<gl-search-box-by-type
class=
"gl-bg-white"
:placeholder=
"$options.i18n.searchPlaceholder"
@
input=
"onInputChange"
/>
</div>
<h4
class=
"d-block d-md-none my-3"
>
<h4
class=
"d-block d-md-none my-3"
>
{{ s__('AlertManagement|Alerts') }}
{{ s__('AlertManagement|Alerts') }}
</h4>
</h4>
<gl-table
<gl-table
class=
"alert-management-table
mt-3
"
class=
"alert-management-table"
:items=
"alerts ? alerts.list : []"
:items=
"alerts ? alerts.list : []"
:fields=
"$options.fields"
:fields=
"$options.fields"
:show-empty=
"true"
:show-empty=
"true"
...
...
app/assets/javascripts/alert_management/graphql/queries/get_alerts.query.graphql
View file @
3af502dc
#import "../fragments/list_item.fragment.graphql"
#import "../fragments/list_item.fragment.graphql"
query
getAlerts
(
query
getAlerts
(
$searchTerm
:
String
,
$projectPath
:
ID
!,
$projectPath
:
ID
!,
$statuses
:
[
AlertManagementStatus
!],
$statuses
:
[
AlertManagementStatus
!],
$sort
:
AlertManagementAlertSort
,
$sort
:
AlertManagementAlertSort
,
...
@@ -11,6 +12,7 @@ query getAlerts(
...
@@ -11,6 +12,7 @@ query getAlerts(
)
{
)
{
project
(
fullPath
:
$projectPath
,
)
{
project
(
fullPath
:
$projectPath
,
)
{
alertManagementAlerts
(
alertManagementAlerts
(
search
:
$searchTerm
,
statuses
:
$statuses
,
statuses
:
$statuses
,
sort
:
$sort
,
sort
:
$sort
,
first
:
$firstPageSize
first
:
$firstPageSize
...
...
app/assets/javascripts/alert_management/graphql/queries/get_count_by_status.query.graphql
View file @
3af502dc
query
getAlertsCount
(
$projectPath
:
ID
!)
{
query
getAlertsCount
(
$searchTerm
:
String
,
$projectPath
:
ID
!
)
{
project
(
fullPath
:
$projectPath
)
{
project
(
fullPath
:
$projectPath
)
{
alertManagementAlertStatusCounts
{
alertManagementAlertStatusCounts
(
search
:
$searchTerm
)
{
all
all
open
open
acknowledged
acknowledged
...
...
changelogs/unreleased/tr-alert-text-search.yml
0 → 100644
View file @
3af502dc
---
title
:
Search plain text in alert list frontend
merge_request
:
34631
author
:
type
:
added
spec/frontend/alert_management/components/alert_management_list_spec.js
View file @
3af502dc
...
@@ -11,6 +11,7 @@ import {
...
@@ -11,6 +11,7 @@ import {
GlTab
,
GlTab
,
GlBadge
,
GlBadge
,
GlPagination
,
GlPagination
,
GlSearchBoxByType
,
}
from
'
@gitlab/ui
'
;
}
from
'
@gitlab/ui
'
;
import
{
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
TimeAgo
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
TimeAgo
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
...
@@ -49,6 +50,7 @@ describe('AlertManagementList', () => {
...
@@ -49,6 +50,7 @@ describe('AlertManagementList', () => {
const
findSeverityFields
=
()
=>
wrapper
.
findAll
(
'
[data-testid="severityField"]
'
);
const
findSeverityFields
=
()
=>
wrapper
.
findAll
(
'
[data-testid="severityField"]
'
);
const
findSeverityColumnHeader
=
()
=>
wrapper
.
findAll
(
'
th
'
).
at
(
0
);
const
findSeverityColumnHeader
=
()
=>
wrapper
.
findAll
(
'
th
'
).
at
(
0
);
const
findPagination
=
()
=>
wrapper
.
find
(
GlPagination
);
const
findPagination
=
()
=>
wrapper
.
find
(
GlPagination
);
const
findSearch
=
()
=>
wrapper
.
find
(
GlSearchBoxByType
);
const
alertsCount
=
{
const
alertsCount
=
{
open
:
14
,
open
:
14
,
triggered
:
10
,
triggered
:
10
,
...
@@ -487,4 +489,26 @@ describe('AlertManagementList', () => {
...
@@ -487,4 +489,26 @@ describe('AlertManagementList', () => {
});
});
});
});
});
});
describe
(
'
Search
'
,
()
=>
{
beforeEach
(()
=>
{
mountComponent
({
props
:
{
alertManagementEnabled
:
true
,
userCanEnableAlertManagement
:
true
},
data
:
{
alerts
:
{
list
:
mockAlerts
},
alertsCount
,
errored
:
false
},
loading
:
false
,
});
});
it
(
'
renders the search component
'
,
()
=>
{
expect
(
findSearch
().
exists
()).
toBe
(
true
);
});
it
(
'
sets the `searchTerm` graphql variable
'
,
()
=>
{
const
SEARCH_TERM
=
'
Simple Alert
'
;
findSearch
().
vm
.
$emit
(
'
input
'
,
SEARCH_TERM
);
expect
(
wrapper
.
vm
.
$data
.
searchTerm
).
toBe
(
SEARCH_TERM
);
});
});
});
});
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