0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-25 13:10:14 +01:00
Commit Graph

17892 Commits

Author SHA1 Message Date
Sage Abdullah
e6bcfb710b Remove focus-visible fallback in preview panel code
We're dropping support for Safari 15 soon
2024-09-19 08:22:54 +10:00
Sage Abdullah
8d6d772da0 Final clean up of PreviewController and usage
Move all bind() to connect()

Add renderUrl value to use different URLs for sending vs rendering preview data

Add docstrings for PreviewController properties

Rename cleared property to ready and dispatch w-preview:ready

Add events to PreviewController update lifecycle

Use zero interval delay to disable preview auto update

Rearrange PreviewController methods to better follow the update flow

Ensure only one preview iframe has the w-preview-iframe ID at a given time

This doesn't really affect how it functions, but it's semantically more correct

Ensure runContentChecks function does not crash in tests

Only clear stale data if there is a valid stale preview available

Fix preview on Firefox by not removing the only iframe

Reorder targets and values alphabetically and add JSDoc for events

Introduce w-preview__proxy class for invisible elements in preview panel
2024-09-19 08:22:54 +10:00
Sage Abdullah
054e72b4c2 Setup main PreviewController unit tests
Test loading the last device size from localStorage

Ensure selected device size class is applied on connect

Add test for using ResizeObserver in PreviewController

Add tests for default PreviewController behaviour

Add test for opening preview in a new tab

Add test for handling a request error when opening preview in a new tab

Add test for showing the spinner when loading the preview

Add test for enforcing rendered preview width when there are errors

Split PreviewController tests into separate describe blocks

Use fake timers for all PreviewController tests

Add more detailed assertions in initializeOpenedPanel

Add assertions for setTimeout in PreviewController test

Add test for auto-update cycle

Add test for disabling auto update on panel close

Add tests for manually updating the preview

Add tests for switching preview modes

Only add the mode select element for these tests, to ensure that the
preview panel works even without it (e.g. for models that only define a
single preview mode)

Add tests for PreviewController.disconnect and for requiring the url value

Add test for assuming the first size input is the default

Add ResizeObserver test for preview controller

Reuse url variable in PreviewController tests
2024-09-19 08:22:54 +10:00
Sage Abdullah
0b14ae31dc Add block markers to preview.html to ease customisability
This allows developers to more easily customise the panel, e.g. customising the device sizes
2024-09-19 08:22:54 +10:00
Sage Abdullah
db4e86a2c1 Rename preview-panel class to w-preview 2024-09-19 08:22:54 +10:00
Sage Abdullah
55d57be7c5 Initial migration of preview panel to Stimulus PreviewController
Initialise preview panel as a Stimulus PreviewController

Fix TypeScript issues in PreviewController

Use Stimulus targets for preview device size inputs

Use Stimulus target for preview panel new tab button

Use Stimulus target for preview panel loading spinner

Use Stimulus target for preview panel refresh button

Use Stimulus target for preview panel mode select

Use Stimulus target for preview panel iframe

Also rename the id to w-preview-iframe to follow our new conventions for
singleton elements

Rely on Stimulus to replace the iframe target

Because we copy all the attributes from the old iframe to the new one,
this means that the new iframe will also become a target. When we remove
the old iframe, the target is disconnected, and subsequent references to
this.iframeTarget should point to the new one.

Access the preview panel's parent side panel element via this.element.parentElement

Bind preview device size inputs using Stimulus data-action

Extract PreviewController.observePanelSize() method

Extract PreviewController.restoreLastSavedPreferences() method

Use Stimulus value for preview panel url

Use Stimulus value for preview panel pending update state

Move edit form and spinner timeout references into instance variables

Extract PreviewController.finishUpdate() method

Extract PreviewController.reloadIframe() method

Extract PreviewController.clearPreviewData() and setPreviewData() methods

Replace preview panel refresh button target with data-action

Extract openPreviewInNewTab method and use it via data-action

Do not close the preview tab if the data is not valid

Use Stimulus values for preview panel auto update config

Extract PreviewController.initAutoUpdate() method

Extract handlePreviewModeChange method and use it via data-action

Use Stimulus classes for preview panel unavailable and has-errors CSS classes

Use Stimulus class for preview panel selected input size

This removes the reliance of having a predefined set of classes for each
device name, making it easier to add support for custom sizes later.

The outline styles have also been updated to make use of focus-visible
when available.

Use hidden attribute for hiding preview panel spinner

Replace PreviewController isUpdating value with an updatePromise instance variable

Extract PreviewController.hasChanges() method

Extract PreviewController.checkAndUpdatePreview() method

Add default values for PreviewController values

Use ProgressController outlet for preview panel refresh button

This allows the use of the button-longrunning handling for the loading state.

Also, turn the button into an icon-only button as there might not be enough space when the panel is resized to the smallest size

Use cloneNode() instead of manually copying the attributes

Extract PreviewController.replaceIframe() and use it as the iframe's action

Extract PreviewController.sidePanelContainer instance attribute

Extract PreviewController.checksSidePanel instance attribute

Extract PreviewController.updateInterval instance attribute

Clean up PreviewController event listeners on disconnect

Extract preview panel device localStorage key into PreviewController Stimulus value

Extract preview panel's width CSS property names into Stimulus values

Disconnect preview panel ResizeObserver on controller disconnect

Use an instance variable for tracking preview availability
2024-09-19 08:22:54 +10:00
Sage Abdullah
5aa0dde2a4 Move preview-panel.js to PreviewController.ts 2024-09-19 08:22:54 +10:00
Sage Abdullah
a5b42936ec Extract setOptionalInterval util from SessionController 2024-09-19 08:22:54 +10:00
Sage Abdullah
7b67723da9 Fix error if the preview iframe does not have the userbar loaded 2024-09-19 08:22:54 +10:00
Sage Abdullah
014ffb5ce9 Ensure the side panel's show event is dispatched after any hide events
If the event is dispatched in the loop, then the show event may be
dispatched before the hide event is dispatched. For example, if you're
switching from the checks panel to the preview panel, as the preview
panel is ordered before the checks panel in the DOM.

This could cause an issue with the preview panel code, where we listen
for the show event to activate the auto update, and listen to the hide
event to deactivate it. We're listening to both the preview and checks
side panels.

Without this fix, the preview auto-update will get deactivated upon
switching from the checks panel to the preview panel, as the hide event
is dispatched after the show event.
2024-09-19 08:22:54 +10:00
Sage Abdullah
30f1115353 Fix debounce() return type to follow original function
Without typing Promise and Promise.resolve with R, it defaults to
unknown, so the R generic type can't be used.

Also, the debounced function's args should take the generic A parameter
instead of redefining it as any[].
2024-09-19 08:22:54 +10:00
LB Johnston
6bb0c7597f Docs - Hacktoberfest - Remove reference to the t-shirt
There is no longer a t-shirt reward as of 2023
https://hacktoberfest.com/participation/#faq
2024-09-19 08:03:36 +10:00
sanjeevholla26
aa3be4b888 [UI]: Changed class from warning to failure for confirm delete message
Ensure the contrast of the message is suitable
Fixes #12232
2024-09-18 09:48:41 +10:00
Matt Westcott
9c153d27ea Release note for #12327 2024-09-17 18:12:50 +01:00
Matt Westcott
a26bd1d6aa Omit messages about root / unroutable pages when searching or filtering
In this view the results include descendant pages, for which the information is not necessarily accurate.
2024-09-17 18:11:25 +01:00
Matt Westcott
42aa0c027e Move messages about root / unroutable parent pages to a new explorable_index_results template 2024-09-17 18:11:25 +01:00
Matt Westcott
baa2e15d82 Update Atif Khan's name in release notes 2024-09-17 17:23:31 +01:00
Sage Abdullah
59689600e9 Fix missing JS in pages/explorable_index.html template 2024-09-17 16:12:58 +01:00
Matt Westcott
66ff3c52cc Use non-tracked links in Divio hosting details
As per https://github.com/wagtail/wagtail/pull/12250#discussion_r1762523573
2024-09-17 14:37:08 +01:00
Sage Abdullah
65efe1f160 Ensure form pages listing tests have consistent ordering 2024-09-17 14:12:50 +01:00
Sage Abdullah
621998f233 Use lru_cache for get_form_types caching 2024-09-17 14:12:50 +01:00
Atif2077
96f8324458 Modified slugify/urlify to according to django's slug validator (#12319)
Fixes #12300
2024-09-17 13:14:51 +01:00
Sage Abdullah
6affa04d32 Add search and filters from PageListingMixin to form pages listing (#12324) 2024-09-17 09:58:12 +01:00
Matt Westcott
a7ad9ba5f1 Release note for #12275 2024-09-16 20:27:12 +01:00
Sage Abdullah
dfc4a5b2ed Enable breadcrumbs in images URL Generator view 2024-09-16 20:26:14 +01:00
Sage Abdullah
4245d7f619 Use grid and simplify the template for image edit view 2024-09-16 20:26:14 +01:00
Sage Abdullah
d3d3299c22 Refactor images edit view to use generic EditView 2024-09-16 20:26:14 +01:00
Sage Abdullah
ed2f0c4720 Refactor images single upload view to use generic CreateView 2024-09-16 20:26:14 +01:00
Sage Abdullah
89bd68b0dc Enable breadcrumbs in images multiple upload view 2024-09-16 20:26:14 +01:00
Sage Abdullah
3b07d32fb8 Add missing index_url_name and edit_url_name in images UsageView
And reduce 1 query by using select_related for uploaded_by_user.
2024-09-16 20:26:14 +01:00
Matt Westcott
63fb2b123d Release note for #12248 2024-09-16 14:23:59 +01:00
Sage Abdullah
c50f7d1918 Remove .filter() from PageListingMixin.annotate_queryset() 2024-09-16 14:23:06 +01:00
Sage Abdullah
1449a64329 Do not define permission_policy/any_permission_required in PageListingMixin
Require the concrete views to define them instead, as PageListingMixin
should not make any assumptions how the view should behave.
2024-09-16 14:23:06 +01:00
Sage Abdullah
e46f6920b6 Make PageListingMixin.annotate_queryset public and use page_permission_policy directly 2024-09-16 14:23:06 +01:00
Sage Abdullah
d8bdc900c8 Filter PageListingMixin.columns by name instead of using pop() by index 2024-09-16 14:23:06 +01:00
Sage Abdullah
b1a1989899 Use content type cache in page search view 2024-09-16 14:23:06 +01:00
Sage Abdullah
f45b0a4ad5 Show locale labels on treeless page listings 2024-09-16 14:23:06 +01:00
Sage Abdullah
ef2dad9dd9 Add parent page query optimisation in PageListingMixin if ParentPageColumn is used 2024-09-16 14:23:06 +01:00
Sage Abdullah
cc56f0b6ba Use PageListingMixin for page SearchView 2024-09-16 14:23:06 +01:00
Sage Abdullah
2ad8c7286e Use PageListingMixin in page ContentTypeUseView 2024-09-16 14:23:06 +01:00
Sage Abdullah
ed45350e8c Reimplement workflow usage view with PageListingMixin and BaseListingView 2024-09-16 14:23:06 +01:00
Sage Abdullah
028fabbd6a Add parent page column to PageListingMixin.columns
In a treeless page listing, it can be quite useful to know the parent page
of each page in the listing.
2024-09-16 14:23:06 +01:00
Sage Abdullah
08cb3a88a9 Extract PageListingMixin from page IndexView 2024-09-16 14:23:06 +01:00
Sage Abdullah
639586423f Rename ExplorablePageFilterSet to GenericPageFilterSet
The main difference is that it has the content_type filter, which means
it's intended for listings that show the generic base Page type.
2024-09-16 14:23:06 +01:00
Matt Westcott
84ab70d3a1 Release note for #12272 2024-09-16 09:27:23 +01:00
Sage Abdullah
f99a66a709 Use grid and simplify the template for documents edit view 2024-09-16 09:24:09 +01:00
Sage Abdullah
08fd30cb65 Add fields block to generic/form.html template for easier customisation 2024-09-16 09:24:09 +01:00
Sage Abdullah
054dea5302 Refactor documents edit view to use generic EditView 2024-09-16 09:24:09 +01:00
Sage Abdullah
a28cb84b80 Refactor documents single upload view to use generic CreateView
This view isn't actually used anymore and is only accessible via direct
URL. We might want to deprecate them instead.
2024-09-16 09:24:09 +01:00
Sage Abdullah
36fc9615ae Enable breadcrumbs in documents multiple upload view 2024-09-16 09:24:09 +01:00