Hi everyone,
I'm looking for a user macro that removes the labels from the current Confluence page.
Ideally, I would like a 'button' and when clicked will remove the labels.
Is this possible?
Thanks!
Community moderators have prevented the ability to post new answers.
This is a bit quick and dirty, but it'll do:
## @noparams #if($permissionHelper.canEdit($userAccessor.getUserIfAvailable($req.getRemoteUser()),$content)) <button class="aui-button" onclick="removeLabels()">Remove all labels</button> <script> var removeLabels = function() { jQuery.ajax({ url: contextPath + "/rest/api/content/" + $content.id + "?expand=metadata.labels", success: function(response) { jQuery(response.metadata.labels.results).each(function() { jQuery.post(contextPath+'/json/removelabelactivity.action', {'entityIdString': '$content.id', 'labelIdString': this.name, 'atl_token': jQuery('#atlassian-token').attr('content') }); }); } }); jQuery("li.aui-label").remove(); jQuery("ul.label-list-right").prepend('<li class="no-labels-message">No labels</li>'); alert("All labels removed."); } </script> #end
EDIT: Oops, forgot to remove the hardcoded pageId
For the button part of this, you can use the Run macro with user macro as the body.
For the user macro part, I am not sure. Maybe this question might help: https://answers.atlassian.com/questions/107652. If that doesn't work out, then you can always construct a small script using Scripting for Confluence.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.