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

Add workflow actions to the Wagtail userbar #9106

Open
lb- opened this issue Aug 31, 2022 · 8 comments
Open

Add workflow actions to the Wagtail userbar #9106

lb- opened this issue Aug 31, 2022 · 8 comments

Comments

@lb-
Copy link
Member

lb- commented Aug 31, 2022

Issue Summary

  • Since Wagtail 2.10 it appears that the userbar no longer shows the Approve/Reject buttons when a page is in moderation (aka within a workflow)

Steps to Reproduce

  1. Open the bakerydemo or any new Wagtail project
  2. Using the default page moderation workflow, mark a page as ready for review
  3. Now go back to the admin home page and you should see the page listed under 'awaiting your review'
  4. Hover over the page and click the 'preview' button
  5. This preview page should open its own window, while signed in, so you see the Wagtail userbar (bird button)
  6. Click the userbar button
  7. Expected - the moderation/workflow approval button should be shown
  8. Actual - no moderation/workflow buttons are shown

Screen Shot 2022-08-31 at 6 28 57 pm

The page is awaiting approval - which shows on the Dashboard page and in the page actions but not on the userbar.

  • I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: no

Potentially broken since Wagtail 2.10

PageRevision.submitted_for_moderation will return True for revisions passing through the old moderation system, but not for the new system

Potential solution

The wagtailuserbar template tag is in https://github.com/wagtail/wagtail/blob/main/wagtail/admin/templatetags/wagtailuserbar.py#L65-L74

if page and page.id:
if revision_id:
revision = Revision.page_revisions.get(id=revision_id)
items = [
AdminItem(),
ExplorePageItem(revision.content_object),
EditPageItem(revision.content_object),
ApproveModerationEditPageItem(revision),
RejectModerationEditPageItem(revision),
]

This instantiates the classes ApproveModerationEditPageItem & RejectModerationEditPageItem which are declared in https://github.com/wagtail/wagtail/blob/main/wagtail/admin/userbar.py

class ModeratePageItem(BaseItem):
def __init__(self, revision):
self.revision = revision
def render(self, request):
if not self.revision.id:
return ""
if not self.revision.submitted_for_moderation:
return ""
if not request.user.has_perm("wagtailadmin.access_admin"):
return ""
if not self.revision.content_object.permissions_for_user(
request.user
).can_publish():
return ""
return super().render(request)

Ideally this logic would be updated to be similar to the logic used in the Dashboard (home) listing to determine the workflow state. Using something like revision.submitted

  • A general clean up of the legacy submitted_for_moderation would be good to do also.

Technical details

  • Python version: 3.0
  • Django version: 4.0
  • Wagtail version: 4.0RC
  • Browser version: Firefox 103 macOS 12.3
@lb- lb- added type:Bug status:Unconfirmed Issue, usually a bug, that has not yet been validated as a confirmed problem. labels Aug 31, 2022
@Lovelyfin00
Copy link
Contributor

Hi
Can I try working on this?

@lb-
Copy link
Member Author

lb- commented Oct 14, 2022

Go for it @Lovelyfin00 - we will also need to ensure there are new unit tests for this behaviour. It's likely some existing tests exist for the userbar legacy moderation buttons.

@lb- lb- added component:Workflow component:Userbar type:Bug and removed type:Bug status:Unconfirmed Issue, usually a bug, that has not yet been validated as a confirmed problem. labels Oct 14, 2022
@Lovelyfin00
Copy link
Contributor

Ok
Thank you☺
Can you attach links to resources and previous issues that could help me?
I'm very very new to this @lb

@lb-
Copy link
Member Author

lb- commented Oct 14, 2022

@Lovelyfin00 this may not be a good first issue sorry - but have a read of the issue in full and try to reproduce the problem, then also read all the links to get more context. I'll try to find the PR that implemented workflow and add a link to it.

@thibaudcolas
Copy link
Member

@Lovelyfin00 before you claim an issue, please make sure that you do have the appropriate skillset to do so! It takes a lot of time to curate issues so the problems are well described and potential solutions also covered. @lb- has already added plenty of details in the original description, and I don’t think there is much more to be said about this until you or someone else has done their own research.

If you’re still feeling very new to this – please do consider the good first issues only. They’re specially made so as to be approachable with very little background on how Wagtail works.

@thibaudcolas
Copy link
Member

thibaudcolas commented Jan 11, 2023

We’ve discussed this in today’s core team meeting – since this has been broken for such a long time, it’s unclear to us whether this is a bug for us to fix or dead code to remove and move on.

If any projects out there rely on this, or would want to rely on this if it worked, please let us know.


I’m not sure whether this code had ever been adapted to support workflows, so there may be quite a bit of work needed to make this happen. In particular I believe reject/approve support adding a comment everywhere else in the CMS, not sure whether it’d be a requirement to do this for the userbar too.

@laymonage
Copy link
Member

laymonage commented Oct 2, 2023

Per my comment on #10968 (comment), I don't think this is a bug. Workflows can have custom tasks which can use custom forms, so approving/rejecting a task may require additional user input instead of just a click of a button. Adding approve and reject items to the userbar would require the ability to render the modal dialog for the workflow approve/reject views rendered by https://github.com/wagtail/wagtail/blob/main/wagtail/admin/views/generic/workflow.py.

This might be easier to do once #9246 is done, as that means such modals will use the a11y-dialog, which is already included in the userbar as part of the accessibility checker.

And yes, we should remove the unused code for the legacy moderation system's userbar items. I've started #10968 to deprecate them so that they can be removed in the next major release.

Labelling as Enhancement.

@laymonage laymonage changed the title Wagtail userbar no longer shows moderation (workflow) actions Add workflow actions to the Wagtail userbar Oct 2, 2023
@lb-
Copy link
Member Author

lb- commented Oct 3, 2023

Thanks @thibaudcolas & @laymonage - this all makes sense.

Thanks for updating the issue and labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants