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

feat: Use same icons in page tree state indicators and Manage verisons #302

Merged
merged 51 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fbe1bd8
Add: Ability to patch new page tree indicator drop down menus
fsbraun Oct 29, 2022
6124d45
Fix: isort, flake8
fsbraun Oct 29, 2022
5689c4c
adj toolbar tests to reflect unified spelling
fsbraun Oct 29, 2022
d3bafb5
Fix: Catch cms.pagetree.js` ajax posts
fsbraun Oct 29, 2022
41977d0
Add: Indicator status draft
fsbraun Oct 30, 2022
7155c09
Fix: Only offer to copy plugins from languages that allow for that
fsbraun Oct 30, 2022
85a0504
Fix: Edit button only if it is needed
fsbraun Oct 30, 2022
500f79f
Add: changelog entry
fsbraun Oct 30, 2022
f7cf4d7
Fix: tests
fsbraun Oct 30, 2022
703c4bf
Fix: Remove jsonresponse
fsbraun Oct 31, 2022
0b326d2
udo admin changes
fsbraun Oct 31, 2022
15e2d37
Refactor template tag patch
fsbraun Oct 31, 2022
a55d978
Add: tests for publishand revert button
fsbraun Oct 31, 2022
9b8f73e
Add: tests
fsbraun Oct 31, 2022
2613f1e
fix: isort
fsbraun Oct 31, 2022
7508ecb
Fix: spelling
fsbraun Nov 2, 2022
f90e7f8
Fix isort
fsbraun Nov 2, 2022
aa2efe5
Add: test w/ archived versions
fsbraun Nov 2, 2022
0bf013c
Fix: Use logic from Contitions() to not repeat oneself
fsbraun Nov 2, 2022
9d41f94
flake8
fsbraun Nov 2, 2022
bee5acd
Add: # pragma: no cover to cases without page content
fsbraun Nov 2, 2022
02552e8
Removed unused method add_revert_button
fsbraun Nov 2, 2022
9a01fc6
Fix: typo
fsbraun Nov 3, 2022
54bf047
Fix: Only offer view published if get_absolute_url returns non-empty…
fsbraun Nov 3, 2022
69c9167
Fix: ensure get_absolute_url is s property of versionable object
fsbraun Nov 3, 2022
a268ef3
Fix: Sync indicator items and versioning admin actions according to …
fsbraun Nov 22, 2022
6307e1d
Refactor: No patching
fsbraun Nov 24, 2022
de6a135
Fix: isort
fsbraun Nov 24, 2022
405ae39
Undo: Make version number column smaller
fsbraun Nov 27, 2022
b42087a
Merge branch 'master' into feat/stateIndicators
fsbraun Nov 28, 2022
da14fe0
Merge branch 'master' into feat/stateIndicators
fsbraun Nov 30, 2022
83e4580
Fix merge, isort
fsbraun Nov 30, 2022
a7103ea
FiX: remove revert from archive and add compare to published
fsbraun Dec 1, 2022
1702d55
feat: add configurable back button
fsbraun Dec 1, 2022
681e566
Fix linter problems
fsbraun Dec 3, 2022
f5d6fa4
Fix: order of compared versions in toolbar menu
fsbraun Dec 3, 2022
bfcb5d9
Fix: Add check for in navigation toggle
fsbraun Dec 3, 2022
1311e81
unify icons
fsbraun Dec 3, 2022
2528843
fix import
fsbraun Dec 4, 2022
4a029e2
add users to request in tests
fsbraun Dec 4, 2022
ed3e907
fix: no double edit option
fsbraun Dec 4, 2022
a8264f5
Use cms icons
fsbraun Dec 4, 2022
ca24a62
Add: css to mixin
fsbraun Dec 4, 2022
a642f9e
Fix: POST requests for changing actions
fsbraun Dec 4, 2022
c9efb77
Fix: ask before unpublishing/reverting/deleting
fsbraun Dec 4, 2022
6e4bed1
Remove unused templatetags from load
fsbraun Dec 4, 2022
cc37651
Merge branch 'master' into feat/state-indicators-cms-icons
fsbraun Dec 15, 2022
61a632f
Fix test requirements
fsbraun Dec 15, 2022
ca003fe
Use pagetree.css instead if base.css
fsbraun Dec 15, 2022
73a14b4
Fix keepsideframe
fsbraun Dec 15, 2022
c61f1e4
Remove unnecessary `static` template tags
fsbraun Dec 15, 2022
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
43 changes: 24 additions & 19 deletions djangocms_versioning/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from cms.models import PageContent
from cms.utils import get_language_from_request
from cms.utils.conf import get_cms_setting
from cms.utils.urlutils import add_url_parameters
from cms.utils.urlutils import add_url_parameters, static_with_version

from . import versionables
from .conf import USERNAME_FIELD
Expand Down Expand Up @@ -130,6 +130,7 @@ class Media:
js = ("admin/js/jquery.init.js", "djangocms_versioning/js/actions.js")
css = {
"all": (
static_with_version("cms/css/cms.pagetree.css"),
"djangocms_versioning/css/actions.css",
)
}
Expand Down Expand Up @@ -212,7 +213,7 @@ def list_actions(obj):

def _get_preview_link(self, obj, request, disabled=False):
"""
Return a user friendly button for previewing the content model
Return a user-friendly button for previewing the content model
:param obj: Instance of versioned content model
:param request: The request to admin menu
:param disabled: Should the link be marked disabled?
Expand All @@ -229,7 +230,7 @@ def _get_preview_link(self, obj, request, disabled=False):

def _get_edit_link(self, obj, request, disabled=False):
"""
Return a user friendly button for editing the content model
Return a user-friendly button for editing the content model
- mark disabled if user doesn't have permission
- hide completely if instance cannot be edited
:param obj: Instance of Versioned model
Expand All @@ -254,7 +255,7 @@ def _get_edit_link(self, obj, request, disabled=False):
)
return render_to_string(
"djangocms_versioning/admin/icons/edit_icon.html",
{"url": url, "disabled": disabled, "get": False},
{"url": url, "disabled": disabled, "get": False, "keepsideframe": False},
)

def _get_manage_versions_link(self, obj, request, disabled=False):
Expand Down Expand Up @@ -400,7 +401,10 @@ class VersionAdmin(admin.ModelAdmin):

class Media:
js = ("admin/js/jquery.init.js", "djangocms_versioning/js/actions.js", "djangocms_versioning/js/compare.js",)
css = {"all": ("djangocms_versioning/css/actions.css",)}
css = {"all": (
static_with_version("cms/css/cms.pagetree.css"),
"djangocms_versioning/css/actions.css",
)}

# register custom actions
actions = ["compare_versions"]
Expand Down Expand Up @@ -491,17 +495,17 @@ def _get_archive_link(self, obj, request, disabled=False):
),
args=(obj.pk,),
)
disabled = not obj.check_archive.as_bool(request.user)
disabled = not obj.can_be_archived()

return render_to_string(
"djangocms_versioning/admin/archive_icon.html",
{"archive_url": archive_url, "disabled": disabled},
"djangocms_versioning/admin/icons/archive_icon.html",
{"url": archive_url, "disabled": disabled},
)

def _get_publish_link(self, obj, request):
"""Helper function to get the html link to the publish action
"""
if not obj.can_be_published():
if not obj.check_publish.as_bool(request.user):
# Don't display the link if it can't be published
return ""
publish_url = reverse(
Expand All @@ -510,16 +514,17 @@ def _get_publish_link(self, obj, request):
),
args=(obj.pk,),
)
disabled = not obj.check_publish.as_bool(request.user)
disabled = not obj.can_be_published()

return render_to_string(
"djangocms_versioning/admin/publish_icon.html", {"publish_url": publish_url, "disabled": disabled}
"djangocms_versioning/admin/icons/publish_icon.html",
{"url": publish_url, "disabled": disabled, "get": False, "keepsideframe": False}
)

def _get_unpublish_link(self, obj, request, disabled=False):
"""Helper function to get the html link to the unpublish action
"""
if not obj.can_be_unpublished():
if not obj.check_unpublish.as_bool(request.user):
# Don't display the link if it can't be unpublished
return ""
unpublish_url = reverse(
Expand All @@ -528,11 +533,11 @@ def _get_unpublish_link(self, obj, request, disabled=False):
),
args=(obj.pk,),
)
disabled = not obj.check_unpublish.as_bool(request.user)
disabled = not obj.can_be_unpublished()

return render_to_string(
"djangocms_versioning/admin/unpublish_icon.html",
{"unpublish_url": unpublish_url, "disabled": disabled},
"djangocms_versioning/admin/icons/unpublish_icon.html",
{"url": unpublish_url, "disabled": disabled},
)

def _get_edit_link(self, obj, request, disabled=False):
Expand Down Expand Up @@ -589,8 +594,8 @@ def _get_revert_link(self, obj, request, disabled=False):
)

return render_to_string(
"djangocms_versioning/admin/revert_icon.html",
{"revert_url": revert_url, "disabled": disabled},
"djangocms_versioning/admin/icons/revert_icon.html",
{"url": revert_url, "disabled": disabled},
)

def _get_discard_link(self, obj, request, disabled=False):
Expand All @@ -608,8 +613,8 @@ def _get_discard_link(self, obj, request, disabled=False):
)

return render_to_string(
"djangocms_versioning/admin/discard_icon.html",
{"discard_url": discard_url, "disabled": disabled},
"djangocms_versioning/admin/icons/discard_icon.html",
{"url": discard_url, "disabled": disabled},
)

def get_state_actions(self):
Expand Down
18 changes: 12 additions & 6 deletions djangocms_versioning/static/djangocms_versioning/css/actions.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-------------------------------------
Classes for Action btn & Burger menu
Classes for Action btn & Burger menu
---------------------------------------*/

a.btn.cms-versioning-action-btn {
Expand All @@ -23,21 +23,27 @@ a.btn.cms-versioning-action-btn {
box-sizing: border-box;
cursor: pointer;
}

a.btn.cms-versioning-action-btn span
{
font-family: django-cms-iconfont;
font-size: 120%;
}

a.btn.cms-versioning-action-btn img {
width: 20px;
height: 20px;
}

a.btn.cms-versioning-action-btn.inactive {
opacity: 0.3;
filter: alpha(opacity=30);
a.btn.cms-versioning-action-btn.inactive:link,
a.btn.cms-versioning-action-btn.inactive:visited {
color: var(--dca-gray-lighter, var(--border-color, #ccc)) !important;
}


/* disable clicking for inactive buttons */
.btn.cms-versioning-action-btn.inactive {
pointer-events: none;
background-color: #e1e1e1 !important;
}

.btn.cms-versioning-action-btn.inactive img {
Expand All @@ -53,7 +59,7 @@ a.btn.cms-versioning-action-btn img {


/*-------------------------------------
This governs the drop-down behaviour
This governs the drop-down behaviour
extending the pagetree classes provided by CMS
---------------------------------------*/

Expand Down
10 changes: 5 additions & 5 deletions djangocms_versioning/static/djangocms_versioning/js/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
});
};

let toggleBurgerMenu = function toggleBurgerMenu(burgerMenuAnchor, optionsContainer) {
let toggleBurgerMenu = function toggleBurgerMenu(burgerMenuAnchor, optionsContainer) {
let bm = $(burgerMenuAnchor);
let op = $(optionsContainer);
let closed = bm.hasClass('closed');
Expand All @@ -176,16 +176,16 @@
op.css('top', pos.top);
};

let closeBurgerMenu = function closeBurgerMenu() {
let closeBurgerMenu = function closeBurgerMenu() {
$('.cms-actions-dropdown-menu').removeClass('open');
$('.cms-actions-dropdown-menu').addClass('closed');
$('.cms-versioning-action-btn').removeClass('open');
$('.cms-versioning-action-btn').addClass('closed');
};
};

$('#result_list').find('tr').each(function (index, item) {
$('#result_list').find('tr').each(function (index, item) {
createBurgerMenu(item);
});
});

});

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "./base.html" %}
{% load i18n %}
{% block title %}{% translate 'Archive' %}{% endblock %}
{% block name %}archive{% endblock %}
{% block icon %}archive{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
{% spaceless %}
<a
title="{% block title %}{% endblock %}"
class="btn
{% if disabled %}
inactive
{% endif %}
cms-versioning-action-btn
cms-versioning-action-{% block name %}{% endblock %}
{% if get|default_if_none:True %} cms-form-get-method {% endif %}
{% if action|default_if_none:True %} js-versioning-action{% endif %}
{% if keepsideframe|default_if_none:True %}js-versioning-keep-sideframe {% else %}js-versioning-close-sideframe {% endif %}"
{% if not disabled %}
href="{{ url }}"
{% endif %}
>
<img src="{% block icon %}{% endblock %}">
<a class="btn{% if disabled %} inactive{% endif %}{% if get|default_if_none:True %} cms-form-get-method{% endif %} cms-versioning-action-btn cms-versioning-action-{% block name %}{% endblock %}{% if action|default_if_none:True %} js-versioning-action{% endif %}{% if keepsideframe|default_if_none:True %} js-versioning-keep-sideframe{% else %} js-versioning-close-sideframe{% endif %}"{% if not disabled %} href="{{ url }}"{% endif %} title="{% block title %}{% endblock %}">
<span class="cms-icon cms-icon-{% block icon %}{% endblock %}"></span>
</a>
{% endspaceless %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "./base.html" %}
{% load i18n %}
{% block title %}{% translate 'Discard' %}{% endblock %}
{% block name %}discard{% endblock %}
{% block icon %}bin{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "./base.html" %}
{% load static i18n %}
{% block title %}{% trans 'Edit' %}{% endblock %}
{% load i18n %}
{% block title %}{% translate 'Edit' %}{% endblock %}
{% block name %}edit{% endblock %}
{% block icon %}{% static 'djangocms_versioning/svg/edit.svg' %}{% endblock %}
{% block icon %}pencil{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "./base.html" %}
{% load static i18n %}
{% block title %}{% trans 'Manage versions' %}{% endblock %}
{% load i18n %}
{% block title %}{% translate 'Manage versions' %}{% endblock %}
{% block name %}manage-versions{% endblock %}
{% block icon %}{% static 'djangocms_versioning/svg/manage_versions.svg' %}{% endblock %}
fsbraun marked this conversation as resolved.
Show resolved Hide resolved
{% block icon %}copy{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "./base.html" %}
{% load static i18n %}
{% block title %}{% trans 'Preview' %}{% endblock %}
{% load i18n %}
{% block title %}{% translate 'Preview' %}{% endblock %}
{% block name %}preview{% endblock %}
{% block icon %}{% static 'djangocms_versioning/svg/preview.svg' %}{% endblock %}
fsbraun marked this conversation as resolved.
Show resolved Hide resolved
{% block icon %}eye{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "./base.html" %}
{% load i18n %}
{% block title %}{% translate 'Publish' %}{% endblock %}
{% block name %}edit{% endblock %}
{% block icon %}publish{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "./base.html" %}
{% load i18n %}
{% block title %}{% translate 'Revert' %}{% endblock %}
{% block name %}revert{% endblock %}
{% block icon %}undo{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "./base.html" %}
{% load i18n %}
{% block title %}{% translate 'Unpublish' %}{% endblock %}
{% block name %}unpublish{% endblock %}
{% block icon %}unpublish{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "./base.html" %}
{% load i18n %}
{% block title %}{% translate 'View on site' %}{% endblock %}
{% block name %}preview{% endblock %}
{% block icon %}eye{% endblock %}

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion tests/requirements/requirements_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ mysqlclient==2.0.3
psycopg2

# Unreleased django-cms 4.0 compatible packages
https://github.com/fsbraun/django-cms/tarball/fix/publish-state#egg=django-cms
https://github.com/django-cms/django-cms/tarball/develop-4#egg=django-cms
https://github.com/divio/djangocms-text-ckeditor/tarball/support/4.0.x#egg=djangocms-text-ckeditor
14 changes: 11 additions & 3 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,10 @@ def test_revert_action_link_enable_state(self):
self.versionable.version_model_proxy, "revert", version.pk
)
expected_enabled_state = (
'<a class="btn cms-form-get-method cms-versioning-action-btn js-versioning-action '
'<a class="btn cms-form-get-method '
'cms-versioning-action-btn '
'cms-versioning-action-revert '
'js-versioning-action '
'js-versioning-keep-sideframe" '
'href="%s" '
'title="Revert">'
Expand Down Expand Up @@ -545,7 +548,10 @@ def test_discard_action_link_enabled_state(self):
actual_enabled_control = self.version_admin._get_discard_link(version, request)

expected_enabled_state = (
'<a class="btn cms-form-get-method cms-versioning-action-btn js-versioning-action '
'<a class="btn cms-form-get-method '
'cms-versioning-action-btn '
'cms-versioning-action-discard '
'js-versioning-action '
'js-versioning-keep-sideframe" '
'href="%s" '
'title="Discard">'
Expand Down Expand Up @@ -608,7 +614,9 @@ def test_revert_action_link_for_archive_state(self):
self.versionable.version_model_proxy, "revert", archive_version.pk
)
expected_disabled_control = (
'<a class="btn cms-form-get-method cms-versioning-action-btn js-versioning-action '
'<a class="btn cms-form-get-method cms-versioning-action-btn '
'cms-versioning-action-revert '
'js-versioning-action '
'js-versioning-keep-sideframe" '
'href="%s" '
'title="Revert">'
Expand Down