How do I disable the create page button for a specific space?

Guy Toyber May 2, 2022

Hi,

I need to disable the creation button for specific spaces.

I found the code below that disables the creation button for all spaces. I need help adjusting it so I can still create pages in other spaces...

<script type="text/javascript">
AJS.toInit(function(){
AJS.$('#quick-create-page-button').hide();
});
</script>

Any tips would be appreciated.

Thanks!

1 answer

1 accepted

2 votes
Answer accepted
Matthias Gaiser _K15t_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 2, 2022

Hi @Guy Toyber

may I ask why you want to disable the creation button? How about using Confluence's space permissions in order to control who's able to create pages for specific pages in spaces? You can define per group or user who's able to do so. You could also restrict everyone from creating pages.

This way, you also prevent the creation of pages via the REST API.

Cheers,
Matthias.

Guy Toyber May 3, 2022

Hi @Matthias Gaiser _K15t_ 

Our Confluence is being migrated from Server to Data Center.

Before a space export we do restrict all users from editing. In this mode "edit" page is hide but "Create" page is visible.

Users can still create pages in other spaces, and since the create button is still visible the scenario of a user that will visit the limited space and will want to published a page there -  it can happen - but the page will be published in another space.

In other words, the user intention will be to create a new page in the limited space but the result will be a new page in another space.

So to be on the safe side and to avoid confusion I would like to hide/disable the create button.

 

Regards,

Guy

Matthias Gaiser _K15t_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 3, 2022

I understand, @Guy Toyber. Thank you for your explanation - that makes sense to me then. And I think I have a solution for you. This call

AJS.Meta.get("space-key")

returns the current space key you are in. If you include that into an if statement into your code, you could check if the space key matches one of your moved ones.

Hope that helps,
Matthias.

Guy Toyber May 3, 2022

Hi @Matthias Gaiser _K15t_ ,

I appreciate your help so far, would you mind to paste the entire code? It did not work for me...

Additionally, If I would like to hide another create button on additional space, how it will work? 

 

Regards,

Guy

Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 3, 2022
Like Matthias Gaiser _K15t_ likes this
Guy Toyber May 3, 2022

Hi Thiago,

Thanks for the info, its now working perfect!

I appreciate your help!

 

Regards,

Guy

Like Matthias Gaiser _K15t_ likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events