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
c2b6131a
Commit
c2b6131a
authored
Mar 15, 2021
by
Alexander Turinske
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add policy name filter to threat alerts
- add input field for policy name searching - update tests
parent
d2dc00ba
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
95 additions
and
29 deletions
+95
-29
ee/app/assets/javascripts/threat_monitoring/components/alerts/alert_filters.vue
...pts/threat_monitoring/components/alerts/alert_filters.vue
+35
-6
ee/app/assets/javascripts/threat_monitoring/components/alerts/alerts_list.vue
...ripts/threat_monitoring/components/alerts/alerts_list.vue
+1
-1
ee/changelogs/unreleased/296712-policy-name-search.yml
ee/changelogs/unreleased/296712-policy-name-search.yml
+5
-0
ee/spec/frontend/threat_monitoring/components/alerts/alert_filters_spec.js
...threat_monitoring/components/alerts/alert_filters_spec.js
+47
-22
ee/spec/frontend/threat_monitoring/components/alerts/alerts_list_spec.js
...d/threat_monitoring/components/alerts/alerts_list_spec.js
+1
-0
locale/gitlab.pot
locale/gitlab.pot
+6
-0
No files found.
ee/app/assets/javascripts/threat_monitoring/components/alerts/alert_filters.vue
View file @
c2b6131a
<
script
>
<
script
>
import
{
GlFormCheckbox
,
GlFormGroup
}
from
'
@gitlab/ui
'
;
import
{
GlFormCheckbox
,
GlFormGroup
,
GlSearchBoxByType
}
from
'
@gitlab/ui
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
DEFAULT_FILTERS
}
from
'
./constants
'
;
import
{
DEFAULT_FILTERS
}
from
'
./constants
'
;
export
default
{
export
default
{
DEFAULT_DISMISSED_FILTER
:
true
,
DEFAULT_DISMISSED_FILTER
:
true
,
components
:
{
GlFormCheckbox
,
GlFormGroup
},
components
:
{
GlFormCheckbox
,
GlFormGroup
,
GlSearchBoxByType
},
props
:
{
filters
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
{},
},
},
data
()
{
return
{
showMinimumSearchQueryMessage
:
false
,
};
},
i18n
:
{
i18n
:
{
HIDE_DISMISSED_TITLE
:
s__
(
'
ThreatMonitoring|Hide dismissed alerts
'
),
HIDE_DISMISSED_TITLE
:
s__
(
'
ThreatMonitoring|Hide dismissed alerts
'
),
POLICY_NAME_FILTER_PLACEHOLDER
:
s__
(
'
NetworkPolicy|Search by policy name
'
),
POLICY_NAME_FILTER_TITLE
:
s__
(
'
NetworkPolicy|Policy
'
),
},
},
methods
:
{
methods
:
{
changeDismissedFilter
(
filtered
)
{
changeDismissedFilter
(
filtered
)
{
const
newFilters
=
filtered
?
DEFAULT_FILTERS
:
{};
const
newFilters
=
filtered
?
DEFAULT_FILTERS
:
{
statuses
:
[]
};
this
.
$emit
(
'
filter-change
'
,
newFilters
);
this
.
handleFilterChange
(
newFilters
);
},
handleSearch
(
searchTerm
)
{
const
newFilters
=
{
searchTerm
};
this
.
handleFilterChange
(
newFilters
);
},
handleFilterChange
(
newFilters
)
{
this
.
$emit
(
'
filter-change
'
,
{
...
this
.
filters
,
...
newFilters
});
},
},
},
},
};
};
...
@@ -20,9 +41,17 @@ export default {
...
@@ -20,9 +41,17 @@ export default {
<
template
>
<
template
>
<div
<div
class=
"gl-p
t-3 gl-px-3 gl-bg-gray-10 gl-display-flex gl-justify-content-end
gl-align-items-center"
class=
"gl-p
-4 gl-bg-gray-10 gl-display-flex gl-justify-content-space-between
gl-align-items-center"
>
>
<gl-form-group
label-size=
"sm"
>
<div>
<h5
class=
"gl-mt-0"
>
{{
$options
.
i18n
.
POLICY_NAME_FILTER_TITLE
}}
</h5>
<gl-search-box-by-type
debounce=
"250"
:placeholder=
"$options.i18n.POLICY_NAME_FILTER_PLACEHOLDER"
@
input=
"handleSearch"
/>
</div>
<gl-form-group
label-size=
"sm"
class=
"gl-mb-0"
>
<gl-form-checkbox
<gl-form-checkbox
class=
"gl-mt-3"
class=
"gl-mt-3"
:checked=
"$options.DEFAULT_DISMISSED_FILTER"
:checked=
"$options.DEFAULT_DISMISSED_FILTER"
...
...
ee/app/assets/javascripts/threat_monitoring/components/alerts/alerts_list.vue
View file @
c2b6131a
...
@@ -137,7 +137,7 @@ export default {
...
@@ -137,7 +137,7 @@ export default {
</
script
>
</
script
>
<
template
>
<
template
>
<div>
<div>
<alert-filters
@
filter-change=
"handleFilterChange"
/>
<alert-filters
:filters=
"filters"
@
filter-change=
"handleFilterChange"
/>
<gl-alert
v-if=
"showNoAlertsMsg"
data-testid=
"threat-alerts-unconfigured"
:dismissible=
"false"
>
<gl-alert
v-if=
"showNoAlertsMsg"
data-testid=
"threat-alerts-unconfigured"
:dismissible=
"false"
>
<gl-sprintf
:message=
"$options.i18n.MESSAGES.CONFIGURE"
>
<gl-sprintf
:message=
"$options.i18n.MESSAGES.CONFIGURE"
>
<template
#link
="
{ content }">
<template
#link
="
{ content }">
...
...
ee/changelogs/unreleased/296712-policy-name-search.yml
0 → 100644
View file @
c2b6131a
---
title
:
Add policy name filter to threat alerts
merge_request
:
56708
author
:
type
:
added
ee/spec/frontend/threat_monitoring/components/alerts/alert_filters_spec.js
View file @
c2b6131a
import
{
GlFormCheckbox
}
from
'
@gitlab/ui
'
;
import
{
GlFormCheckbox
,
GlSearchBoxByType
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
AlertFilters
from
'
ee/threat_monitoring/components/alerts/alert_filters.vue
'
;
import
AlertFilters
from
'
ee/threat_monitoring/components/alerts/alert_filters.vue
'
;
import
{
DEFAULT_FILTERS
}
from
'
ee/threat_monitoring/components/alerts/constants
'
;
import
{
DEFAULT_FILTERS
}
from
'
ee/threat_monitoring/components/alerts/constants
'
;
...
@@ -7,9 +7,10 @@ describe('AlertFilters component', () => {
...
@@ -7,9 +7,10 @@ describe('AlertFilters component', () => {
let
wrapper
;
let
wrapper
;
const
findGlFormCheckbox
=
()
=>
wrapper
.
find
(
GlFormCheckbox
);
const
findGlFormCheckbox
=
()
=>
wrapper
.
find
(
GlFormCheckbox
);
const
findGlSearch
=
()
=>
wrapper
.
find
(
GlSearchBoxByType
);
const
createWrapper
=
()
=>
{
const
createWrapper
=
(
filters
=
DEFAULT_FILTERS
)
=>
{
wrapper
=
shallowMount
(
AlertFilters
);
wrapper
=
shallowMount
(
AlertFilters
,
{
propsData
:
{
filters
}
}
);
};
};
afterEach
(()
=>
{
afterEach
(()
=>
{
...
@@ -17,32 +18,56 @@ describe('AlertFilters component', () => {
...
@@ -17,32 +18,56 @@ describe('AlertFilters component', () => {
wrapper
=
null
;
wrapper
=
null
;
});
});
describe
(
'
default state
'
,
()
=>
{
describe
(
'
Policy Name Filter
'
,
()
=>
{
it
(
'
"hide dismissed checkbox" is checked
'
,
()
=>
{
beforeEach
(
()
=>
{
createWrapper
();
createWrapper
();
const
checkbox
=
findGlFormCheckbox
();
expect
(
checkbox
.
exists
()).
toBe
(
true
);
expect
(
checkbox
.
attributes
(
'
checked
'
)).
toBeTruthy
();
});
});
});
describe
(
'
dismissed alerts filter
'
,
()
=>
{
describe
(
'
default state
'
,
()
=>
{
beforeEach
(()
=>
{
it
(
'
shows policy name search box
'
,
()
=>
{
createWrapper
();
const
search
=
findGlSearch
();
expect
(
search
.
exists
()).
toBe
(
true
);
expect
(
search
.
attributes
(
'
value
'
)).
toBe
(
''
);
});
it
(
'
does emit an event with a user-defined string
'
,
async
()
=>
{
const
term
=
'
abc
'
;
const
search
=
findGlSearch
();
search
.
vm
.
$emit
(
'
input
'
,
term
);
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
emitted
(
'
filter-change
'
)).
toStrictEqual
([
[{
...
DEFAULT_FILTERS
,
searchTerm
:
'
abc
'
}],
]);
});
});
});
});
it
(
'
emits an event with no filters on filter deselect
'
,
async
()
=>
{
describe
(
'
Hide Dismissed Filter
'
,
()
=>
{
const
checkbox
=
findGlFormCheckbox
();
describe
(
'
default state
'
,
()
=>
{
checkbox
.
vm
.
$emit
(
'
change
'
,
false
);
it
(
'
"hide dismissed checkbox" is checked
'
,
()
=>
{
await
wrapper
.
vm
.
$nextTick
();
createWrapper
();
expect
(
wrapper
.
emitted
(
'
filter-change
'
)).
toEqual
([[{}]]);
const
checkbox
=
findGlFormCheckbox
();
expect
(
checkbox
.
exists
()).
toBe
(
true
);
expect
(
checkbox
.
attributes
(
'
checked
'
)).
toBeTruthy
();
});
});
});
it
(
'
emits an event with the default filters on filter select
'
,
async
()
=>
{
describe
(
'
dismissed alerts filter
'
,
()
=>
{
const
checkbox
=
findGlFormCheckbox
();
it
(
'
emits an event with no filters on filter deselect
'
,
async
()
=>
{
checkbox
.
vm
.
$emit
(
'
change
'
,
true
);
createWrapper
();
await
wrapper
.
vm
.
$nextTick
();
const
checkbox
=
findGlFormCheckbox
();
expect
(
wrapper
.
emitted
(
'
filter-change
'
)).
toEqual
([[
DEFAULT_FILTERS
]]);
checkbox
.
vm
.
$emit
(
'
change
'
,
false
);
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
emitted
(
'
filter-change
'
)).
toStrictEqual
([[{
statuses
:
[]
}]]);
});
it
(
'
emits an event with the default filters on filter select
'
,
async
()
=>
{
createWrapper
({});
const
checkbox
=
findGlFormCheckbox
();
checkbox
.
vm
.
$emit
(
'
change
'
,
true
);
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
emitted
(
'
filter-change
'
)).
toEqual
([[
DEFAULT_FILTERS
]]);
});
});
});
});
});
});
});
ee/spec/frontend/threat_monitoring/components/alerts/alerts_list_spec.js
View file @
c2b6131a
...
@@ -101,6 +101,7 @@ describe('AlertsList component', () => {
...
@@ -101,6 +101,7 @@ describe('AlertsList component', () => {
it
(
'
shows threat monitoring alert filters
'
,
()
=>
{
it
(
'
shows threat monitoring alert filters
'
,
()
=>
{
expect
(
findAlertFilters
().
exists
()).
toBe
(
true
);
expect
(
findAlertFilters
().
exists
()).
toBe
(
true
);
expect
(
findAlertFilters
().
props
(
'
filters
'
)).
toBe
(
DEFAULT_FILTERS
);
});
});
it
(
'
does have the default filters initially
'
,
()
=>
{
it
(
'
does have the default filters initially
'
,
()
=>
{
...
...
locale/gitlab.pot
View file @
c2b6131a
...
@@ -20394,6 +20394,12 @@ msgstr ""
...
@@ -20394,6 +20394,12 @@ msgstr ""
msgid "NetworkPolicies|ports/protocols"
msgid "NetworkPolicies|ports/protocols"
msgstr ""
msgstr ""
msgid "NetworkPolicy|Policy"
msgstr ""
msgid "NetworkPolicy|Search by policy name"
msgstr ""
msgid "Never"
msgid "Never"
msgstr ""
msgstr ""
...
...
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