mosaic icon indicating copy to clipboard operation
mosaic copied to clipboard

Store expansion status in URL

Open mmieszek opened this issue 6 years ago • 5 comments
trafficstars

Solution for #331

A new query string parameter expand is introduced which stores a comma-separated list of expanded workspace ids.

When a subtree is collapsed, a corresponding workspace id is removed from the URL.

When there are no expanded nodes, expand is removed completely from a query string.

URL is of the form: http://localhost:3000/workspaces/2487918d-7ddc-488b-937b-e0b90428e088/subtree?expand=e3cbf7d8-d001-4f7b-8f55-a9827da4f6ed,2487918d-7ddc-488b-937b-e0b90428e088

Potential improvements:

  • when a nested subtree is collapsed, remove ids of expanded children from the URL, not only the id of a tree that is being collapsed
  • fetch a whole subtree with a single graphql query
  • shorten ids in the URL. Storing whole UUIDs is not necessary and it might be enough to store 7-8 characters. The same mechanism employs git to shorten commit hashes. This would make the URL much shorter and easier to share.
  • Updated query-string dependency to the latest version (6.4.2) to have an automated conversion to an array with arrayFormat = "comma" option . Right now the query string value is converted into an array manually. Upgrade to TypeScript 3 needed as query-string 6.4.2 uses keyworn unknown.

mmieszek avatar Apr 22 '19 12:04 mmieszek

Thanks for submitting this! We're in the process of removing UUIDs from the URLs in favor of shorter identifiers. I think it makes sense to hold off on merging this until we've completed that task, and then recast this PR in those terms.

zjmiller avatar Jun 12 '19 19:06 zjmiller

It would also be nice to have a system that worked with well the "Expand All" functionality currently associated the expanded query param being set to true. With this PR, if we "Expand All" and then collapse a few subtrees, the resulting state isn't saved in the URL.

zjmiller avatar Jun 12 '19 20:06 zjmiller

@zjmiller what's the current status of this PR?

brachbach avatar Sep 05 '19 01:09 brachbach

We still need to resolve the issues I mentioned in my comments. Doing this hasn't been a priority, less so now that most non-admins use the compact tree view.

zjmiller avatar Sep 05 '19 03:09 zjmiller

cool, sounds good

brachbach avatar Sep 05 '19 03:09 brachbach