Closed AlexBueckig closed 2 years ago
Thanks @AlexBueckig I merge this ASAP.
Just realized, that the SvgChooserPanel looks a bit off in 3.0. This is how it looks in 2.16: and this is how it looks in 3.0 (just a dropdown instead if a widget)
The issue seems to be related to the Javascript and the UI-changes that happened in Wagtail 3.0. I will investigate further tomorrow after work. Nonetheless, the Dropdown seems to be working as expected.
@Aleksi44 Okay, I did some digging and found the reason. Most of the panels have been reworked so that you only need to use a FieldPanel. The easiest way to fix the panel is to actually use wagtails FieldPanel with a custom widget like this directly:
content_panels = Page.content_panels + [
FieldPanel('logo', widget=AdminSvgChooser),
StreamFieldPanel('body'),
]
Wagtail 2 still supports the old widgets, so keeping the SvgChooserPanel as is make sense in wagtail 2. It'll still look like this for wagtail 2:
content_panels = Page.content_panels + [
SvgChooserPanel('logo'),
StreamFieldPanel('body'),
]
Do you have a preferred take on this case? Theoretically it's possible to just update the docs for usage with Wagtail 3 and deprecate the SvgChooserPanel and make clear that this way only works with Wagtail 2. Afaik the old deprecated panels will be removed in Wagtail 5.
Edit: I fiddled around a bit and have this option for the SvgChooserPanel. Not sure if this is the optimal pythonic way but here is my take:
try:
from wagtail.admin.panels import FieldPanel
from wagtailsvg.widgets import AdminSvgChooser
class SvgChooserPanel(FieldPanel):
def __init__(self, field_name, disable_comments=None, permission=None, **kwargs):
super().__init__(field_name, **kwargs)
self.widget = AdminSvgChooser
self.disable_comments = disable_comments
self.permission = permission
except ImportError:
<old existing code here>
This would make it completely backwards compatible.
Implemented upgrade steps described here: https://docs.wagtail.org/en/stable/releases/3.0.html#upgrade-considerations-deprecation-of-old-functionality
The update checker also told me that the 0001_initial.py has one change needed to be done. I did not touch the migration yet since I'm uncertain what's the best way to fix this complaint.
The package still seems to work fine with wagtail 3 without the update since the old paths still re-import all the classes, panels, etc. from the new paths. So I guess there is no need to rush this update if you want to test it first thouroughly.