8000 [PM-18091] Update cipher delete & restore permissions by andrebispo5 · Pull Request #1474 · bitwarden/ios · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[PM-18091] Update cipher delete & restore permissions #1474

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

Merged
merged 4 commits into from
Apr 7, 2025

Conversation

andrebispo5
Copy link
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-18091

📔 Objective

Use new cipher permissions properties to show or hide the delete and restore buttons on the UI.

📸 Screenshots

Screen.Recording.2025-03-31.at.23.02.18.mov

⏰ 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

Logo
Checkmarx One – Scan Summary & Details0ecdee62-244c-4995-b809-89e085a8a10e

Great job, no security vulnerabilities found in this Pull Request

Copy link
codecov bot commented Mar 31, 2025

Codecov Report

Attention: Patch coverage is 91.66667% with 3 lines in your changes missing coverage. Please review.

Project coverage is 89.59%. Comparing base (faff479) to head (7a9b614).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...red/UI/Vault/VaultItem/ViewItem/ViewItemView.swift 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1474      +/-   ##
==========================================
+ Coverage   89.56%   89.59%   +0.02%     
==========================================
  Files         769      773       +4     
  Lines       48392    48539     +147     
==========================================
+ Hits        43343    43489     +146     
- Misses       5049     5050       +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.

///
func loadRestrictItemDeletionFlag() async {
state.restrictItemDeletionFlagEnabled = await services.configService.getFeatureFlag(
FeatureFlag.restrictItemDeletion
Copy link
Member

Choose a reason for hiding this comment

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

⛏️ I think there's no need to indicate the enum, it should be implicit.

Suggested change
FeatureFlag.restrictItemDeletion
.restrictItemDeletion

Comment on lines 68 to 70
/// A feature flag for the use of new cipher permission properties.
case restrictItemDeletion = "pm-15493-restrict-item-deletion-to-can-manage-permission"

Copy link
Member

Choose a reason for hiding this comment

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

⛏️ 🤔 Does this affect any item of the app, like a send or an attachment? Or does this only affect deletion of ciphers? If the latter I'd update the case name to something more explicit like restrictCipherItemDeletion. I would guess you wanted to match the case name with the flag string value but if we can be more explicit the better so we don't actually need to read the flag comment here to see what's being used for.
However, if you have reasons to keep using the current one please let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this is a property only for ciphers, I'll update the naming to better reflect the scope of action.

Comment on lines 146 to 154
/// Whether or not this item can be deleted by the user.
/// New permission model from PM-18091
var canBeDeletedPermission: Bool {
// backwards compatibility for old server versions
guard let cipherPermissions = cipher.permissions else {
return canBeDeleted
}
return cipherPermissions.delete
}
Copy link
Member

Choose a reason for hiding this comment

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

🎨 I believe you don't need the extra property and you can also save making the checks in the views if you combine this property with canBeDeleted, i.e.:

    /// Whether or not this item can be deleted by the user.
    var canBeDeleted: Bool {
        // New permission model from PM-18091
        if restrictItemDeletionFlagEnabled, let cipherPermissions = cipher.permissions {
            return cipherPermissions.delete
        }

        guard !collectionIds.isEmpty else { return true }
        return collections.contains { collection in
            guard let id = collection.id else { return false }
            return collection.manage && collectionIds.contains(id)
        }
    }

Comment on lines 523 to 525
let restrictItemDeletionFlagEnabled: Bool = await services.configService.getFeatureFlag(
FeatureFlag.restrictItemDeletion
)
Copy link
Member

Choose a reason for hiding this comment

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

⛏️ I believe you can skip the enum name reference:

Suggested change
let restrictItemDeletionFlagEnabled: Bool = await services.configService.getFeatureFlag(
FeatureFlag.restrictItemDeletion
)
let restrictItemDeletionFlagEnabled: Bool = await services.configService.getFeatureFlag(
.restrictItemDeletion
)

Copy link
Member
@fedemkr fedemkr left a comment

Choose a reason for hiding this comment

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

Sorry didn't mean to approve, I meant to request changes.

@andrebispo5 andrebispo5 requested a review from fedemkr April 7, 2025 13:56
@andrebispo5 andrebispo5 merged commit af3b1e6 into main Apr 7, 2025
10 checks passed
@andrebispo5 andrebispo5 deleted the pm-18091/update-cipher-permissions branch April 7, 2025 17:39
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.

2 participants
0