[PM-40531] feat: Lock the "Who can view" selection when enforced by policy - #7266
[PM-40531] feat: Lock the "Who can view" selection when enforced by policy#7266andrebispo5 wants to merge 7 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7266 +/- ##
==========================================
- Coverage 86.25% 85.93% -0.33%
==========================================
Files 891 937 +46
Lines 65294 67225 +1931
Branches 9808 9861 +53
==========================================
+ Hits 56320 57769 +1449
- Misses 5472 5937 +465
- Partials 3502 3519 +17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Implements SendControls policy enforcement for the “Who can view” selection on the Add Send screen by forcing the initial auth/access type in the ViewModel and locking the chooser UI when an enforced policy applies.
Changes:
- Enforce initial
sendAuthbased onEffectiveSendPolicy.whoCanAccesswhen SendControls is enabled (add mode only). - Lock the “Who can view” chooser when an enforced access type applies, while keeping email/password sub-fields editable.
- Add/expand ViewModel and Compose UI tests covering enforced, ANY, and disabled/unset policy scenarios.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/main/kotlin/com/x8bit/bitwarden/ui/tools/feature/send/addedit/AddEditSendViewModel.kt | Enforces access type in add mode based on policy; exposes enforcedWhoCanAccess helper for UI locking. |
| app/src/main/kotlin/com/x8bit/bitwarden/ui/tools/feature/send/addedit/components/AddEditSendAuthTypeChooser.kt | Disables the chooser when enforcedWhoCanAccess is non-null. |
| app/src/main/kotlin/com/x8bit/bitwarden/ui/tools/feature/send/addedit/AddEditSendScreen.kt | Threads enforcedWhoCanAccess from state into content UI. |
| app/src/main/kotlin/com/x8bit/bitwarden/ui/tools/feature/send/addedit/AddEditSendContent.kt | Accepts/passes enforcedWhoCanAccess down to the chooser. |
| app/src/test/kotlin/com/x8bit/bitwarden/ui/tools/feature/send/addedit/AddEditSendViewModelTest.kt | Adds unit tests for initial enforcement and policy-change behavior. |
| app/src/test/kotlin/com/x8bit/bitwarden/ui/tools/feature/send/addedit/AddEditSendScreenTest.kt | Adds Compose UI tests for locked/unlocked chooser behavior under policy. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| val enforcedWhoCanAccess: SendAccessTypeJson? | ||
| get() = whoCanAccess?.takeIf { isSendControlsEnabled && it.restrictsAccess } |
There was a problem hiding this comment.
Intentional. AddEditSendCustomDateChooser (AddEditSendContent.kt:155) locks in edit mode the same way without an isAddMode gate, so this matches the existing pattern. Gating it would also let a compliant existing Send be switched to a type the policy forbids. Non-compliant existing Sends get edit disabled in a follow-up ticket.
| composeTestRule | ||
| .onNodeWithTag("SendAuthTypeChooser") | ||
| .performScrollTo() | ||
| .performClick() | ||
|
|
||
| // The enforced option is displayed, but the other options are never composed. | ||
| composeTestRule | ||
| .onNodeWithText("Anyone with the link") | ||
| .assertDoesNotExist() | ||
| composeTestRule | ||
| .onNodeWithText("Anyone with a password set by you") | ||
| .assertDoesNotExist() | ||
| composeTestRule | ||
| .onNodeWithText("Specific people") | ||
| .performScrollTo() | ||
| .assertIsDisplayed() |
There was a problem hiding this comment.
Added assertIsNotEnabled() on the chooser, good call, the disabled state was not pinned before. Keeping the assertDoesNotExist() assertions too: "the dialog does not open" is the actual requirement, and removing the lock does make them fail, so they are not brittle.
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-40531
📔 Objective
When an org's SendControls policy sets
whoCanAccess, the "Who can view" chooser on the Add Sendscreen starts on the enforced option and can't be changed.
What changed
SPECIFIC_PEOPLE→ Specific people,PASSWORD_PROTECTED→ Anyone with a password set by youANYleaves every option available, so it is not a restriction. The chooser stays interactive,same as no policy at all
Why the ViewModel, not the chooser
AddEditSendAuthTypeChoosergets saved
isEnabledchange
Out of scope
separately, when the edit option is disabled for them
Worth flagging
typed alone. PM-40532 reset the deletion date to its default instead; resetting here would throw
away entered emails or a password for no reason
normally blocks picking it by hand
📸 Screenshots