Skip to content

Conversation

@jnovinger
Copy link
Member

@jnovinger jnovinger commented Mar 10, 2025

Fixes: #18782

This PR does two things to address this bug:

  • Updated the check before htmx_url has query params added so that we don't try to add them to None. This has the effect of properly triggering the branch in the template that indicates this widget can not be displayed.
  • It also adds validation for ObjectListWidget.ConfigForm.model via a clean_model method that checks to make sure that a model is supported by ObjectListWidget at the time of creation. This results in the following error for the user:
    image

I'm open to adjust that error message as needed.

I also played around with disabling unsupported object choices, but ended up not including those in the PR. Will add a screenshot if anyone is interested in seeing them.

If this is done incorrently, then the string formatting operation turns
`htmx_url` into a string and the test in the template fails.
@jnovinger jnovinger marked this pull request as draft March 10, 2025 14:59
@jnovinger jnovinger marked this pull request as ready for review March 10, 2025 15:11
@jnovinger jnovinger requested review from a team and bctiemann and removed request for a team March 10, 2025 15:11
@jnovinger jnovinger changed the title Fixes #18782: properly check if htmx_url is None Fixes #18782: Allows misconfigured widget to degrade gracefully Mar 10, 2025
@jnovinger jnovinger changed the title Fixes #18782: Allows misconfigured widget to degrade gracefully Fixes #18782: Misconfigured ObjectListWidget now degrade gracefully Mar 12, 2025
@jnovinger jnovinger changed the title Fixes #18782: Misconfigured ObjectListWidget now degrade gracefully Fixes #18782: Misconfigured ObjectListWidgets now degrade gracefully Mar 12, 2025
@bctiemann
Copy link
Contributor

@jnovinger This works in scope, however I noticed another weird adjacent behavior which we might want to try to fix at the same time if possible, if it's in the same code area (if not, I'll open a separate bug).

Screenshot 2025-03-18 at 1 56 17 PM

If you click the X to clear the "Widget type" value (or backspace the existing value), the page immediately bombs to this error:

Screenshot 2025-03-18 at 1 57 43 PM

This behavior is in main too, so it isn't related to your fix. I'll probably open another issue accordingly as it's likely a separate problem, but please weigh in if it looks familiar.

@bctiemann bctiemann merged commit 7c152e9 into main Mar 18, 2025
6 checks passed
@jnovinger jnovinger deleted the 18782-dashboard-broken-on-notification-list-widget branch March 21, 2025 21:53
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard broken after adding widget

3 participants