cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
shane_ohara
Community Champion

Custom JS to Hide +App Button from Course Settings

Hello, 

We are finding that Canvas permissions for LTI management (when disabled to all roles except for account admins) are not granular enough to allow instructors to edit/delete installed LTIs in a course (example: redirect tool links) while removing the ability to install an entirely new app that has yet to be vetted through our security team. Instructors have the ability to install any account-level app, however.

We would like to hide the +App button from Settings > Apps > View App Configurations. I know how to hide the button using JS, but it seems that the click on View App Configurations invokes an event to happen to re-shows the button. If the page is reloaded, then the button is hidden again using $('.AddExternalToolButton').hide(); from the uploaded JS. 

Account admins should retain access to the button. All non-admin roles should not.

This is what I am using right now:

$(document).ready(function(){
if($.inArray('admin',ENV['current_user_roles']) == -1) {
   $(".AddExternalToolButton").hide();

   console.log ('hide Add App button')

}
});

314791_Screen Shot 2019-06-10 at 8.52.56 AM.png

I am wondering if anyone in this group knows how to hide the button after a click on View App Configurations and the event is triggered?

Best regards,

Shane

Labels (1)
Tags (2)
2 Replies
robotcars
Community Champion

I've had this tab open since you posted, and I feel bad that I haven't responded. It's a busy few weeks.

The solution likely requires Mutation Observers, and removing jQuery, for best practice. You can search the community for Mutation Observers, I think we mention it by name with many mixed feelings in every script discussion that uses it.

 @korina_figueroa ‌, did a nice job documenting her issue and shared a solution https://community.canvaslms.com/groups/canvas-developers/blog/2019/05/31/course-import-tool-include-... 

dgrobani‌, posted one that resulted in a few discussions Sort Account-Level Course Page Terms in Descending Order

Thank you for responding! This is going to get me going in the right direction. Much appreciated.