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] Prevent published toast when save failed #10191

Closed

Conversation

simonerd
Copy link
Contributor

fixes #10190

I've tried to stay as close as possible to the changes made in #9040 but needed some further adjustments. Specifically, Revisable::publishWorkingCopy() and Revisable::unpublishWorkingCopy() now return false if the entry save() function fails. While this seems reasonable to me, I haven't yet found out if there are any other places (apart from the PublishedEntriesController) that would need to be considered.

I have added translations for the "Couldn't (un)publish entry" toast message as far as my (non-german) language skills felt reliable enough.

@duncanmcclean
Copy link
Member

We're no longer accepting fixes to 4.x, can you re-target this PR for 5.x?

simonerd added 3 commits May 24, 2024 12:46
# Conflicts:
#	resources/lang/de.json
#	resources/lang/de_CH.json
#	resources/lang/fr.json
#	resources/lang/nl.json
#	src/Http/Controllers/CP/ActionController.php
#	src/Http/Controllers/CP/Collections/PublishedEntriesController.php
@simonerd simonerd changed the base branch from 4.x to 5.x May 24, 2024 13:00
@simonerd simonerd changed the title [4.x] Prevent published toast when save failed [5.x] Prevent published toast when save failed May 24, 2024
@simonerd
Copy link
Contributor Author

We're no longer accepting fixes to 4.x, can you re-target this PR for 5.x?

Ah, sorry, didn't think about that 🙈 The project this is relevant to is still on 4.x, hence the target. Looks like they've got another reason not to wait with the 5.x update 😁

I've re-targeted and merged 5.x, will see if more changes are required.

@simonerd
Copy link
Contributor Author

@duncanmcclean done for now

Still on the 4.x branch I already realised that the publish/unpublish actions also don't show any errors if saving fails. I've added a way of letting an action fail and optionally add a message that will be shown in the error toast.

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.

Copy link
Member

@duncanmcclean duncanmcclean left a comment

Choose a reason for hiding this comment

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

Still on the 4.x branch I already realised that the publish/unpublish actions also don't show any errors if saving fails. I've added a way of letting an action fail and optionally add a message that will be shown in the error toast.

Can you open a separate pull request with these changes, since they're unrelated to the original issue?

@simonerd
Copy link
Contributor Author

simonerd commented Jun 5, 2024

I've split up the changes into two new PRs:

@simonerd simonerd closed this Jun 5, 2024
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.

'Published' toast is shown when returning false from EntrySaving listener
2 participants