Skip to content

Add the option to edit a page from the Userbar#5

Merged
thibaudcolas merged 3 commits into
wagtail:mainfrom
saevarom:headless-page-edit
Jun 18, 2026
Merged

Add the option to edit a page from the Userbar#5
thibaudcolas merged 3 commits into
wagtail:mainfrom
saevarom:headless-page-edit

Conversation

@saevarom

Copy link
Copy Markdown
Contributor

I have been experimenting with a headless setup and the dynamic Userbar. What I found lacking is the option to edit a page from the Userbar. This PR along with an edit to the feature in the headless branch of bakerydemo will accomplish that.

The changes needed in the backend to accomplish these changes are:

class UserbarView(TemplateView):
    template_name = Userbar.template_name
    http_method_names = ["get"]

    def dispatch(self, request, *args, **kwargs):
        response = super().dispatch(request, *args, **kwargs)
        client_url = headless_preview_settings.CLIENT_URLS["default"]
        response["Access-Control-Allow-Origin"] = client_url
        return response

    def get_context_data(self, **kwargs):
+        object = None
+        page_id = self.request.GET.get('page_id', None)
+        if page_id:
+            object = Page.objects.filter(id=page_id).first()

-        return Userbar(object=None, position="bottom-left").get_context_data(
+        return Userbar(object=object, position="bottom-left").get_context_data(
            super().get_context_data(request=self.request, **kwargs)
        )

@thibaudcolas thibaudcolas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

excellent, ty!

Comment thread components/Userbar.tsx Outdated
@thibaudcolas thibaudcolas merged commit 0e2e5ca into wagtail:main Jun 18, 2026
1 check passed
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