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

Manually applying a draft or creating an entry from a draft leaves the submission in pending state #187

Open
MoritzLost opened this issue Apr 5, 2023 · 10 comments

Comments

@MoritzLost
Copy link

Describe the bug

When a publisher reviews a submission, they get the options to approve or reject the submission. Approving it will automatically apply the draft, or create an entry if it's an unpublished draft for a new entry. However, the publishers also have the regular buttons to apply the draft (or Create entry for unpublished drafts). Using those will leave the submission in Pending state. In this case, the interface for approving or rejecting the submission is still displayed:

Screenshot 2023-04-05 at 12 07 54

However, trying to approve or reject the submission will result in an error:

HTTP 400 – Bad Request – yii\web\BadRequestHttpException
No draft was identified by the request.

This makes sense, since the draft the submission was referencing doesn't exist any more. But from a user's perspective, this is an error and is hard to understand.

I think the best solution would be to automatically set the submission to Approved in this case. If the draft is manually applied, this means the submission was accepted, so this makes sense from the publisher's perspective. This would also mean that the email notification to the editor is sent as well, which is currently impossible, since the submission can't be approved once the draft has been applied.

Steps to reproduce

  1. As an editor, create a draft for a new entry and submit it.
  2. As the publisher, go to the draft and click on Create entry.
  3. After the entry is created, click on Approve and publish, this will cause the error mentioned above.

Craft CMS version

4.4.5

Plugin version

2.0.4

Multi-site?

No

Additional context

No response

@engram-design
Copy link
Member

Hmmm, it's a big assumption to make that if a draft that was linked to the submission that now doesn't exist means that it's been approved. But I suppose short of a draft being outright deleted, there's not too many other scenarios that could happen.

I'll give it some further thought.

@MoritzLost
Copy link
Author

@engram-design Can't this be done with entry save hooks? When an entry is saved, the plugin can hook into the save process and check if the draft being saved is associated with any pending submission and approve that submission. This leaves out any guesswork. Or am I missing something?

@engram-design
Copy link
Member

All of workflows actions are already on the save events, but only if they “opt in” to a workflow action. In theory what you propose should be okay, but I feel like I might be missing something (I can’t think of immediately) so I’ll test out a few scenarios.

@MoritzLost
Copy link
Author

@engram-design Got it, thanks!

@martijnvanonz
Copy link

Hi all,

Is there maybe an update on this?

@MoritzLost
Copy link
Author

MoritzLost commented Dec 10, 2024

@engram-design Did you have a chance to test out the edge-case you were worried about yet?

The client just ran into this issue again. It's really tough to communicate that they can't use the regular buttons to save entries at all while a submission is pending, or the submission will be in an unclear state. It would be great if this could be addressed in some way.

If automatically approving the submission as mentioned above is not an option: Maybe the submission card in the sidebar (as well as the submission page) could identify if this case occurred (pending submission with a draft that no longer exists), and offer a way to revover? I'm imagining an alert / prompt like this:

It looks like the draft that this submission relates to was already merged manually. Mark the submission as approved?
Yes / No

@engram-design
Copy link
Member

Just a few little things to fix up, due to draft behaviour being different for new vs existing entries.

To get this early, run composer require verbb/workflow:"dev-craft-4 as 2.0.13".

@MoritzLost
Copy link
Author

MoritzLost commented Dec 12, 2024

@engram-design Thanks! We're already on Craft 5 with this project (at least in dev, I'm finalizing the update atm), I'm not seeing the same change in the craft-5 branch yet? As far as I can tell, the issue still exists in Craft 5.

@engram-design
Copy link
Member

I usually merge things for each major version at the time of release, but happy to merge now. To get this early, run composer require verbb/workflow:"dev-craft-5 as 3.0.5".

@MoritzLost
Copy link
Author

@engram-design Thanks, I'll give it a try 👍

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

No branches or pull requests

3 participants