kopia lustrzana https://github.com/wagtail/wagtail
Remove shared admin imports from `_editor_js.html` & remove unnecessary usage
- Fixes #2936 - Deprecate the usage of _editor_js.htmlpull/12993/merge
rodzic
97975b5293
commit
9f04de83d5
|
@ -222,6 +222,15 @@ class WagtailAdminPageForm(WagtailAdminModelForm):
|
|||
|
||||
return cleaned_data
|
||||
|
||||
@property
|
||||
def media(self):
|
||||
media = super().media
|
||||
if self.show_comments_toggle:
|
||||
media += forms.Media(
|
||||
js=["wagtailadmin/js/comments.js"],
|
||||
)
|
||||
return media
|
||||
|
||||
|
||||
class MoveForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<script src="{% versioned_static 'wagtailadmin/js/telepath/telepath.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/sidebar.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/modal-workflow.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/privacy-switch.js' %}"></script>
|
||||
|
||||
{% hook_output 'insert_global_admin_js' %}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
{% load wagtailadmin_tags %}
|
||||
|
||||
{% comment %}
|
||||
JavaScript declarations to be included on the 'create page' and 'edit page' views
|
||||
DEPRECATED: Remove this template in a future release and replace with the direct hook_output template tag, customizations should use the hook only.
|
||||
Do not add any further standalone script imports here, this template will be deprecated in a future release.
|
||||
{% endcomment %}
|
||||
|
||||
<script src="{% versioned_static 'wagtailadmin/js/comments.js' %}"></script>
|
||||
<script src="{% versioned_static 'wagtailadmin/js/privacy-switch.js' %}"></script>
|
||||
{% hook_output 'insert_editor_js' %}
|
||||
|
|
|
@ -63,6 +63,5 @@
|
|||
|
||||
{% block extra_js %}
|
||||
{{ block.super }}
|
||||
{% include "wagtailadmin/pages/_editor_js.html" %}
|
||||
{{ form.media.js }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
{% block extra_js %}
|
||||
{{ block.super }}
|
||||
{% include "wagtailadmin/pages/_editor_js.html" %}
|
||||
{{ move_form.media.js }}
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -1778,6 +1778,15 @@ class TestCommentPanel(WagtailTestUtils, TestCase):
|
|||
for panel in expand_panel_list(Page, Page.settings_panels)
|
||||
)
|
||||
)
|
||||
|
||||
self.login()
|
||||
response = self.client.get(reverse("wagtailadmin_pages:edit", args=[3]))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
soup = self.get_soup(response.content)
|
||||
scripts = soup.select("script[src='/static/wagtailadmin/js/comments.js']")
|
||||
self.assertEqual(len(scripts), 0)
|
||||
|
||||
form_class = Page.get_edit_handler().get_form_class()
|
||||
form = form_class()
|
||||
self.assertFalse(form.show_comments_toggle)
|
||||
|
@ -1792,6 +1801,15 @@ class TestCommentPanel(WagtailTestUtils, TestCase):
|
|||
for panel in expand_panel_list(Page, Page.settings_panels)
|
||||
)
|
||||
)
|
||||
|
||||
self.login()
|
||||
response = self.client.get(reverse("wagtailadmin_pages:edit", args=[3]))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
soup = self.get_soup(response.content)
|
||||
scripts = soup.select("script[src='/static/wagtailadmin/js/comments.js']")
|
||||
self.assertEqual(len(scripts), 1)
|
||||
|
||||
form_class = Page.get_edit_handler().get_form_class()
|
||||
form = form_class()
|
||||
self.assertTrue(form.show_comments_toggle)
|
||||
|
|
|
@ -2,6 +2,7 @@ from django.contrib.auth.models import Group
|
|||
from django.test import TestCase, override_settings
|
||||
from django.urls import reverse
|
||||
|
||||
from wagtail.admin.staticfiles import versioned_static
|
||||
from wagtail.models import Page, PageViewRestriction
|
||||
from wagtail.test.testapp.models import SimplePage
|
||||
from wagtail.test.utils import WagtailTestUtils
|
||||
|
@ -504,9 +505,13 @@ class TestPrivacyIndicators(WagtailTestUtils, TestCase):
|
|||
|
||||
soup = self.get_soup(response.content)
|
||||
|
||||
privacy_switch_js = versioned_static("wagtailadmin/js/privacy-switch.js")
|
||||
|
||||
public_link = soup.select_one('[data-w-zone-switch-key-value="isPublic"]')
|
||||
private_link = soup.select_one('[data-w-zone-switch-key-value="!isPublic"]')
|
||||
scripts = soup.select(f"script[src='{privacy_switch_js}']")
|
||||
|
||||
self.assertEqual(len(scripts), 1)
|
||||
# Check the privacy indicator is public
|
||||
self.assertEqual(public_link["class"], ["page-status-tag"])
|
||||
|
||||
|
@ -525,8 +530,13 @@ class TestPrivacyIndicators(WagtailTestUtils, TestCase):
|
|||
|
||||
soup = self.get_soup(response.content)
|
||||
|
||||
privacy_switch_js = versioned_static("wagtailadmin/js/privacy-switch.js")
|
||||
|
||||
public_link = soup.select_one('[data-w-zone-switch-key-value="isPublic"]')
|
||||
private_link = soup.select_one('[data-w-zone-switch-key-value="!isPublic"]')
|
||||
scripts = soup.select(f"script[src='{privacy_switch_js}']")
|
||||
|
||||
self.assertEqual(len(scripts), 1)
|
||||
|
||||
# Check the privacy indicator is private
|
||||
self.assertEqual(private_link["class"], ["page-status-tag"])
|
||||
|
|
Ładowanie…
Reference in New Issue