Fix false unsaved changes after saving emergency access settings#425
Fix false unsaved changes after saving emergency access settings#425
Conversation
That's correct, because there is no "min members" field visible, when |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe change updates the Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/src/components/AdminSettingsEmergencyAccess.vue (1)
252-259: Reduce future drift by centralizing effectivedefaultMinMembers.This exact conditional is now duplicated across unsaved-check and save paths. Extracting it to one computed value would prevent this regression from reappearing.
♻️ Suggested refactor
+const effectiveDefaultMinMembers = computed(() => + allowChoosing.value ? minMembers.value : selectedUsers.value.length +); + const hasUnsavedChanges = computed(() => { return ( initialEmergencyAccessSettings.value.enableEmergencyAccess !== enableEmergencyAccess.value || initialEmergencyAccessSettings.value.defaultRequiredEmergencyKeyShares !== requiredShares.value || - initialEmergencyAccessSettings.value.defaultMinMembers !== (allowChoosing.value ? minMembers.value : selectedUsers.value.length) || + initialEmergencyAccessSettings.value.defaultMinMembers !== effectiveDefaultMinMembers.value || initialEmergencyAccessSettings.value.allowChoosingEmergencyCouncil !== allowChoosing.value || !sameCouncilMemberIds.value ); }); @@ await backend.settings.update({ enableEmergencyAccess: enableEmergencyAccess.value, defaultRequiredEmergencyKeyShares: requiredShares.value, - defaultMinMembers: allowChoosing.value ? minMembers.value : selectedUsers.value.length, + defaultMinMembers: effectiveDefaultMinMembers.value, allowChoosingEmergencyCouncil: allowChoosing.value, emergencyCouncilMemberIds: selectedUsers.value.map(u => u.id), }); initialEmergencyAccessSettings.value = { enableEmergencyAccess: enableEmergencyAccess.value, defaultRequiredEmergencyKeyShares: requiredShares.value, - defaultMinMembers: allowChoosing.value ? minMembers.value : selectedUsers.value.length, + defaultMinMembers: effectiveDefaultMinMembers.value, allowChoosingEmergencyCouncil: allowChoosing.value, selectedUsers: selectedUsers.value };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/src/components/AdminSettingsEmergencyAccess.vue` around lines 252 - 259, The unsaved-change logic in the hasUnsavedChanges computed duplicates the calculation for the effective default min members; extract that logic into a new computed (e.g., effectiveDefaultMinMembers) that returns allowChoosing.value ? minMembers.value : selectedUsers.value.length and then replace the inline expression initialEmergencyAccessSettings.value.defaultMinMembers !== (allowChoosing.value ? minMembers.value : selectedUsers.value.length) with initialEmergencyAccessSettings.value.defaultMinMembers !== effectiveDefaultMinMembers.value; update any save-path code that repeats the same ternary to use effectiveDefaultMinMembers.value as well so the single computed centralizes the rule.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@frontend/src/components/AdminSettingsEmergencyAccess.vue`:
- Around line 252-259: The unsaved-change logic in the hasUnsavedChanges
computed duplicates the calculation for the effective default min members;
extract that logic into a new computed (e.g., effectiveDefaultMinMembers) that
returns allowChoosing.value ? minMembers.value : selectedUsers.value.length and
then replace the inline expression
initialEmergencyAccessSettings.value.defaultMinMembers !== (allowChoosing.value
? minMembers.value : selectedUsers.value.length) with
initialEmergencyAccessSettings.value.defaultMinMembers !==
effectiveDefaultMinMembers.value; update any save-path code that repeats the
same ternary to use effectiveDefaultMinMembers.value as well so the single
computed centralizes the rule.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 69d561eb-9801-4aab-b011-8822cd414ad7
📒 Files selected for processing (1)
frontend/src/components/AdminSettingsEmergencyAccess.vue
Co-authored-by: Sebastian Stenzel <[email protected]>
Summary
Fix false "unsaved changes" indicator in admin emergency access settings when "let vault owners choose different key holders" is disabled
Problem
When saving with
allowChoosingEmergencyCouncil = false,defaultMinMembersis persisted asselectedUsers.lengthinstead ofminMembers. ThehasUnsavedChangescheck compared againstminMembers(the raw input value), which differed from the saved value — causing the warning to persist immediately after a successful save.Solution
Use the same conditional expression in
hasUnsavedChangesas in the save function:allowChoosing ? minMembers : selectedUsers.length