-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support Wagtail 6 + add sharing link to Action Menu + more #3
base: main
Are you sure you want to change the base?
Conversation
This commit mirrors the current functionality for Wagtail 5 in Wagtail 6 by creating a Stimulus JS controller and hooking it into Wagtail in a similar way as for Wagtail 5. For the page history view, the HTML templating is different, so the previous approach overrode wagtailadmin/pages/revisions/_actions.html to slot in custom markup that the JS could hook into. For Wagtail 6 we do something similar, extending wagtailadmin/generic/history/action_cell.html to slot in a bit of custom markup. For snippet-list view, we update the HTML output for the share_url method to hook in the Stimulus controller used above. The JS in the Stimulus controller is deliberately very similar to the original JS. I wondered about refactoring out the main duplicated code (the main function which triggers the creation of new links via a POST to the backend, and the function which upgrades the View button on the list view of existing sharing links to be a clipboard link). However, for now - and with a view potentially to deprecating pre-Wagtail 6 behaviour - I've gone with some repetition rather than DRY code. Note that we don't load both JS files into the browser - we only load the appropriate one based on the version of Wagtail in use
...if there is an unpublished draft that can be shared
…uring link creation
Bit of a nitpick here, I know - sorry!
incl datetime_now -> timezone_now to avoid mis-assumption about which library it's from
Brings coverage up to 98%, and effectively all code that needs coverage
…was coming back as a naive datetime So we patch it in the tests and warn about it
Note the tolerance of a should-not-build version python3.12-django3.2-wagtail6.1 - may be there are better ways around that
No need to have three things going when ruff does the lot
… expiry timestamps Note the addition to the README, requiring the use of settings.USE_TZ=True
Add Wagtail 6 support + extra way to create a sharing link
…as a maintainer contact
Hotfix: page creation was broken by addition to Action Menu 🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @stevejalim I have just one outstanding question regarding the naming of the settings. Thanks for all the hard work, the tests are really thorough
Amend settings naming and update docs
…t more reusable from Python
…ython-api Move the link generation out of the view, to make it more reusable from Python
Note: our fork of the project is moving on beyond what the description covers here, so please check later commits carefully before merging |
This avoids the downside of reusing links: you might get a link that will expire soon (or has expired but won't be marked as such until it's used)
…s generating a new one
Support custom max age + multiple links per Revision
This PR is based on our fork of the project and I'm very happy to offer our changes back upstream.
The changeset:
For more details, please see the PR on our side: mozmeao#1
Note that this hasn't been tested in production yet, so feel free to wait a few weeks before merging. Equally, if during review you spot something that could be done better, please feel free to mention it!