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
9adb7fe9
Commit
9adb7fe9
authored
Mar 29, 2021
by
Alexander Turinske
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify dynamic count text
- create computed property for it - update tests
parent
ccb9310a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
12 deletions
+9
-12
ee/app/assets/javascripts/threat_monitoring/components/alerts/alert_filters.vue
...pts/threat_monitoring/components/alerts/alert_filters.vue
+7
-11
ee/spec/frontend/threat_monitoring/components/alerts/alert_filters_spec.js
...threat_monitoring/components/alerts/alert_filters_spec.js
+2
-1
No files found.
ee/app/assets/javascripts/threat_monitoring/components/alerts/alert_filters.vue
View file @
9adb7fe9
...
...
@@ -6,10 +6,9 @@ import {
GlFormGroup
,
GlIcon
,
GlSearchBoxByType
,
GlSprintf
,
GlTruncate
,
}
from
'
@gitlab/ui
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s
printf
,
s__
,
__
}
from
'
~/locale
'
;
import
{
ALL
,
DEBOUNCE
,
STATUSES
}
from
'
./constants
'
;
export
default
{
...
...
@@ -23,7 +22,6 @@ export default {
GlFormGroup
,
GlIcon
,
GlSearchBoxByType
,
GlSprintf
,
GlTruncate
,
},
props
:
{
...
...
@@ -54,6 +52,9 @@ export default {
const
firstOption
=
this
.
filters
.
statuses
?.
length
?
this
.
filters
.
statuses
[
0
]
:
undefined
;
return
this
.
$options
.
i18n
.
STATUSES
[
firstOption
]
||
this
.
$options
.
ALL
.
value
;
},
extraOptionText
()
{
return
sprintf
(
__
(
'
+%{extra} more
'
),
{
extra
:
this
.
extraOptionCount
});
},
},
methods
:
{
handleFilterChange
(
newFilters
)
{
...
...
@@ -109,14 +110,9 @@ export default {
<gl-dropdown
toggle-class=
"gl-inset-border-1-gray-400!"
class=
"gl-w-full"
>
<template
#button-content
>
<gl-truncate
:text=
"firstSelectedOption"
class=
"gl-min-w-0 gl-mr-2"
/>
<gl-sprintf
v-if=
"extraOptionCount > 0"
class=
"gl-mr-2"
:message=
"__('+%
{extra} more')"
data-testid="dropdown-message"
>
<template
#extra
>
{{
extraOptionCount
}}
</
template
>
</gl-sprintf>
<span
v-if=
"extraOptionCount > 0"
class=
"gl-mr-2"
>
{{
extraOptionText
}}
</span>
<gl-icon
name=
"chevron-down"
class=
"gl-flex-shrink-0 gl-ml-auto"
/>
</
template
>
...
...
ee/spec/frontend/threat_monitoring/components/alerts/alert_filters_spec.js
View file @
9adb7fe9
...
...
@@ -2,6 +2,7 @@ import { GlDropdownItem, GlSearchBoxByType } from '@gitlab/ui';
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
AlertFilters
from
'
ee/threat_monitoring/components/alerts/alert_filters.vue
'
;
import
{
ALL
,
DEFAULT_FILTERS
,
STATUSES
}
from
'
ee/threat_monitoring/components/alerts/constants
'
;
import
{
trimText
}
from
'
helpers/text_helper
'
;
describe
(
'
AlertFilters component
'
,
()
=>
{
let
wrapper
;
...
...
@@ -62,7 +63,7 @@ describe('AlertFilters component', () => {
const
status
=
'
TRIGGERED
'
;
const
translated
=
STATUSES
[
status
];
createWrapper
({
method
:
mount
});
expect
(
findDropdownMessage
(
)).
toBe
(
`
${
translated
}
+1 more`
);
expect
(
trimText
(
findDropdownMessage
()
)).
toBe
(
`
${
translated
}
+1 more`
);
});
it
(
'
Emits an event with the new filters on deselect
'
,
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