Skip to content

Add Sources management to HTMX interface#1901

Merged
Simrayz merged 8 commits into
mainfrom
feat/1898-sources-management
Apr 28, 2026
Merged

Add Sources management to HTMX interface#1901
Simrayz merged 8 commits into
mainfrom
feat/1898-sources-management

Conversation

@Simrayz

@Simrayz Simrayz commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Scope and purpose

Fixes #1898.

Add staff-only Sources management (SourceSystem and SourceSystemType) to the HTMX interface, removing the need to use the Django admin panel for this.

Screenshots

Screenshot Description
image Sources overview
image Create Form: The username field preview is automatically synced with the name
image Edit Form
image Dropdown menu 1: An unused source can be deleted, and a missing token can be generated
image Dropdown menu 2: A used source delete is disabled, and tokens can be regenerated at any time
image Source Types overview. Only unused types can be deleted.
image Create Source Type Form. Can only set name.
image Sources menu item.

Contributor Checklist

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Linted/formatted the code with ruff and djLint, 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 our how-to
  • If this results in changes in the UI: Added screenshots of the before and after

@github-actions

github-actions Bot commented Apr 23, 2026

Copy link
Copy Markdown

Test results

    6 files  1 248 suites   2m 25s ⏱️
  909 tests   908 ✅ 1 💤 0 ❌
5 454 runs  5 448 ✅ 6 💤 0 ❌

Results for commit 51a5024.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented Apr 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.43%. Comparing base (b7a7170) to head (2513c76).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1901      +/-   ##
==========================================
+ Coverage   88.21%   88.43%   +0.22%     
==========================================
  Files         140      143       +3     
  Lines        6848     6954     +106     
==========================================
+ Hits         6041     6150     +109     
+ Misses        807      804       -3     

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

@Simrayz Simrayz self-assigned this Apr 23, 2026
@Simrayz Simrayz force-pushed the feat/1898-sources-management branch 8 times, most recently from 2d34171 to eddf5aa Compare April 23, 2026 15:23
@Simrayz Simrayz requested a review from a team April 23, 2026 15:33
@Simrayz Simrayz added frontend Affects frontend backend UX UX design help needed/Improves user experience labels Apr 23, 2026
@Simrayz Simrayz marked this pull request as ready for review April 23, 2026 15:34
@Simrayz Simrayz force-pushed the feat/1898-sources-management branch from eddf5aa to 1a263ba Compare April 23, 2026 15:34
Comment thread src/argus/htmx/sourcesystem/forms.py
Comment thread src/argus/htmx/sourcesystem/views.py Outdated
Comment thread src/argus/htmx/sourcesystem/views.py
@Simrayz Simrayz requested a review from johannaengland April 24, 2026 12:26
</div>
</div>
<form method="dialog" class="modal-backdrop">
<button>close</button>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure if you can reproduce this, but when I try to delete a source type the "close" is at a strange position:

Image

This does not happen for sources

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did have this problem, but it's fixed for me. Have you rebuilt the css?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have, still the same problem 🤷

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@johannaengland I thought you were referring to the Sources delete dialog, and didn't realize the Source Type dialog was implemented differently 🥲 Should be fixed now though (see the fixup)!

@Simrayz Simrayz requested a review from johannaengland April 27, 2026 07:36
Comment thread src/argus/htmx/utils.py
Comment on lines +16 to +20
class UserIsStaffMixin(UserPassesTestMixin):
def test_func(self):
return self.request.user.is_staff


@hmpf hmpf Apr 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Much better location than in plannedmaintenance, yes, though the ultimate location is in argus.htmx.auth.utils, if Django doesn't already have this mixin. No need to move it, though.

@hmpf hmpf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very good that you are told you can't delete sources with incidents.

Having the token column is excellent, but the token is only accessible when regenerating. There are two token systems, though. What about the knox tokens?

drf tokens needs to be stored in the glue service somehow and I'm not sure ppl will realize they can just select the text in the green popup.

Follow-up:

I think it would be better to not have the popup but to alter the row (add a temporary row just after?) with the message and token, and maybe a copypaste button (that does not break selecting the token manually!) with a "I've seen you, go away"-button. That will also help if multiple tokens are set at a time. Each is shown, next to the source it is for.

@Simrayz Simrayz force-pushed the feat/1898-sources-management branch from feab55c to 51a5024 Compare April 28, 2026 10:05
@Simrayz Simrayz force-pushed the feat/1898-sources-management branch from 51a5024 to 2513c76 Compare April 28, 2026 11:12
@Simrayz Simrayz merged commit 1bfd2c9 into main Apr 28, 2026
8 of 9 checks passed
@Simrayz Simrayz deleted the feat/1898-sources-management branch April 28, 2026 11:12
@sonarqubecloud

Copy link
Copy Markdown

@Simrayz

Simrayz commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Very good that you are told you can't delete sources with incidents.

Having the token column is excellent, but the token is only accessible when regenerating. There are two token systems, though. What about the knox tokens?

drf tokens needs to be stored in the glue service somehow and I'm not sure ppl will realize they can just select the text in the green popup.

Follow-up:

I think it would be better to not have the popup but to alter the row (add a temporary row just after?) with the message and token, and maybe a copypaste button (that does not break selecting the token manually!) with a "I've seen you, go away"-button. That will also help if multiple tokens are set at a time. Each is shown, next to the source it is for.

@hmpf Created a follow-up issue #1911

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend frontend Affects frontend UX UX design help needed/Improves user experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Sources management to HTMX interface

3 participants