Skip to content

[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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

LRNcardozoWDF
Copy link
Member

@LRNcardozoWDF LRNcardozoWDF commented Mar 4, 2025

🎟️ 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

  • User doesn't belong to an organization, so the ownership picker doesn't show.
  • User belongs to an organization, so the ownership picker is available when adding a new item.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 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

Copy link
Contributor

github-actions bot commented Mar 4, 2025

Logo
Checkmarx One – Scan Summary & Details958f508f-8539-4ea3-bdd9-9b6daf1b0d1e

Great job, no security vulnerabilities found in this Pull Request

Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.73%. Comparing base (956e05d) to head (e174bd2).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LRNcardozoWDF LRNcardozoWDF marked this pull request as ready for review March 4, 2025 15:56
@@ -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()
Copy link
Collaborator

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:

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 {
Copy link
Collaborator

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.

Copy link
Member Author

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.

@vvolkgang vvolkgang changed the title [PM 13428] Remove ownership option [PM-13428] Remove ownership option Mar 6, 2025
matt-livefront
matt-livefront previously approved these changes Mar 12, 2025
Comment on lines 48 to 50
/// Whether the user belongs to any organization.
var hasOrganizations: Bool { get set }

Copy link
Member

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:

Suggested change
/// 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
Comment on lines +140 to +142
var hasOrganizations: Bool {
cipher.organizationId != nil || ownershipOptions.contains { !$0.isPersonal }
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ Add tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants