feat: add option to preserve namespaces when switching contexts #853
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.
Summary
This PR implements a namespace preservation feature when switching contexts. Users can now maintain their current namespaces across different clusters when the same namespace names exist, enabling smoother transitions without re-selecting namespaces.
Key Changes:
Ctrl+Space
option to preserve current namespaces when switching contextsImplementation Details
Message Layer Extension (src/features/context/message.rs:14-20)
keep_namespace
flag toContextRequest::Set
UI Layer Improvements (src/features/context/view/dialog.rs)
Controller Layer Logic (src/workers/kube/controller.rs:228-250, 588-622)
keep_namespace: true
, pass current namespace list to the next contextUser Experience
Users can switch contexts in two ways:
Example Use Case
Scenario:
team-a
,team-b
,team-c
,monitoring
team-a
,team-b
,default
When switching from prod to dev while viewing
team-a
,team-b
,team-c
:default
)team-a
,team-b
(team-c
is excluded as it doesn't exist, warning logged)Additional Improvements
Code Quality
clear_widgets_and_close_dialog
,switch_context
)Documentation
?
key)Test plan
Future Work
When some namespaces are not found, we currently output warnings to logs. In the future, we plan to consider UI notifications as well. (Notification system will be proposed in a separate issue)