Skip to content
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

[5.x] Improve feedback when action fails #10264

Merged

Conversation

simonerd
Copy link
Contributor

@simonerd simonerd commented Jun 5, 2024

replaces concerned parts of #10191
requires changes in Revisable from #10263


With the changes in #10263 the publishWorkingCopy and unpublishWorkingCopy return false when save fails (e. g. because an entrySaving listener returns false). When working on this I realised that the publish/unpublish actions don't show any errors if saving fails. In this PR I added a way of letting an action fail and optionally add a message that will be shown in the error toast.

// edit: extended to also cover the 'delete' action

Additionally, I was not quite happy with the handling of the action modal. So far, if the action was not successful, the confirmation modal would still be shown and an error toast would pop up. This kind of suggests that something went technically wrong, as the interface is stuck – similar to when an ajax error occurres.

I felt like it would be more appropriate if the modal closes, but the error toast doesn't just give you a generic "action failed" answer. To get there, I introduced a status information to the ActionController response, and adjusted the modal handling based on that status. Errors because of missing auth or something else still leave the modal open, while unsuccessful publish/unpublish actions close the modal and show an error toast.

@simonerd
Copy link
Contributor Author

simonerd commented Jun 6, 2024

We just realised in a different case that this also applies to the 'delete' action. I have extended the code to also cover that.

@simonerd simonerd changed the title [5.x] Improve action feedback when save fails [5.x] Improve feedback when action fails Jun 6, 2024
@jasonvarga jasonvarga merged commit 6db65ff into statamic:5.x Sep 23, 2024
16 checks passed
duncanmcclean added a commit to statamic-rad-pack/runway that referenced this pull request Sep 27, 2024
This should mean that the built assets include the changes from statamic/cms#10264.

Fixes #614.
caseydwyer added a commit to caseydwyer/statamic-cms that referenced this pull request Sep 27, 2024
mirrors the `data-list\HasActions.js` approach, as updated in statamic#10264.
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