Allow overriding Super Dev Mode server URL via prompt#10344
Conversation
If the SDM server is unreachable, a prompt now allows users to specify a new server URL. This URL is persisted in sessionStorage so it can be used during the subsequent page reload.
niloc132
left a comment
There was a problem hiding this comment.
I like the idea, and at a quick glance the implementation seems okay - but doesn't the bookmarklet setup solve this too? That is, if you first start mysdm:9876 and visit that URL, the bookmarklets let you enable SDM in session storage?
My current usage is atypical, so I may well be misremembering.
| try { | ||
| serverUrl = $wnd.sessionStorage.getItem(serverUrlKey) || defaultServerUrl; | ||
| } catch (e) { | ||
| // sessionStorage may be unavailable; fall back to the default url. |
There was a problem hiding this comment.
What's the risk/likelihood that session storage is unavailable? dev_mode_on.js relies on it and won't function without it, so I think maybe we can assume it is there?
| try { | ||
| $wnd.sessionStorage.setItem(serverUrlKey, newServerUrl); | ||
| } catch (e) { | ||
| // Without storage the reload falls back to the default url. |
There was a problem hiding this comment.
(assuming still relevant) Should probably notify that the prompt had no effect?
Maybe test for storage usage before attempting to use prompt to begin with?
I haven't used the bookmarklets in so long, I thought they were abandoned with the old dev mode and replaced by SDM. I'll remove the check for sessionstorage availability, I was not aware of it being used for other GWT functionality. 👍 |
Remove try-catch blocks around sessionStorage interactions when retrieving or persisting the Super Dev Mode server URL since we know sessionStorage is already available and used in dev_mode_on.js.
|
They aren't necessary, but they are allowed to be used, and can give you control like what you're describing - arguably better to be able to enable/disable and control urls directly through the click of a button than prompts and manual typing (when it might just be that your server is stopped and you forgot when you hit refresh). |
|
Just to clarify, the original URL is pre-filled in the prompt. Just clicking OK on the prompt will yield the exact same result as clicking OK on the original alert. Manual typing would only be needed if you would want to change the default URL. And since it's persisted it's only needed once (if typed correctly). I haven't tried the bookmarklet variant yet, but an alternative solution for this PR might be to simply change the message in the original alert to give the user the tip of using the bookmarklet if they want to manually change the URL? |
|
@schteff If you try the bookmarklets then you might need to adjust the gwt property |
|
Another approach would be to put the right URL of the code server into the JS similar to this proposal: (except instead of the binding address, a new setting would be used to allow use of local tunnel) |
If the SDM server is unreachable, a prompt now allows users to specify a new server URL. This URL is persisted in sessionStorage so it can be used during the subsequent page reload.
This makes it possible to use https://github.com/localtunnel/localtunnel or other similar services (that tunnel specific ports) to share the local dev environment with other people without having to build and deploy the app on some other server.