ui: Fix sticky namespace selector #11830
Merged
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.
When the application initially loads we request a list of namespaces from the backend within the application model hook in order to immediately populate the namespace menu in the top left of the UI.
We also use this application model namespace list to find 'valid' namespaces to mark as 'selected' in order to show the currently selected menu item. If we can't find the specified namespace (taken from the URL segment) then we default to just show the 'default' namespace instead.
The namespace menu is refreshed everytime it is opened (we fire off a request to get a refreshed response) - importantly this request doesn't refresh the model on the application model hook, which is the one we sometimes use to check for a 'valid' selection 😬 .
The application model hook is also not refreshed when you save a new namespace via the UI. Meaning that we end up defaulting to 'default' if you save a new namespace and then immediately try to select it with the same 'javascript execution session' (i.e. without manually hitting refresh)
All in all this can mean that once you have saved a namespace, whilst it possible to select it and navigate to it, it sometimes seems like the top menu doesn't want to mark it as selected.
The fix here is to just make sure to use the central data store instead of using the result of the application model hook which in Ember's case is the Ember Data store.
Lastly, 1.10 forwards uses a completely different approach for the entire UI so this is a 1.9 only fix (note the base branch) that will never be ported forwards and we will soonish drop support for this version. Oh I also changed to retrieve the list of dcs here also, which meant I could get rid of the
app
variable, and whilst there isn't a similar related bug there, I felt it was best to just access this directly from the store also.Changelog coming shortly.
Fixes #11553