Repository: plone/Products.CMFPlone

Issue:
Allow to hide/show actions directly from the Actions control panel list
As @esteele mentionned in #1342



Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/controlpanel/browser/actions.py b/Products/CMFPlone/controlpanel/browser/actions.py
--- a/Products/CMFPlone/controlpanel/browser/actions.py
+++ b/Products/CMFPlone/controlpanel/browser/actions.py
@@ -41,6 +41,7 @@ def display(self):
                         'id': action.id,
                         'title': action.title,
                         'url': action.absolute_url(),
+                        'visible': action.visible,
                     })
             cat_infos['actions'] = action_list
             actions.append(cat_infos)
@@ -49,11 +50,21 @@ def display(self):
         return self.template()
 
     def __call__(self):
-        if self.request.get('deleteaction'):
-            action_id = self.request['deleteaction']
+        if self.request.get('delete'):
+            action_id = self.request['actionid']
             category = self.portal_actions[self.request['category']]
             category.manage_delObjects([action_id])
             self.request.RESPONSE.redirect('@@actions-controlpanel')
+        if self.request.get('hide'):
+            action_id = self.request['actionid']
+            category = self.portal_actions[self.request['category']]
+            category[action_id].visible = False
+            self.request.RESPONSE.redirect('@@actions-controlpanel')
+        if self.request.get('show'):
+            action_id = self.request['actionid']
+            category = self.portal_actions[self.request['category']]
+            category[action_id].visible = True
+            self.request.RESPONSE.redirect('@@actions-controlpanel')
         return self.display()
 
 


Test patch:
diff --git a/Products/CMFPlone/tests/robot/test_controlpanel_actions.robot b/Products/CMFPlone/tests/robot/test_controlpanel_actions.robot
--- a/Products/CMFPlone/tests/robot/test_controlpanel_actions.robot
+++ b/Products/CMFPlone/tests/robot/test_controlpanel_actions.robot
@@ -32,6 +32,16 @@ Scenario: Create a new action in Actions Control Panel
    When I add a new action
    Then logged-in users can see the new action
 
+Scenario: Hide/show an action in Actions Control Panel
+  Given a logged-in administrator
+    and the actions control panel
+   When I hide an action
+   Then anonymous users cannot see the action anymore
+  Given a logged-in administrator
+    and the actions control panel
+   When I unhide the action
+   Then anonymous users can see the action again
+
 Scenario: Delete an action in Actions Control Panel
   Given a logged-in administrator
     and the actions control panel
@@ -76,9 +86,15 @@ I add a new action
   Click Element  css=.pattern-modal-buttons > input
 
 I delete an action
-  Click Button    css=section:nth-child(3) li:first-child input[type=submit]
+  Click Button    css=section:nth-child(3) li:first-child input[name=delete]
   Confirm Action
 
+I hide an action
+  Click Button    css=section:nth-child(3) li:first-child input[name=hide]
+
+I unhide the action
+  Click Button    css=section:nth-child(3) li:first-child input[name=show]
+
 # --- THEN -------------------------------------------------------------------
 
 anonymous users can see the new action title
@@ -101,4 +117,9 @@ logged-in users can see the new action
 anonymous users cannot see the action anymore
   Disable autologin
   Go to  ${PLONE_URL}
-  Page Should Not Contain  Site map
+  Page Should Not Contain  Site Map
+
+anonymous users can see the action again
+  Disable autologin
+  Go to  ${PLONE_URL}
+  Page Should Contain  Site Map
\ No newline at end of file