-
Notifications
You must be signed in to change notification settings - Fork 389
Allow overriding Super Dev Mode server URL via prompt #10344
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
Open
schteff
wants to merge
2
commits into
gwtproject:main
Choose a base branch
from
Tempus-Information-Systems:feature/allow-alt-sdm-url
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+13
−4
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,8 +20,19 @@ | |
| (function($wnd, $doc){ | ||
| // Compute some codeserver urls so as the user does not need bookmarklets | ||
| var hostName = $wnd.location.hostname; | ||
| var serverUrl = 'http://' + hostName + ':__SUPERDEV_PORT__'; | ||
| var module = '__MODULE_NAME__'; | ||
|
|
||
| // The default Super Dev Mode server url. The user may override it (and retry) | ||
| // through the prompt shown by the error handler below; the override is kept | ||
| // for the session so the reload picks up the new server. | ||
| var serverUrlKey = '__gwt_sdm__server_url'; | ||
| var defaultServerUrl = 'http://' + hostName + ':__SUPERDEV_PORT__'; | ||
| var serverUrl = defaultServerUrl; | ||
| try { | ||
| serverUrl = $wnd.sessionStorage.getItem(serverUrlKey) || defaultServerUrl; | ||
| } catch (e) { | ||
| // sessionStorage may be unavailable; fall back to the default url. | ||
| } | ||
| var nocacheUrl = serverUrl + '/recompile-requester/' + module; | ||
|
|
||
| // Insert the superdevmode nocache script in the first position of the head | ||
|
|
@@ -32,15 +43,22 @@ | |
| // This means that we do not detect a non running SDM with IE8. | ||
| if (devModeScript.addEventListener) { | ||
| var callback = function() { | ||
| // Don't show the confirmation dialogue twice (multimodule) | ||
| // Don't show the prompt twice (multimodule) | ||
| if (!$wnd.__gwt__sdm__confirmed && | ||
| (!$wnd.__gwt_sdm__recompiler || !$wnd.__gwt_sdm__recompiler.loaded)) { | ||
| $wnd.__gwt__sdm__confirmed = true; | ||
| if ($wnd.confirm( | ||
| var newServerUrl = $wnd.prompt( | ||
| "Couldn't load " + module + " from Super Dev Mode\n" + | ||
| "server at " + serverUrl + ".\n" + | ||
| "Please make sure this server is ready.\n" + | ||
| "Do you want to try again?")) { | ||
| "Press OK to try again:", | ||
| serverUrl); | ||
| if (newServerUrl) { | ||
| try { | ||
| $wnd.sessionStorage.setItem(serverUrlKey, newServerUrl); | ||
| } catch (e) { | ||
| // Without storage the reload falls back to the default url. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (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? |
||
| } | ||
| $wnd.location.reload(); | ||
| } | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What's the risk/likelihood that session storage is unavailable?
dev_mode_on.jsrelies on it and won't function without it, so I think maybe we can assume it is there?