Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence - hide comments, ellipsis and breadcrumbs on pages from unlicensed users

Drew Smith February 14, 2019

Jira Service Desk gives the ability to link to a KB area in Confluence. Our KB articles require authentication in order to view them, anonymous access cannot be given as we cannot have our competitors seeing these articles. In this scenario we are setting up Confluence so there is no global anonymous access and the Unlicensed Access is enabled, in JSD that means the "All active users and customers can access the KB without a Confluence license" option is selected. With this setup the first time a customer selects a KB article from the search results they are prompted to login to Confluence, using the same login as JSD they are able to do that, although inconvenient we are fine with this. At this point the customer sees the Confluence page but can also see our comments, the ellipsis which gives options like Page History, Page Information, Resolved Comments .... and there is a Dashboard breadcrumb at the top of the page. We are looking to hide/disable these options so the customer ONLY sees the content of the page. Can anyone recommend how to accomplish this with NO plugins? Here are things that I have found but do not provide a full solution.

Javascript that can to in the Custom HTML area that will check if the user is anonymous and if so hide these areas, as our customers have to login they are simply unlicensed not anonymous, I haven't found any javascript that can test for unlicensed users or users not in any groups
<script type="text/javascript">
AJS.toInit(function(){
if (AJS.params.remoteUser == ''){
AJS.$('#action-menu-link').hide();
AJS.$('#comments-section').hide();
}
});
</script>

In the space's Look and Feel > Stylesheet area we can add the following to hide these areas, but that impacts our staff who create the documents who will need to use comments and inline comments, page history etc.
#action-menu-link {
display:none !important;
}
#breadcrumbs {
display:none !important;
}
#comments-section {
display:none !important;
}

2 answers

1 vote
Drew Smith February 21, 2019

An update on this for anyone who may be interested. There were still elements appearing that we didn't want the customer to see, namely

  • inline comments
  • the "Created by <> last modified...."
  • The Space Tools menu

The following code is the same as above but with the additional lines added to hide these elements.

<script type="text/javascript">
AJS.toInit(function(){
if (!AJS.params.remoteUserHasLicensedAccess){
AJS.$('#action-menu-link').hide();
AJS.$('#comments-section').hide();
AJS.$('#breadcrumbs').hide();
AJS.$('#likes-section').hide();
AJS.$('#labels-section').hide();
AJS$('.page-metadata').hide();
AJS.$('.inline-comment-marker').hide();
AJS.$("#space-tools-menu-trigger").hide();
}
});
</script>

As for the "Likes" area, the following can be put on the Space > Look and Feel > Stylesheet section if really needed to be hidden but this does hide it from licensed and unlicensed users.

#likes-section {
display:none !important;
}

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 19, 2019

Hello Drew,

Thank you for providing vast amounts of details into what you’re attempting to accomplish. This really helps to paint a picture of what you need and how you’re trying to achieve this.

I tested the following and found you may filter based on group/membership. This means you should be able to filter based on a group of members that have no access or filter based on users who have no membership at all. Here is a break down of how this would look:

Removed code, please see answer below.

The better option would be to have all users who need access to be in a group by themselves. This would prevent an accidental account creation and grant the user access to something.

Please test this and let me know if it suits your needs.

Regards,
Stephen Sifers

Drew Smith February 19, 2019

@Stephen Sifers , thanks for the input but this didn't work for me. I noticed using the browser's developer tools the lines "#Users in group named "Unlicensed"" and "#Users who have no group membership" returned "Invalid or unexpected token" errors but when I took those lines out there still was no difference. 

I did some research on AJS.params and I don't see anything about the hasMembership as an available function to it. You say it worked for you, maybe there is a different version you are using than what we are. We are on Confluence Server 6.12.0. 

For fun and to see if there was something else I might have been doing wrong I did test one if statement using AJS.params.spaceKey and that worked, it hid the ellipsis, comments and breadcrumbs but of course that does it for every page in that space.

Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 19, 2019

Hello Drew,

Thank you for testing out the provided information. I went back through and retested this and found it didn’t work on a fresh instance. I had an issue in my testing instance with some residual from the previous testing. I did create a fresh instance with 6.12 and found another method that may work for you. This method uses the global comment layout.

Under Confluence Administration > Look and Feel > Layouts > Comments Layout

Enter the following under the first 3 lines:

#if ($userAccessor.hasMembership('unlicensed', $helper.action.remoteUser.name))
<div id="comments-section" display="hide">
#elseif ($helper.action.remoteUser.name == '')
<div id="comments-section" display="hide">
#else

And add the following at the end of the editor:

#end

Here are screenshots of where this should be inserted:

Start of file:

image.png

End of file:

image.png

The above will hide comments from users within the group named “Unlicensed” or users who are not logged in.

I used the following documentation as reference How to display different appearance for different users using Confluence layouts.

I am also going to correct my response above to remove the incorrect code block that will not work.

Please test the above and let us know the outcome.

Regards,
Stephen Sifers

Drew Smith February 20, 2019

@Stephen Sifers , although I appreciate your input I didn't implement your advice. You had the section for the comments but we also want to hide the ellipsis, breadcrumbs, labels and page like areas. I tried doing your little code snippet in the Content Layouts -> Page Layout area for the ellipsis but it still showed. I wasn't going to play around with the code in the page layout area.

When I was trying your original code block from yesterday I was doing some research trying to get it to work and found one post that mentioned using the browser's dev tools to find the different parameters/options for AJS.params. I did that this morning and found the boolean remoteUserHasLicensedAccess. I implemented that in my initial code and it worked like a charm. I have put the code at the bottom of this reply into the Custom HTML section "At the end of the HEAD" and everything except for the "<user> Likes this" is now removed for the unlicensed users but there for our staff. We will just tell our staff not to like any of our KB articles and that should take care of the "Likes" text.

Probably the only downside to this is when we upgrade Confluence this may have to be replaced, we'll just make a note that this has to be added as part of our upgrade procedure.

<script type="text/javascript">
AJS.toInit(function(){
if (!AJS.params.remoteUserHasLicensedAccess){
AJS.$('#action-menu-link').hide();
AJS.$('#comments-section').hide();
AJS.$('#breadcrumbs').hide();
AJS.$('#likes-section').hide();
AJS.$('#labels-section').hide();
AJS.$('#page-metadata-modification-info').hide();
}
});
</script>

Like Stephen Sifers likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events