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
8ed012d0
Commit
8ed012d0
authored
Apr 28, 2021
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.com:gitlab-org/gitlab
parents
dc42afe9
b1453948
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
35 deletions
+30
-35
ee/app/assets/javascripts/security_dashboard/components/filters/activity_filter.vue
...security_dashboard/components/filters/activity_filter.vue
+1
-1
ee/app/assets/javascripts/security_dashboard/components/filters/scanner_filter.vue
.../security_dashboard/components/filters/scanner_filter.vue
+1
-1
ee/app/assets/javascripts/security_dashboard/components/filters/standard_filter.vue
...security_dashboard/components/filters/standard_filter.vue
+15
-20
ee/spec/frontend/security_dashboard/components/filters/standard_filter_spec.js
...rity_dashboard/components/filters/standard_filter_spec.js
+13
-13
No files found.
ee/app/assets/javascripts/security_dashboard/components/filters/activity_filter.vue
View file @
8ed012d0
...
...
@@ -40,7 +40,7 @@ export default {
this
.
selectedOptions
=
xor
(
this
.
selectedOptions
,
[
option
]);
}
this
.
update
RouteQuery
();
this
.
update
Querystring
();
},
},
NO_ACTIVITY
,
...
...
ee/app/assets/javascripts/security_dashboard/components/filters/scanner_filter.vue
View file @
8ed012d0
...
...
@@ -84,7 +84,7 @@ export default {
?
without
(
this
.
selectedOptions
,
...
options
)
:
union
(
this
.
selectedOptions
,
options
);
this
.
update
RouteQuery
();
this
.
update
Querystring
();
},
},
};
...
...
ee/app/assets/javascripts/security_dashboard/components/filters/standard_filter.vue
View file @
8ed012d0
...
...
@@ -41,12 +41,8 @@ export default {
selectedOptionsOrAll
()
{
return
this
.
selectedOptions
.
length
?
this
.
selectedOptions
:
[
this
.
filter
.
allOption
];
},
queryObject
()
{
// This is the object used to update the querystring.
return
{
[
this
.
filter
.
id
]:
this
.
selectedOptionsOrAll
.
map
((
x
)
=>
x
.
id
)
};
},
filterObject
()
{
// This is
the object used by the GraphQL query
.
// This is
passed to the vulnerability list's GraphQL query as a variable
.
return
{
[
this
.
filter
.
id
]:
this
.
selectedOptions
.
map
((
x
)
=>
x
.
id
)
};
},
filteredOptions
()
{
...
...
@@ -54,13 +50,13 @@ export default {
option
.
name
.
toLowerCase
().
includes
(
this
.
searchTerm
.
toLowerCase
()),
);
},
routeQuery
Ids
()
{
querystring
Ids
()
{
const
ids
=
this
.
$route
?.
query
[
this
.
filter
.
id
]
||
[];
return
Array
.
isArray
(
ids
)
?
ids
:
[
ids
];
},
routeQuery
Options
()
{
const
options
=
this
.
options
.
filter
((
x
)
=>
this
.
routeQuery
Ids
.
includes
(
x
.
id
));
const
hasAllId
=
this
.
routeQuery
Ids
.
includes
(
this
.
filter
.
allOption
.
id
);
querystring
Options
()
{
const
options
=
this
.
options
.
filter
((
x
)
=>
this
.
querystring
Ids
.
includes
(
x
.
id
));
const
hasAllId
=
this
.
querystring
Ids
.
includes
(
this
.
filter
.
allOption
.
id
);
if
(
options
.
length
&&
!
hasAllId
)
{
return
options
;
...
...
@@ -78,32 +74,31 @@ export default {
},
},
created
()
{
this
.
selectedOptions
=
this
.
routeQuery
Options
;
this
.
selectedOptions
=
this
.
querystring
Options
;
// When the user clicks the forward/back browser buttons, update the selected options.
window
.
addEventListener
(
'
popstate
'
,
()
=>
{
this
.
selectedOptions
=
this
.
routeQuery
Options
;
this
.
selectedOptions
=
this
.
querystring
Options
;
});
},
methods
:
{
toggleOption
(
option
)
{
// Toggle the option's existence in the array.
this
.
selectedOptions
=
xor
(
this
.
selectedOptions
,
[
option
]);
this
.
update
RouteQuery
();
this
.
update
Querystring
();
},
deselectAllOptions
()
{
this
.
selectedOptions
=
[];
this
.
update
RouteQuery
();
this
.
update
Querystring
();
},
updateRouteQuery
()
{
if
(
!
this
.
$router
)
{
updateQuerystring
()
{
const
options
=
this
.
selectedOptionsOrAll
.
map
((
x
)
=>
x
.
id
);
// To avoid a console error, don't update the querystring if it's the same as the current one.
if
(
!
this
.
$router
||
isEqual
(
this
.
querystringIds
,
options
))
{
return
;
}
const
query
=
{
query
:
{
...
this
.
$route
?.
query
,
...
this
.
queryObject
}
};
// To avoid a console error, don't update the querystring if it's the same as the current one.
if
(
!
isEqual
(
this
.
routeQueryIds
,
this
.
queryObject
[
this
.
filter
.
id
]))
{
this
.
$router
.
push
(
query
);
}
const
query
=
{
...
this
.
$route
.
query
,
[
this
.
filter
.
id
]:
options
};
this
.
$router
.
push
({
query
});
},
isSelected
(
option
)
{
return
this
.
selectedSet
.
has
(
option
);
...
...
ee/spec/frontend/security_dashboard/components/filters/standard_filter_spec.js
View file @
8ed012d0
...
...
@@ -186,7 +186,7 @@ describe('Standard Filter component', () => {
});
describe
(
'
filter querystring
'
,
()
=>
{
const
update
RouteQuery
=
async
(
ids
)
=>
{
const
update
Querystring
=
async
(
ids
)
=>
{
// window.history.back() won't change the location nor fire the popstate event, so we need
// to fake it by doing it manually.
router
.
replace
({
query
:
{
[
filter
.
id
]:
ids
}
});
...
...
@@ -221,7 +221,7 @@ describe('Standard Filter component', () => {
describe
(
'
querystring on page load
'
,
()
=>
{
it
(
'
selects correct items
'
,
()
=>
{
update
RouteQuery
(
optionIdsAt
([
1
,
3
,
5
,
7
]));
update
Querystring
(
optionIdsAt
([
1
,
3
,
5
,
7
]));
createWrapper
();
expectSelectedItems
([
1
,
3
,
5
,
7
]);
...
...
@@ -229,21 +229,21 @@ describe('Standard Filter component', () => {
it
(
'
selects only valid items when querystring has valid and invalid IDs
'
,
async
()
=>
{
const
ids
=
optionIdsAt
([
2
,
4
,
6
]).
concat
([
'
some
'
,
'
invalid
'
,
'
ids
'
]);
update
RouteQuery
(
ids
);
update
Querystring
(
ids
);
createWrapper
();
expectSelectedItems
([
2
,
4
,
6
]);
});
it
(
'
selects default options if querystring only has invalid items
'
,
async
()
=>
{
update
RouteQuery
([
'
some
'
,
'
invalid
'
,
'
ids
'
]);
update
Querystring
([
'
some
'
,
'
invalid
'
,
'
ids
'
]);
createWrapper
({
defaultOptions
:
optionsAt
([
4
,
5
,
8
])
});
expectSelectedItems
([
4
,
5
,
8
]);
});
it
(
'
selects All option if querystring only has invalid IDs and there are no default options
'
,
async
()
=>
{
update
RouteQuery
([
'
some
'
,
'
invalid
'
,
'
ids
'
]);
update
Querystring
([
'
some
'
,
'
invalid
'
,
'
ids
'
]);
createWrapper
();
expectAllOptionSelected
();
...
...
@@ -254,7 +254,7 @@ describe('Standard Filter component', () => {
it
(
'
selects the correct options
'
,
async
()
=>
{
createWrapper
();
const
indexes
=
[
3
,
5
,
7
];
await
update
RouteQuery
(
optionIdsAt
(
indexes
));
await
update
Querystring
(
optionIdsAt
(
indexes
));
expectSelectedItems
(
indexes
);
});
...
...
@@ -265,7 +265,7 @@ describe('Standard Filter component', () => {
await
clickItemAt
(
3
);
expectSelectedItems
([
2
,
3
,
5
,
8
]);
await
update
RouteQuery
([]);
await
update
Querystring
([]);
expectSelectedItems
([
2
,
5
,
8
]);
});
...
...
@@ -275,7 +275,7 @@ describe('Standard Filter component', () => {
await
clickItemAt
(
3
);
expectSelectedItems
([
3
]);
await
update
RouteQuery
([]);
await
update
Querystring
([]);
expectAllOptionSelected
();
});
...
...
@@ -283,13 +283,13 @@ describe('Standard Filter component', () => {
createWrapper
({
defaultOptions
:
optionsAt
([
2
,
4
,
8
])
});
expectSelectedItems
([
2
,
4
,
8
]);
await
update
RouteQuery
([
filter
.
allOption
.
id
]);
await
update
Querystring
([
filter
.
allOption
.
id
]);
expectAllOptionSelected
();
});
it
(
'
selects All option if querystring has all option ID as well as other IDs
'
,
async
()
=>
{
createWrapper
({
defaultOptions
:
optionsAt
([
5
,
6
,
9
])
});
await
update
RouteQuery
([
filter
.
allOption
.
id
,
...
optionIdsAt
([
1
,
2
])]);
await
update
Querystring
([
filter
.
allOption
.
id
,
...
optionIdsAt
([
1
,
2
])]);
expectAllOptionSelected
();
});
...
...
@@ -297,7 +297,7 @@ describe('Standard Filter component', () => {
it
(
'
selects only valid items when querystring has valid and invalid IDs
'
,
async
()
=>
{
createWrapper
();
const
ids
=
optionIdsAt
([
3
,
7
,
9
]).
concat
([
'
some
'
,
'
invalid
'
,
'
ids
'
]);
await
update
RouteQuery
(
ids
);
await
update
Querystring
(
ids
);
expectSelectedItems
([
3
,
7
,
9
]);
});
...
...
@@ -308,7 +308,7 @@ describe('Standard Filter component', () => {
await
clickItemAt
(
8
);
expectSelectedItems
([
1
,
3
,
4
,
8
]);
await
update
RouteQuery
([
'
some
'
,
'
invalid
'
,
'
ids
'
]);
await
update
Querystring
([
'
some
'
,
'
invalid
'
,
'
ids
'
]);
expectSelectedItems
([
1
,
3
,
4
]);
});
...
...
@@ -318,7 +318,7 @@ describe('Standard Filter component', () => {
await
clickItemAt
(
8
);
expectSelectedItems
([
8
]);
await
update
RouteQuery
([
'
some
'
,
'
invalid
'
,
'
ids
'
]);
await
update
Querystring
([
'
some
'
,
'
invalid
'
,
'
ids
'
]);
expectAllOptionSelected
();
});
...
...
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