fix(redis): guard string key Refresh and crumb navigation against unsaved edits - #933
Merged
Merged
Conversation
…aved edits Add _savedStringText to track the server-loaded value and _isStringDirty to detect unsaved edits in the string TextField. Wrap the Refresh button with _confirmDiscardStringEdits() so the user is prompted before their changes are thrown away. Introduce RedisKeyEditorController with canNavigateAway() so that RedisExplorerView can guard crumb/back navigation in the same way. _navigateToKeys() now awaits the controller before clearing the selected key. Tests: 4 new cases in redis_key_editor_test.dart covering clean/dirty Refresh and clean/dirty canNavigateAway(). Closes #873
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Prevents data loss when the user edits a Redis string key value and then clicks Refresh or navigates away via the breadcrumb trail without saving.
Changes
redis_key_editor.dart_savedStringTextto track the server-loaded string value._isStringDirtygetter — true only for editable string keys when the controller text differs from_savedStringText._confirmDiscardStringEdits()— shows an 'Unsaved changes' dialog and returnstrueonly when safe to proceed.RedisKeyEditorController(public) with acanNavigateAway()method so the parent widget can query dirty-state without touching private state.controllerparameter toRedisKeyEditor; the state attaches/detaches ininitState/dispose.onTapwith the discard guard.redis_explorer_view.dartRedisKeyEditorController? _keyEditorControllerto_RedisExplorerViewState._navigateToKeys()is nowasyncand callscontroller.canNavigateAway()before clearing navigation state._onCrumbTapusesunawaited(_navigateToKeys())so the async guard works._navigateToKeyand_onKeyRenamedcreate a fresh controller on each key selection.Tests
4 new cases in
test/features/redis/redis_key_editor_test.dart:canNavigateAway()returnstruewhen clean.canNavigateAway()shows dialog when dirty; Cancel →false, Discard →true.Closes #873