Skip to content

Conversation

@Simrayz
Copy link
Contributor

@Simrayz Simrayz commented Aug 11, 2025

Scope and purpose

This PR continues the initial POC done in #2883 , and adds a completed replacement for the "Quickselect" component in the Maintenance view using HTMX. The same change could be implemented in the devicehistory tool, to get rid of the quickselect component entirely. However, this would have to be done in a separate issue/PR.

This pull request

  • Replaces "Select components" implemenation using Quickselect with HTMX
  • Uses only Foundation 5 buttons for consistency.
  • Enables selecting new components and editing the selected components listing without refreshing the page.
  • Enables adding components for a single type, without triggering submission of all multiselects.
  • Adds new urls and corresponding views to support HTMX, /maintenance/search/ (component_search()) and /maintenance/selectcomponents (component_select()).
  • Add reusable partial _selected-components-list, which is used on initial load in new_task.html and as response template in component_search(...)
  • The "Select components" form now only shows results after searches, and does not load the entire list of components.
  • The select supports multiselect, and is cleared upon pressing "Add component".
  • The "Selected components" listing includes a "Select all" and "Unselect all" button at the top, to enable bulk adjustment of selected components.

Screenshots

Previous implementation

image

With HTMX

image

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with black and ruff, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • This pull request is based on the correct upstream branch: For a patch/bugfix affecting the latest stable version, it should be based on that version's branch (<major>.<minor>.x). For a new feature or other additions, it should be based on master.
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this adds a new Python source code file: Added the boilerplate header to that file

@CLAassistant
Copy link

CLAassistant commented Aug 11, 2025

CLA assistant check
All committers have signed the CLA.

@Simrayz Simrayz requested a review from lunkwill42 August 11, 2025 12:43
@Simrayz Simrayz self-assigned this Aug 11, 2025
@Simrayz Simrayz requested a review from podliashanyk August 11, 2025 12:44
@github-actions
Copy link

github-actions bot commented Aug 11, 2025

Test results

   12 files     12 suites   12m 2s ⏱️
2 250 tests 2 250 ✅ 0 💤 0 ❌
6 225 runs  6 225 ✅ 0 💤 0 ❌

Results for commit 165a596.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

❌ Patch coverage is 95.83333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.87%. Comparing base (8a60b1d) to head (165a596).
⚠️ Report is 540 commits behind head on master.

Files with missing lines Patch % Lines
python/nav/web/maintenance/views.py 93.33% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3425       +/-   ##
===========================================
+ Coverage        0   60.87%   +60.87%     
===========================================
  Files           0      607      +607     
  Lines           0    44280    +44280     
  Branches        0       48       +48     
===========================================
+ Hits            0    26954    +26954     
- Misses          0    17314    +17314     
- Partials        0       12       +12     

☔ 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.

@Simrayz Simrayz marked this pull request as ready for review August 12, 2025 13:19
Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

This is a beautiful first PR, if you ask me 🤩

The test coverage is great, but you'll find that most of my comments are about the tests themselves. You'll find that I tend to be quite picky about these things ;-)

I did not comment on all tests, as my comments and renaming suggestions can work generically - feel free to compare my comments to your other tests.

I quite like this pattern of naming tests (but you will of course find lots of legacy test code in NAV which does not measure up to this - clean as you go is a good keyword here): https://en.wikipedia.org/wiki/Given-When-Then

Copy link
Contributor

@johannaengland johannaengland left a comment

Choose a reason for hiding this comment

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

Works great! Just small nitpicks

lunkwill42 and others added 2 commits August 13, 2025 17:29
Make component_search POST-only

As mentioned in code review.

feat: Start implementing component select with HTMX

feat: Implement component select and listing with HTMX

chore: Add changelog entry

chore(maintenance): Remove quickselect code from maintenance tool

fix(maintenance/utils): Use 3.9 comopatible union type
chore(maintenance/tests): Improve test names and reduce asserts per test

feat(maintenance/views): Strip whitespace from search query
@Simrayz Simrayz force-pushed the poc/maintenance-htmx-simen branch from 2c1e705 to 870d276 Compare August 13, 2025 16:04
@lunkwill42 lunkwill42 changed the title POC: Replace Quickselect in Maintenance form with HTMX Replace Quickselect in Maintenance form with HTMX Aug 15, 2025
Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

This is nice. SonarCloud has two tiny nit-picks, about a missing docstring and alt-attribute for the spinner. Fix those, and we should be good to merge!

I removed the POC: from the title. This is no longer just a Proof-of-concept, this is more or less production ready :)

@sonarqubecloud
Copy link

@Simrayz Simrayz requested a review from lunkwill42 August 15, 2025 11:05
@Simrayz
Copy link
Contributor Author

Simrayz commented Aug 15, 2025

@lunkwill42 Ready for merge 🚀

Copy link
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

🎉

@lunkwill42 lunkwill42 merged commit 077d920 into master Aug 18, 2025
17 checks passed
@lunkwill42 lunkwill42 deleted the poc/maintenance-htmx-simen branch August 18, 2025 09:58
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.

5 participants