-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Split out code from telepath/widgets.js #13222
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
Open
gasman
wants to merge
15
commits into
wagtail:main
Choose a base branch
from
gasman:cleanup/telepath-widgets
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+1,828
−1,744
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It references wagtailadmin/js/telepath/telepath.js and wagtail.admin.staticfiles, and we don't want wagtail core to depend on code in wagtail.admin. Also, we don't want to encourage use of this registry outside of admin views, as adapters registered here are likely to depend on admin-specific JS includes.
…er it in entrypoints/admin/draftail.js The definition of DraftailRichTextArea needs to be in index.js because we want to export it as part of the top-level `draftail` API (rather than having to import a submodule of components/Draftail when registering it with telepath), but it also depends on initEditor.
…nts/Widget and decouple from telepath
…nstead of widgets.js This puts them in the same file as the window.init* functions that they depend on, so that we aren't reliant on getting the import order of these two files correct.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Preliminary cleanup as part of the work for using Telepath to manage overall edit form state.
entrypoints/admin/telepath/widgets.js has accumulated a lot of widget implementation code (including a large chunk relating to Draftail), probably because of the perception that these are conceptually "within" Telepath, rather than JS classes with a meaningful API in their own right (with Telepath just being the mechanism to map these to Python-side objects).
The goal here is to move these class definitions into
client/src/components
, and handle the Telepath registration in the most appropriate top-level entrypoint: admin/draftail.js (for DraftailRichTextArea), admin/date-time-chooser.js (for AdminDateInput etc) or admin/telepath/widgets.js (for the 'regular' widgets).This change requires us to be more rigorous about import order - previously the
DraftailRichTextArea
only referencedwindow.draftail
within its method code, meaning that it could be defined before or after Draftail was loaded, but now we definitely require telepath to come first. To achieve this, we make it explicit that the telepath registry included with Wagtail is only valid for use within the Wagtail admin - where we load it early in the global includes - and move thewagtail.telepath
andwagtail.widget_adapters
modules towagtail.admin.telepath
to formalise this.(Incidentally, it would make sense to reshuffle our chooser widgets to follow the same pattern and have the Telepath registration in chooser-widget.js, rather than having separate chooser-widget-telepath.js and page-chooser-telepath.js endpoints. But at that point I'd be getting completely derailed from working on the form management stuff :-) )