-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor url hash to json #5730
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really great stuff! Great that you also added extensive tests 👍
From our discussion today, there are some remaining todos (namely, sticking to the legacy URL by default), but other than that everything looks pretty good 👍 From my POV you could add the mapping-support to this PR or open a new one for that. Your call 🎲
|
||
return [...position, viewModeIndex, zoomStep, ...rotation, ...activeNodeId].join(","); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From our verbal discussion: The legacy variant (maybe we should call it CSV
since we'll stick to it) should be still supported and also used here for updating the URL (probably the component would need to support both ways for building the hash; the new variant would be used by the share modal).
I think, this would be great, but that could be a follow-up once we are annoyed enough by it (building the new variant backwards compatible should not be a problem in my opinion). |
I did it in this PR :) I'll tackle the mapping and agglomerate loading in a separate PR. This one should be ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great and it also works well for me :)
Refactor the url hash/fragment to alternatively use json format instead of a comma-delimited custom format. I added quite a few tests to make sure that both the csv format as well as the comment links (which also temporarily change the url hash) continue to work. Keep the csv format as the default.
encodeURIComponent
to do that. However, the function encodes quite a few characters which don't need to be encoded, resulting in a rather unreadable url hash. We could write a custom {en,de}coding wrapper which doesn't encode:
,.
and,
to make the hash more readable. On the other hand, we don't really want users to modify the url hash anyways, I'd say. What do you think?URL of deployed dev instance (used for testing):
Steps to test:
#10,20,30,0,1.3,2
(x,y,z,mode,zoomStep,activeNode
)#%7B"position"%3A%5B445%2C358%2C501%5D%2C"mode"%3A"orthogonal"%2C"zoomStep"%3A2%2C"activeNode"%3A2%7D
jump to node with id #2
andjump to position #(1,2,3)
. Then click on the links and check that the links work as expected.Issues: