Skip to content

Keep around the current filter in query parameter for Discarding failed jobs#272

Merged
rosa merged 2 commits intorails:mainfrom
TimeTravelerFromNow:button-with-params
Jul 11, 2025
Merged

Keep around the current filter in query parameter for Discarding failed jobs#272
rosa merged 2 commits intorails:mainfrom
TimeTravelerFromNow:button-with-params

Conversation

@TimeTravelerFromNow
Copy link
Copy Markdown
Contributor

@TimeTravelerFromNow TimeTravelerFromNow commented Jul 10, 2025

Solves #161 by adding the current parameters to the discard button
Alternative to turbo stream solution proposed in #270

Solution

Add the current parameters to the discard button path, with params: params.permit!

Screenshot 2025-07-09 at 8 22 26 PM

Continue submitting params in the Discard and Retry buttons so that the next request keeps filter

Steps to test

  • Create some failed jobs of separate classes
  • Apply the filter in the view
  • Discard a job, check that it is deleted successfully and is removed from the view
  • The filter for the job class remains selected in the next request

Thoughts on this approach

After discussing some possible drawbacks of turbo for Discarding jobs in the view:

  • Incorrect state of discarded job if the server is down
  • rendering the flash message
  • Handling update the Failed job count display

I've come to the conclusion that for solving the issue of the filter persisting keep the params with the Discard button submission.

The hard refresh on redirect comes with the benefit of

  • immediate feedback of server uptime
  • Complete re-render ensures latest state is displayed
  • No maintenance of turbo streams required

Continue submitting params in the Discard and Retry buttons so that the next request keeps filter
@TimeTravelerFromNow TimeTravelerFromNow changed the title Add to the params in buttons Keep around the current filter for Discarding Jul 10, 2025
@TimeTravelerFromNow TimeTravelerFromNow changed the title Keep around the current filter for Discarding Keep around the current filter in query parameter for Discarding failed jobs Jul 10, 2025
@rosa
Copy link
Copy Markdown
Member

rosa commented Jul 11, 2025

I changed this a bit to include only the job filters and not all params in the URL, and to also preserve the params in the redirects.

Nice work, and thank you!

Only those, not all params, which include controller, actions, etc.
@rosa rosa merged commit d0fc674 into rails:main Jul 11, 2025
3 checks passed
@TimeTravelerFromNow TimeTravelerFromNow deleted the button-with-params branch July 12, 2025 16:23
@TimeTravelerFromNow
Copy link
Copy Markdown
Contributor Author

@rosa good work, thanks for revisiting this one

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.

2 participants