Skip to content

Conversation

@mattwyatt-ix
Copy link
Contributor

Changes:
on the iSCSI shares page, clicking the Target navigation link when already on that section of the component would cause the target details to disappear due to us not checking if we were on mobile layout or not. this was breaking some automated tests.

Testing:

  1. create an iSCSI share - it doesn't have to be valid. it just has to exist.
  2. in the shares page, click the Targets navigation tab at the top and observe that the details pane doesn't disappear.

Screen recordings:

Downstream

Affects Reasoning
Documentation
Testing

@mattwyatt-ix mattwyatt-ix self-assigned this Dec 17, 2025
@bugclerk bugclerk changed the title NAS-138487: fix: prevent iSCSI target details from closing on navigation NAS-138487 / 26.04 / fix: prevent iSCSI target details from closing on navigation Dec 17, 2025
@bugclerk
Copy link
Contributor

@claude
Copy link

claude bot commented Dec 17, 2025

Claude finished @mattwyatt-ix's task —— View job


Code Review Complete ✅

Tasks

  • Read review guidelines
  • Examine changed files
  • Check for unrelated SMB tests
  • Verify adherence to best practices
  • Assess test coverage
  • Provide comprehensive feedback

Review Findings

Great fix! 🎉 The implementation correctly addresses the issue where clicking the "Target" navigation link would inappropriately close the details pane on desktop view. The solution is clean, well-tested, and the unrelated SMB tests have been properly removed.

✅ What's Working Well

The fix properly delegates to the MasterDetailViewComponent's isMobileView() signal, which uses Angular's BreakpointObserver under the hood. The test coverage is solid with clear test cases for both mobile and desktop scenarios.

🔍 Code Quality Observations

src/app/pages/sharing/iscsi/target/all-targets/all-targets.component.ts:78-80

isMobileView(): boolean {
  return this.masterDetailView().isMobileView();
}

This wrapper method works, but creates an unnecessary indirection. Since masterDetailView is already protected and the isMobileView is a public signal, the template and onMobileDetailsClosed() could call it directly:

// In onMobileDetailsClosed():
if (this.masterDetailView().isMobileView()) {
  this.dataProvider.expandedRow = null;
}

// If used in template, can do:
this.masterDetailView().isMobileView()

This would eliminate the wrapper method entirely. However, the current approach is also reasonable if you prefer the abstraction for readability.

src/app/pages/sharing/iscsi/target/all-targets/all-targets.component.spec.ts:46-52

The use of Object.defineProperty to override protected properties in tests is noted in the comment as "generally ill-advised, but in such a small case it's permissible." While it works, consider these alternatives for future improvements:

  1. Making dataProvider public (if it's reasonable for the API)
  2. Using a proper test setup method that initializes the component more completely
  3. Testing through the public API instead

For this specific case, the approach is acceptable given the constraints, and the explanatory comment is helpful.

📝 Minor Note

Line 59: The check !this.masterDetailView().isMobileView() correctly prevents auto-expanding the first target in mobile view. This is good defensive programming that complements the fix in onMobileDetailsClosed().

✅ Testing

Test coverage is appropriate for the scope of the change:

  • ✅ Tests the mobile view scenario (clears expanded row)
  • ✅ Tests the desktop view scenario (keeps expanded row)
  • ✅ Includes a basic component creation test
  • ✅ Good explanatory comments in the test file

The tests properly mock the isMobileView() behavior and verify the expected outcomes.

🎯 Summary

Solid fix that correctly addresses the navigation bug! The implementation is clean, follows Angular patterns, and includes good test coverage.


@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.67%. Comparing base (db6b5e7) to head (9e8b7af).
⚠️ Report is 11 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #13007      +/-   ##
==========================================
+ Coverage   86.61%   86.67%   +0.06%     
==========================================
  Files        1842     1844       +2     
  Lines       69157    69261     +104     
  Branches     8525     8540      +15     
==========================================
+ Hits        59898    60033     +135     
+ Misses       9259     9228      -31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mattwyatt-ix mattwyatt-ix marked this pull request as ready for review December 18, 2025 21:21
@mattwyatt-ix mattwyatt-ix requested a review from a team as a code owner December 18, 2025 21:21
@mattwyatt-ix mattwyatt-ix requested review from aervin and removed request for a team December 18, 2025 21:21
Copy link
Contributor

@aervin aervin left a comment

Choose a reason for hiding this comment

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

works well. there are some unrelated smb tests though

@mattwyatt-ix
Copy link
Contributor Author

works well. there are some unrelated smb tests though

that was from when i pulled ac2485f in to fix some failing tests i inherited from master. removed the extras!

@mattwyatt-ix mattwyatt-ix merged commit d2fd620 into master Dec 19, 2025
15 checks passed
@mattwyatt-ix mattwyatt-ix deleted the NAS-138487 branch December 19, 2025 19:02
@bugclerk
Copy link
Contributor

This PR has been merged and conversations have been locked.
If you would like to discuss more about this issue please use our forums or raise a Jira ticket.

@truenas truenas locked as resolved and limited conversation to collaborators Dec 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants