Skip to content
Closed
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
1 change: 1 addition & 0 deletions news/+icon.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade step to set the discussion moderation icon to be bootstrap based icon @erral
14 changes: 14 additions & 0 deletions src/plone/app/upgrade/v62/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,18 @@
/>
</gs:upgradeSteps>

<gs:upgradeSteps
profile="Products.CMFPlone:plone"
source="6204"
destination="6205"
>

<!-- Plone 6.2.2 -->
<gs:upgradeStep
title="Use Bootstrap style icon for discussion moderation action."
handler=".final.manage_comments_icon"
/>

</gs:upgradeSteps>

</configure>
41 changes: 41 additions & 0 deletions src/plone/app/upgrade/v62/final.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from plone.base.utils import get_installer
from Products.CMFCore.utils import getToolByName

import logging

logger = logging.getLogger(__name__)


def manage_comments_icon(context):
"""if plone.app.discussion is installed, set the manage-comments action icon
expression from its default to the bootstrap based new-style icons
"""

installer = get_installer(context)
if not installer.is_product_installed("plone.app.discussion"):
logger.info("plone.app.discussion is not installed. Nothing is done.")
return

portal_actions = getToolByName(context, "portal_actions")
user_actions = getattr(portal_actions, "user", None)
if user_actions is None:
logger.info("There are no user actions. Nothing is done.")
return

review_comments_action = getattr(user_actions, "review-comments", None)
if review_comments_action is None:
logger.info("There is no manage comments action. Nothing is done.")
return

# Check whether the action keeps its original state
if (
review_comments_action.icon_expr
!= "string:${globals_view/navigationRootUrl}/discussionitem_icon.png"
):
logger.info(
"Manage comments action icon was modified by the user. Nothing is done."
)
return

review_comments_action.icon_expr = "string:chat"
logger.info("Manage comments action icon modified")