Skip to content
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

fix: Avoid unnecessary loading of actions.js asset into the toolbar #403

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions djangocms_versioning/cms_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@


class VersioningToolbar(PlaceholderToolbar):
class Media:
js = ("cms/js/admin/actions.js",)

def _get_versionable(self):
"""Helper method to get the versionable for the content type
of the version
Expand Down Expand Up @@ -79,7 +76,7 @@ def _add_publish_button(self):
_("Publish"),
url=publish_url,
disabled=False,
extra_classes=["cms-btn-action", "js-action", "cms-form-post-method", "cms-versioning-js-publish-btn"],
extra_classes=["cms-btn-action", "cms-form-post-method", "cms-versioning-js-publish-btn"],
)
self.toolbar.add_item(item)

Expand Down Expand Up @@ -115,7 +112,7 @@ def _add_edit_button(self, disabled=False):
_("Edit") if draft_exists else _("New Draft"),
url=edit_url,
disabled=disabled,
extra_classes=["cms-btn-action", "js-action", "cms-form-post-method", "cms-versioning-js-edit-btn"],
extra_classes=["cms-btn-action", "cms-form-post-method", "cms-versioning-js-edit-btn"],
)
self.toolbar.add_item(item)

Expand All @@ -135,7 +132,6 @@ def _add_unlock_button(self):
if can_unlock:
extra_classes = [
"cms-btn-action",
"js-action",
"cms-form-post-method",
"cms-versioning-js-unlock-btn",
]
Expand Down Expand Up @@ -316,7 +312,7 @@ def override_language_menu(self):
# Only override the menu if it exists and a page can be found
language_menu = self.toolbar.get_menu(LANGUAGE_MENU_IDENTIFIER, _("Language"))
if settings.USE_I18N and language_menu and self.page:
# remove_item uses `items` attribute so we have to copy object
# remove_item uses `items` attribute, so we have to copy object
for _item in copy(language_menu.items):
language_menu.remove_item(item=_item)

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import djangocms_versioning

INSTALL_REQUIREMENTS = [
"Django>=1.11",
"django-cms",
"Django>=3.2",
"django-cms>=4.1.1",
"django-fsm"
]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_locking.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ def test_enable_edit_button_when_content_is_locked(self):
self.assertFalse(edit_button.disabled)
self.assertListEqual(
edit_button.extra_classes,
["cms-btn-action", "js-action", "cms-form-post-method", "cms-versioning-js-edit-btn"]
["cms-btn-action", "cms-form-post-method", "cms-versioning-js-edit-btn"]
)

def test_lock_message_when_content_is_locked(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_publish_in_toolbar_in_edit_mode(self):
self.assertFalse(publish_button.disabled)
self.assertListEqual(
publish_button.extra_classes,
["cms-btn-action", "js-action", "cms-form-post-method", "cms-versioning-js-publish-btn"],
["cms-btn-action", "cms-form-post-method", "cms-versioning-js-publish-btn"],
)

def test_revert_in_toolbar_in_preview_mode(self):
Expand Down Expand Up @@ -150,7 +150,7 @@ def test_edit_in_toolbar_in_preview_mode(self):
self.assertFalse(edit_button.disabled)
self.assertListEqual(
edit_button.extra_classes,
["cms-btn-action", "js-action", "cms-form-post-method", "cms-versioning-js-edit-btn"]
["cms-btn-action", "cms-form-post-method", "cms-versioning-js-edit-btn"]
)

def test_edit_not_in_toolbar_in_edit_mode(self):
Expand Down
Loading