Extract frequently visited items localStorage helpers
What does this MR do and why?
Extract localStorage helpers
These funcions will be reused in an upcoming MR, which will add frequently visited projects and groups to the global search modal default view.
Part of #409522 (closed).
Screenshots or screen recordings
This should have no visual or behavioural change. But for context, this is what the frequently visited items lists look like:
How to set up and validate locally
- Open the context switcher in the navigation sidebar.
- See frequently visited projects/groups.
- Verify removing items still works.
If you don't have any frequent projects/groups listed
- Back up any existing
localStorage
values you have under these keys, just in case! - Run the below code in the browser console.
- Reload the page.
- Follow the steps above.
(() => {
localStorage.setItem(`${gon.current_username}/frequent-projects`, '[{"id":2,"name":"Gitlab Shell","namespace":"Gitlab Org / Gitlab Shell","webUrl":"/gitlab-org/gitlab-shell","avatarUrl":null,"frequency":30,"lastAccessedOn":1687193007468},{"id":6,"name":"Flight","namespace":"Flightjs / Flight","webUrl":"/flightjs/Flight","avatarUrl":null,"frequency":20,"lastAccessedOn":1690535996582},{"id":1,"name":"Gitlab Test","namespace":"Gitlab Org / Gitlab Test","webUrl":"/gitlab-org/gitlab-test","avatarUrl":null,"frequency":230,"lastAccessedOn":1691481460136}]');
localStorage.setItem(`${gon.current_username}/frequent-groups`, '[{"id":2,"name":"Gitlab.org","namespace":"Gitlab.org","webUrl":"/gitlab-org","avatarUrl":null,"frequency":30,"lastAccessedOn":1687193007468},{"id":6,"name":"Flightjs","namespace":"Flightjs","webUrl":"/flightjs","avatarUrl":null,"frequency":20,"lastAccessedOn":1690535996582}]');
})();
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #409522 (closed)
Edited by Mark Florian