-
Notifications
You must be signed in to change notification settings - Fork 14
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
Make it possible to create and select incident filters #1122
Conversation
No functionality
Both filter params and the incidents table are updated accordingly to a selected filter
In order to match expected FilterKey
Test results 10 files 1 060 suites 38m 14s ⏱️ Results for commit 0cd72b9. ♻️ This comment has been updated with latest results. |
We could also make open/closed and acked/unacked take up less space. |
68dd3e8
to
beba7b2
Compare
src/argus/htmx/incident/views.py
Outdated
filter_pk, filter_obj = request.session.get("selected_filter", None), None | ||
if filter_pk: | ||
filter_obj = get_object_or_404(Filter, pk=filter_pk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest placing this inside incident_list_filter
instead of in the view. This keeps both the view and the filter-plugin interface clean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unclear. The session stuff or raising the 404 or both?
I'm not too fond of raising 404 directly in incident_list_filter
.
src/argus/htmx/incident/views.py
Outdated
def create_filter(request: HtmxHttpRequest): | ||
filter_name = request.POST.get("filter_name", None) | ||
incident_list_filter = get_filter_function() | ||
filter_form, _ = incident_list_filter(request, None) | ||
if filter_name and filter_form.is_valid(): | ||
filterblob = filter_form.to_filterblob() | ||
_, filter_obj = create_named_filter(request, filter_name, filterblob) | ||
if filter_obj: | ||
request.session["selected_filter"] = str(filter_obj.id) | ||
return HttpResponseClientRefresh() | ||
messages.error(request, "Failed to create filter") | ||
return HttpResponseBadRequest() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a nice candidate for extending the filter plugin system (which is currently only get_filter_function
). If we can override filter validation and creation of Filter
s, we can also make use of this endpoint (and others concerning filters). Don't think it'll have to be this pr though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope now, yes, let's make it work first. Also we should have update and delete filter working first I suspect!
14e7ed6
to
91a5b79
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1122 +/- ##
==========================================
- Coverage 79.08% 78.48% -0.61%
==========================================
Files 141 141
Lines 5375 5442 +67
==========================================
+ Hits 4251 4271 +20
- Misses 1124 1171 +47 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good! Now it is only nitpicking and polish suggestion for new issues from my side
I think it would be good to add comments to the parts that override request.session["selected_filter"] to explain why that is happening (to persist the choices)
Quality Gate passedIssues Measures |
Closes #1045