Skip to content

Conversation

@hmpf
Copy link
Contributor

@hmpf hmpf commented Nov 24, 2025

Scope and purpose

This makes the create/update/delete part of the filter box take up less space and changes the behavior of the widget so that update/delete no longer has a drop down but works on the already selected stored filter.

Screenshots

Before:

image

After:

image image

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to Argus can be found in the
Development docs.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation, including updates to the user manual if feature flow or UI is considerably changed
  • 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 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 results in changes to the database model: Updated the ER diagram

@hmpf hmpf requested review from a team and Simrayz November 24, 2025 07:47
@hmpf hmpf self-assigned this Nov 24, 2025
@hmpf hmpf moved this from 📋 Backlog to 🏗 In progress in Argus development, public Nov 24, 2025
@github-actions
Copy link

github-actions bot commented Nov 24, 2025

Test results

    4 files    524 suites   19m 39s ⏱️
  626 tests   625 ✅ 1 💤 0 ❌
2 504 runs  2 500 ✅ 4 💤 0 ❌

Results for commit bcd6413.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@Simrayz Simrayz left a comment

Choose a reason for hiding this comment

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

Tested manually, and it works well. Nice 😄

@hmpf hmpf force-pushed the shrink-stored-filter-widget branch from 810932f to 6e6d225 Compare November 26, 2025 09:01
@hmpf hmpf marked this pull request as ready for review November 26, 2025 09:01
@hmpf hmpf force-pushed the shrink-stored-filter-widget branch from 6e6d225 to badbae2 Compare November 26, 2025 09:01
@hmpf hmpf requested a review from a team November 26, 2025 11:09
@hmpf hmpf moved this from 🏗 In progress to ❓ Ready for review in Argus development, public Nov 26, 2025
@hmpf hmpf force-pushed the shrink-stored-filter-widget branch 6 times, most recently from 6482a4f to 9839d44 Compare November 26, 2025 13:48
@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

❌ Patch coverage is 78.88889% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.05%. Comparing base (571f143) to head (bcd6413).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/argus/htmx/incident/views.py 71.15% 15 Missing ⚠️
src/argus/htmx/incident/filter.py 89.47% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1621      +/-   ##
==========================================
+ Coverage   79.64%   80.05%   +0.41%     
==========================================
  Files         132      132              
  Lines        6120     6167      +47     
==========================================
+ Hits         4874     4937      +63     
+ Misses       1246     1230      -16     

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

@hmpf hmpf force-pushed the shrink-stored-filter-widget branch 2 times, most recently from 9eea3be to f4de5da Compare December 2, 2025 09:35
@hmpf hmpf changed the base branch from master to main December 2, 2025 09:36
@hmpf hmpf force-pushed the shrink-stored-filter-widget branch from f4de5da to ecb86ea Compare December 2, 2025 09:37
hmpf added 4 commits December 2, 2025 11:08
.. also added the name of each involved template to that template as an
html comment, for ease of debugging.
@hmpf hmpf force-pushed the shrink-stored-filter-widget branch from ecb86ea to 7030528 Compare December 2, 2025 10:08
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 2, 2025

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.

It works great for creating new filters and deleting existing filters, but updating a filter is not pretty unintuitive.

Because if I select a filter, then change any of the parameters (e.g. the slider for "acked"), then the name of the filter is updated to "---", which makes sense, because now we are using filter parameters that are not saved in the previously selected filter.

But to update the filter that I previously chose I still have to click on update now (while it's name is not in the filterbox anymore) and it will ask me if I want to update the previously selected filter. This is pretty confusing.

I rather would have a popup or something to ask me which filter I would like to update.



def _normalize_form_data(request):
def _normalize_form_data(raw_data):
Copy link
Contributor

Choose a reason for hiding this comment

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

While we're at it, we can even add a type hint:

Suggested change
def _normalize_form_data(raw_data):
def _normalize_form_data(raw_data: QueryDict):

Comment on lines +116 to +129
def set_selected_filter(request, filter_obj):
if filter_obj:
request.session["selected_filter_pk"] = str(filter_obj.pk)
request.session["selected_filter_name"] = filter_obj.name
else:
request.session["selected_filter_pk"] = None
request.session.pop("selected_filter_name", None)


def get_selected_filter(request):
filter_id = request.session.get("selected_filter_pk", None)
if filter_id:
return get_object_or_404(Filter, pk=filter_id, user=request.user)
return None
Copy link
Contributor

Choose a reason for hiding this comment

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

Beautiful helper functions!

return HttpResponseClientRefresh()
messages.error(request, f"Failed to update filter '{filter_obj.name}'.")
errors = f": {filter_form.errors}" if filter_form.errors else ""
messages.error(request, f'Failed to update filter "{filter_obj.name}": {errors}')
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
messages.error(request, f'Failed to update filter "{filter_obj.name}": {errors}')
messages.error(request, f'Failed to update filter "{filter_obj.name}"{errors}')

@@ -0,0 +1,60 @@
from django.http.response import Http404
from django.test import tag, RequestFactory, TestCase
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
from django.test import tag, RequestFactory, TestCase
from django.test import RequestFactory, TestCase, tag

Comment on lines +4 to +5
from argus.htmx.incident.views import filter_select
from argus.filter.factories import FilterFactory
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
from argus.htmx.incident.views import filter_select
from argus.filter.factories import FilterFactory
from argus.filter.factories import FilterFactory
from argus.htmx.incident.views import filter_select

pass


class filter_select_Test(TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
class filter_select_Test(TestCase):
class FilterSelectTest(TestCase):

factory = RequestFactory()

@tag("unit")
def test_when_no_filter_in_request_should_unset_filter_in_session(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the name of the test I would assume that a filter was saved in the session before, but it looks like none is set and we're just testing that that doesn't change

@github-project-automation github-project-automation bot moved this from ❓ Ready for review to ♻ Changes requested in Argus development, public Dec 3, 2025
@hmpf
Copy link
Contributor Author

hmpf commented Dec 3, 2025

How about keeping the previously selected name somewhere visible and keep the update button simple? Because having a drop-down has always been unintuitive to me. Maybe have a "save" vs. "save as" button instead of update, too?

@hmpf hmpf added the rc-future label Dec 3, 2025
@johannaengland
Copy link
Contributor

How about keeping the previously selected name somewhere visible and keep the update button simple? Because having a drop-down has always been unintuitive to me. Maybe have a "save" vs. "save as" button instead of update, too?

I really like the "save" and "save as" idea

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

Projects

Status: Changes requested

Development

Successfully merging this pull request may close these issues.

4 participants