-
Notifications
You must be signed in to change notification settings - Fork 44
[PM-13428] Remove ownership option #1405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditItemView.swift # BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditItemViewTests.swift
Great job, no security vulnerabilities found in this Pull Request |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1405 +/- ##
==========================================
- Coverage 89.73% 89.73% -0.01%
==========================================
Files 785 785
Lines 49286 49289 +3
==========================================
+ Hits 44229 44231 +2
- Misses 5057 5058 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@@ -284,6 +284,7 @@ final class AddEditItemProcessor: StateProcessor<// swiftlint:disable:this type_ | |||
state.collections.contains(where: { $0.id == collectionId }) | |||
} | |||
|
|||
state.hasOrganizations = try await services.vaultRepository.hasOrganizations() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Do we need to consider if any of the organizations are disabled or if the user isn't confirmed in the organization? For example VaultRepository.fetchCipherOwnershipOptions()
has the following checks:
ios/BitwardenShared/Core/Vault/Repositories/VaultRepository.swift
Lines 1012 to 1015 in dc5f086
func fetchCipherOwnershipOptions(includePersonal: Bool) async throws -> [CipherOwner] { | |
let organizations = try await organizationService.fetchAllOrganizations() | |
let organizationOwners: [CipherOwner] = organizations | |
.filter { $0.enabled && $0.status == .confirmed } |
I wonder if it would be easier to check state.ownershipOptions.contains { !$0.isPersonal }
rather than do another fetch from the database?
if store.state.configuration.isAdding, let owner = store.state.owner { | ||
if let owner = store.state.owner, store.state.hasOrganizations { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ I'm seeing that if I edit an item in my personal vault, I can change the owner. Is that expected, or should the ownership field be disabled? (e.g. should the disabled modifier not have the !owner.isPersonal
check?). Because I thought you couldn't change the other while editing without also adding a separate API call to move the item.
And similarly, if I edit an item in an organization, should I be able to toggle the collection toggles on this screen? I think that also requires a separate API call which is why you needed to go to the edit collections screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you belong to an organization and the personal vault isn't disabled it will be possible to change the owner. And yes, we should be able to toggle the collection toggles.
However, as you said both cases require a separate API call, thank you for feedback.
I'm going to remove these changes as it's more complex than I originally thought and falls outside the scope of the bug.
/// Whether the user belongs to any organization. | ||
var hasOrganizations: Bool { get set } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎨 From what I can see this depends on the cipher
and the ownershipOptions
. Couldn't this be just readonly and calculate the value based off these other properties? Correct me if I'm wrong but something like:
/// Whether the user belongs to any organization. | |
var hasOrganizations: Bool { get set } | |
/// Whether the user belongs to any organization. | |
var hasOrganizations: Bool { | |
cipher.organizationId != nil || ownershipOptions.contains { !$0.isPersonal } | |
} |
This would make the change much simpler and you avoid having to update the variable from outside the state.
# Conflicts: # BitwardenShared/UI/Vault/VaultItem/AddEditItem/__Snapshots__/AddEditItemViewTests/test_snapshot_add_identity_full_fieldsFilled_largeText.1.png # BitwardenShared/UI/Vault/VaultItem/CipherItemState.swift
var hasOrganizations: Bool { | ||
cipher.organizationId != nil || ownershipOptions.contains { !$0.isPersonal } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ Add tests.
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-13428
📔 Objective
Removed ownership option when the user doesn't belong to an organization since they can't select anything else other than themselves.
Disabled the ownership picker when editing an item that belongs to an organization.
📸 Screenshots
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes