Expand my Community achievements bar.

What or how page editor modes generate (targeting, timewarp, design, developer and scaffolding) dropdown button list?

Avatar

Level 2

Hello, 

Synopsis, I wanted to restrict the "Targeting" UI button by denying it thru ACL. 
I know that /libs/wcm/core/content/editor/jcr:content/content/items/content/header/items/headerbar/items/selectlayerpopover/items/buttonlist generates the popover but I need to know what or how the button list is being populated in the dropdown for me to be able to restrict or modify it to disable and hide "Targeting" only while the rest of the modes are enabled and visible.
jnikolainemo_0-1691027250676.png


Only restricting of component or method thru ACL is acceptable for this one. 


Thank you for all the help!

3 Replies

Avatar

Employee

you can write custom clientlib where you can define the logic of hiding the targetting button.

Example  : 

(function($, window) {
    'use strict';

    /* editor panel selector */
    var headerSelector = '.editor-GlobalBar.editor-panel-header .header-main';
    /* targeting mode selector */
    var targetingLayer = '#selectlayer-popover .js-editor-LayerSwitcherTrigger[data-layer="Targeting"]';
   $(window.document).ready( function() {
        var header = $(headerSelector);
        /* wait until content frame is loaded */
        $(window.document).on('click', '[href="#selectlayer-popover"]', function() {
            /* hide targeting layer */
            header.find(targetingLayer).hide();
        });
    });

}(jQuery, window));

Avatar

Level 2

Thank you for the answer but for now only restricting/deny in AC Tool of component or the one that handles the rending of "Targeting" button is allowed. 

Avatar

Level 5

Well, this can be achieved through java script, but since you are looking for an ACL option. I am assuming one specific approach may work and you can try the same. Here my understanding is this layer for Targeting is added based on presence of contexthub clientlib  in the content page so you can identify your customheaderlibs.html HTL file of your page component, and use CQ Granite User API to determine logged in user's access and if the user has permission to the group you are referring to, then only add the clientlib, and ensure this is added only in WCM Edit Mode. See if this helps. Thanks !