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 support for Wagtail 4.x #37

Merged
merged 4 commits into from
Jan 12, 2023
Merged

Add support for Wagtail 4.x #37

merged 4 commits into from
Jan 12, 2023

Conversation

willbarton
Copy link
Member

This pull request converts the TreeModelAdmin UI to use Wagtail 4’s breadcrumb and header pattern, dropping support for Wagtail 3 and below’s admin UI. After this, Wagtail < 4 will no longer be supported.

With Wagtail 4's admin UI changes, I've gone with a pattern that's slightly less like the page tree itself, and more like how ModelAdmin and Snippets appear:

image

I noted in the comments, but While Wagtail includes a shared breadcrumb template, it doesn't seem possible to use the wagtailadmin/shared/breadcrumbs.html template for non-page-based breadcrumbs. The implementation here borrows heavily from wagtailsnippets/snippets/headers/_base_header.html, where the same style breadcrumbs are also re-implemented (and which contains a similar TODO).

I've also changed the breadcrumb labeling a little bit. Prior to this change, breadcrumbs from our books example would follow this pattern:

J. R. R. Tolkein -> The Lord of the Rings -> Volumes

Where the author name would link to the full list of authors, the book name would link to the list of books under the author, and the book’s volumes would exist under the model name itself. This change makes that same set of breadcrumbs appear as:

Authors -> J. R. R. Tolkien -> The Lord of the Rings

Where “Authors” links to the full list of authors, the author name links to the authors books, and the book title links to the book’s volumes. In converting the breadcrumbs to Wagtail 4, this seemed more natural.

Finally, I've updated the gif in the README demonstrating how the library works, and updated the versions in the README.

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)

Copy link
Member

@chosak chosak left a comment

Choose a reason for hiding this comment

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

The source file wagtailmodeladmin/css/index.css was removed in wagtail/wagtail#8564, which causes a 404 error in the Wagtail admin. It looks like those styles were merged into the main admin core.css, so there's no need to replace this line with something else; but it is checked in a couple of tests so those need to be cleaned up.

README.md Outdated Show resolved Hide resolved
This change converts the TreeModelAdmin UI to use Wagtail 4’s breadcrumb and header pattern, dropping support for Wagtail 3 and below’s admin UI.
Prior to this change, breadcrumbs from our books example would follow this pattern:

J. R. R. Tolkein -> The Lord of the Rings -> Volumes

Where the author name would link to the full list of authors, the book name would link to the list of books under the author, and the book’s volumes would exist under the model name itself.

This change makes that same set of breadcrumbs appear as:

Authors -> J. R. R. Tolkien -> The Lord of the Rings

Where “Authors” links to the full list of authors, the author name links to the authors books, and the book title links to the book’s volumes.

In converting the breadcrumbs to Wagtail 4, this seemed more natural.
@willbarton
Copy link
Member Author

Took care of the wagtailmodeladmin/css/index.css in fe03d28

@willbarton willbarton merged commit 1c8159c into main Jan 12, 2023
@willbarton willbarton deleted the wag4-support branch January 12, 2023 14:13
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