Skip to content

[PM-21691] - Added tree and test with implementation for CollectionView #279

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

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

jrmccannon
Copy link

@jrmccannon jrmccannon commented May 19, 2025

🎟️ Tracking

PM-21691

📔 Objective

This splits the collections code out of the vault crate and adds a Tree implementation for representing the parent child relationship between nested collections.

⏰ 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 May 19, 2025

Logo
Checkmarx One – Scan Summary & Details5e5790f8-8451-41ca-a04f-5536b04c3067

Great job, no security vulnerabilities found in this Pull Request

@jrmccannon jrmccannon force-pushed the jmccannon/ac/pm-21691-nested-tree branch from d1e534f to b0dbb1c Compare May 27, 2025 21:15
Copy link

codecov bot commented May 27, 2025

Codecov Report

Attention: Patch coverage is 87.27273% with 28 lines in your changes missing coverage. Please review.

Project coverage is 70.49%. Comparing base (38654e9) to head (1a4a122).

Files with missing lines Patch % Lines
crates/bitwarden-collections/src/collection.rs 20.00% 12 Missing ⚠️
crates/bitwarden-collections/src/tree.rs 94.97% 10 Missing ⚠️
crates/bitwarden-vault/src/collection_client.rs 0.00% 3 Missing ⚠️
crates/bitwarden-collections/src/error.rs 0.00% 1 Missing ⚠️
crates/bitwarden-collections/src/lib.rs 0.00% 1 Missing ⚠️
crates/bitwarden-collections/src/uniffi_support.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #279      +/-   ##
==========================================
+ Coverage   70.32%   70.49%   +0.17%     
==========================================
  Files         217      221       +4     
  Lines       16992    17209     +217     
==========================================
+ Hits        11949    12132     +183     
- Misses       5043     5077      +34     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coroiu coroiu left a comment

Choose a reason for hiding this comment

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

Just some minor comments, but very nice overall, +1 for the tests 👍

}

impl<T: TreeItem> Tree<T> {
pub fn from_items(items: &mut Vec<T>) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: I would take the value here since we are modifying it in unexpected ways inside of the function (sorting). It might also mean that we can get away with not cloning the items when you put them in the tree since you'd have ownership of them

pub fn new<T: TreeItem>(id: usize, parent_idx: Option<usize>, children_idx: Vec<usize>, index: TreeIndex<T>) -> Self {
TreeNode {
id,
item_id: index.data.id().unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: unwrap is not allowed

suggestion: either remove the ability for this to be optional or use Result:Err somehow

Comment on lines 221 to 224
let node_option = Tree::from_items(&mut items)
.get_item_by_id(child_1_id);

if let Some(node) = node_option {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: same here, simplify with expect

@jrmccannon jrmccannon changed the title Added tree and test with implementation for CollectionView [PM-21691] - Added tree and test with implementation for CollectionView Jun 6, 2025
Copy link

sonarqubecloud bot commented Jun 6, 2025

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