How to Remove Tabs, Buttons, Links Under a Specific Path How to Remove Tabs, Buttons, Links Under a Specific Path

Today we have a question from guian who asks how to remove the notification tab in the administration panel for each folder inside: /default-domain/workspaces/myWorkspace/aSpecialFolder/.

To answer that question, the first thing you need to know is that a tab is what we call an Action. An action can also be a link (a tab is basically a link styled as a tab) or a button, anything clickable in fact. And as stated in the documentation, you can filter theses actions. Take a look at the filter extension point in Nuxeo Explorer. As you can see there are several ways to filter actions.

Let's say that the documents where we want to hide the notification tabs are all of a special document type. We could add a filter like this:


<extension point="filters" target="org.nuxeo.ecm.platform.actions.ActionService">
<filter id="notSpecialDocType">
<rule grant="false">
<type>SpecialDocType</type>
</rule>
</filter>
</extension>


The action associated with this filter would not be displayed if the current document type was SpecialDocType. To associate this filter to an existing action, you need to override the action definition. To do that you need to know the id of the action you want to override. Most of the times if you look at the html code of the button or action you want to override, you'll see the action id in the element id. You can also use the search in Nuxeo Explorer. Here, the id of the notification sub tab is TAB_MANAGE_SUBSCRIPTIONS. So to override the action, you have to do as follow:


<extension target="org.nuxeo.ecm.platform.actions.ActionService" point="actions">
<action id="TAB_MANAGE_SUBSCRIPTIONS">
<filter-id>notSpecialDocType</filter-id>
</action>
</extension>


And this is all you have to do. Now this is not exactly what was asked in the question. The filter needs to apply for all documents under a specific path. So you would have to use the condition filter as follow:


<extension point="filters" target="org.nuxeo.ecm.platform.actions.ActionService">
<filter id="notInASpecialFolder">
<rule grant="false">
<condition>#{currentDocument.getPathAsString().startsWith('/default-domain/worspaces/myWorkspace/aSpecialFolder/')}</condition>
</rule>
</filter>
</extension>


Make sure you don't use an EL too heavy to evaluate. Filters are evaluated regularly so badly designed filters can have an impact on performance. If you want to know more about filters, make sure you read the appropriate documentation.