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

toolbar should not be shown when user authenticated but has no edit, contribute or review role for the current page #1570

Closed
fgrcon opened this issue May 3, 2016 · 5 comments

Comments

@fgrcon
Copy link
Member

fgrcon commented May 3, 2016

Plone 5.x
This is a regression compared to 4.x

There are many use cases where users authenticate just in order to be able to see shared content. The toolbar is useless in such situations, is confusing and is ugly for most themes. Instead of the toolbar a simple dropdown with user actions like in Plone 4.x needs to be shown.

See also http://stackoverflow.com/questions/32824931/how-to-disable-plone-5-toolbar-for-authenticated-user-group/36979732#36979732

@jensens
Copy link
Member

jensens commented May 5, 2016

keep in mind: the personal bar is part of the toolbar.

@djay
Copy link
Member

djay commented May 6, 2016

I suspect we might need a way to re-enable the old style personal bar for these type situations. I can see lots of situations where you want to use plone for login/logout/change pw etc, but not for letting people edit/workflow and not for your own custom actions.

Possibly just via diazo and theming. but certainly It should be easy to to turn off the toolbar so you can use another form of personal tools. I'm not sure if there should be an automatic, simpler personal tools in such a case though.

@fgrcon
Copy link
Member Author

fgrcon commented May 6, 2016

  • showing the toolbar to authenticated users for pages where they dont have edit/add/publish roles seems inacceptable to me.
  • so when i hide the toolbar i will have to provide the personalbar (or just the users name, and links to dashboard (which is still missing) and to preferences.
  • I created a *workaround * by slightly tweaking plone.app.layout the rest is done by some css rules / no diazo modifications needed.
remove plone/app/layout/viewlets/anontools.pt
--------------------------------------------------------
added:
+++ b/plone/app/layout/viewlets/personal_bar.pt
@@ -0,0 +1,49 @@
+<div id="personaltools"
+     i18n:domain="plone">
+
+<p class="hiddenStructure" i18n:translate="heading_personal_tools">Personal tools</p>
+
+<dl class="actionMenu deactivated" id="portal-personaltools"
+    tal:condition="python:view.user_actions and not view.anonymous">
+  <tal:block condition="not: view/anonymous">
+  <dt class="actionMenuHeader">
+    <a id="user-name"
+       tal:attributes="href view/homelink_url"
+       tal:content="view/user_name">
+        John
+    </a>
+  </dt>
+  <dd class="actionMenuContent">
+    <ul>
+        <li tal:repeat="action view/user_actions"
+            tal:attributes="id string:personaltools-${action/id}">
+            <a href=""
+               tal:attributes="href action/href;
+                               target action/link_target|nothing"
+               tal:content="action/title"
+               i18n:translate="">
+                action title
+            </a>
+        </li>
+    </ul>
+  </dd>
+  </tal:block>
+</dl>
+
+<ul class="actionMenu deactivated" id="portal-personaltools"
+    tal:condition="python:view.user_actions and view.anonymous">
+  <li id="anon-personalbar">
+    <tal:actions repeat="action view/user_actions">
+        <a href=""
+           tal:attributes="href action/href;
+                           id string:personaltools-${action/id};
+                           target action/link_target|nothing;"
+           tal:content="action/title"
+           i18n:translate="">
+            action title
+        </a>
+    </tal:actions>
+  </li>
+</ul>
+
+</div>
-------------------------------------------------------------------
--- a/plone/app/layout/viewlets/configure.zcml
+++ b/plone/app/layout/viewlets/configure.zcml
@@ -167,15 +167,17 @@
         class=".common.SearchBoxViewlet"
         permission="zope2.View"
         />
-
-    <!-- The anontools (login, register) -->
+        
+    <!-- The personaltoolsviewlet (prefs, dashboard,...) -->
     <browser:viewlet
-        name="plone.anontools"
+        name="plone.personal_bar"
         manager=".interfaces.IPortalHeader"
         class=".common.PersonalBarViewlet"
         permission="zope2.View"
-        template="anontools.pt"
+        template="personal_bar.pt"
         />
-----------------------------------
--- a/plone/app/layout/viewlets/common.py
+++ b/plone/app/layout/viewlets/common.py
....
 class PersonalBarViewlet(ViewletBase):   
+    index = ViewPageTemplateFile('personal_bar.pt')
     def update(self):
...
  • Results:
    anonymous:
    anonym

only read permissions:
noroles

edit permissions:
role-edit

  • CSS
// remove toolbar for authenticated members when no permission to edit, contribute, review 
// see also: http://stackoverflow.com/questions/32824931/how-to-disable-plone-5-toolbar-for-authenticated-user-group

body.userrole-member #edit-zone {
  display:none;
}
.plone-toolbar-top-expanded {
    margin-top: 50px;
  }
body.userrole-member.plone-toolbar-top-expanded {
     margin-top: 0;
}     
body.userrole-editor #edit-zone,
body.userrole-contributor #edit-zone,
body.userrole-reviewer #edit-zone {
  display:inline-block;
}
body.userrole-editor.plone-toolbar-top-expanded,
body.userrole-contributor.plone-toolbar-top-expanded,
body.userrole-reviewer.plone-toolbar-top-expanded {
    margin-top: 50px;
  }
body.userrole-editor #portal-languageselector,
body.userrole-contributor #portal-languageselector,
body.userrole-reviewer #portal-languageselector {
  margin-top:50px;
} 

}
body.userrole-editor #personaltools,
body.userrole-contributor #personaltools ,
body.userrole-reviewer #personaltools,
body.userrole-userrole-owner #personaltools,
body.userrole-manager #personaltools {
    display: none;
  }
#personaltools {
    position: absolute;
    top: 10px;
    float: left;
    right: 1%;
    z-index: 110;
    font-size: 100%;
  }

@jensens, @djay: I doubt that this is a 'clean' solution (thats why no pull requests) but it works for me.
Thanks for any comments / hints ...

@hvelarde hvelarde mentioned this issue May 6, 2016
19 tasks
@3dogMcNeill
Copy link
Contributor

Agreed! +1

fgrcon added a commit that referenced this issue Jul 20, 2017
fgrcon added a commit to plone/plone.app.upgrade that referenced this issue Jul 20, 2017
@fgrcon
Copy link
Member Author

fgrcon commented Jul 20, 2017

A much better and cleaner approach has been provided by @agitator by introducing a new permission ‘Show Toolbar’.`
see:

If I understand the intentions of this changes correctly - I would change the role maps for this permission accordingly - please see following prs. (works fine for me!).

@fgrcon fgrcon closed this as completed Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants