Loading
Sync inventory filters with URL query params
What does this MR do and why?
Sync inventory filters with URL query params
Write security inventory filters to URL query params when they change,
restore them from the URL query params on load, and push/pop history.
When the URL has query params, some of them could be attribute-based,
but attributes are loaded separately, so wait to do the first page
fetch until we know there are no params or attributes are loaded.
Changelog: added
EE: trueWhere the URL params flow
graph TD
URL[address bar]
URL -->|page load: queryToObject| QP[dashboard queryParams]
URL -->|back or forward: popstate| QP
QP -->|url-query prop| BAR[filtered search bar]
BAR -->|queryParamsToTokens| TOK[tokens in the bar]
TOK -->|filters-initialized| DF[dashboard filters]
DF --> VARS[GraphQL query variables]
VARS --> LIST[project list]
USER[user edits a token] --> TOK
TOK -->|tokensToQueryParams| PARAMS[query params]
PARAMS -->|url-params-changed| OUCH[onUrlParamsChanged]
OUCH -->|setUrlParams + withReadableParams| URL
OUCH --> QP
MOUNT[mounted] -->|waits for filters-initialized,<br/>ten second timeout| VARSReferences
- Issue: #580024 (closed)
- Original combined merge request, now closed: !252968 (closed)
- Targets !255936 (merged), which targets !255935 (merged)
- Followed by !255957 (merged), which moves the tool coverage card onto the same params
Screenshots or screen recordings
| Before | After |
|---|---|
you can take all the same actions, but the URL bar stays at /-/security/inventory at most it shows a search term like /-/security/inventory?search=report |
URL bar matches the filtered search each attribute filter type works no flash of unfiltered list on hard reload paging through history navigates between filter states |
How to set up and validate locally
-
git checkout 580024-sync-inventory-filter-bar-with-url-params - have a GitLab Ultimate licence
- have at least one security attribute category with two attributes on the
group, so the attribute tokens appear (create these in top-level group =>
Secure=>Security configuration) - go to a group =>
Secure=>Security inventory
to check filters reach the URL
- apply a plain text search term
- apply
StatusisProtected - apply
Critical>=5 - check that the address bar reads, in some order:
search=<your term>status=protectedgte[critical]=5
- remove one token
- check that only that token's param leaves the URL, and the others stay
to check the URL restores filters on load
- with those filters applied, reload the page
- check that:
- the same tokens are back in the search bar
- the project list is filtered the same way it was before the reload
- copy the address, open it in a new tab
- check that the new tab shows the same tokens and the same filtered list
to check the attribute operators
- apply an attribute filter with
is, reload, and check the token comes back - check the URL reads
attribute~<category>=<id> - repeat with
is not, and check the URL readsnot[attribute~<category>]=<id> - repeat with
orand two attributes selected, and check the URL readsor[attribute~<category>]=<id>,<id> - for each of the three, do a hard reload so the security categories are fetched fresh
- check that in all three cases the project list is filtered from the first render, with no visible moment where more projects are listed than the filter should allow
to check the browser buttons
- apply a filter, then apply a second one
- press back
- check that the search bar and the project list both return to the previous filter, not just the URL
- press forward
- check that both return to the second filter
to check a subgroup selection survives filtering
- select a subgroup in the tree, so the address gains a
#fragment - apply a filter
- check that the fragment is still there and still selects the same subgroup
to run tests
yarn jest ee/spec/frontend/security_inventoryMR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #580024 (closed)
Edited by Miranda Fluharty