Skip to content

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:

context_switcher

How to set up and validate locally

  1. Open the context switcher in the navigation sidebar.
  2. See frequently visited projects/groups.
  3. Verify removing items still works.

If you don't have any frequent projects/groups listed

  1. Back up any existing localStorage values you have under these keys, just in case!
  2. Run the below code in the browser console.
  3. Reload the page.
  4. 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.

Related to #409522 (closed)

Edited by Mark Florian

Merge request reports

Loading