Last active
October 27, 2020 18:53
-
-
Save AustinHay/68f332f1f01c04cbb4ea132289324521 to your computer and use it in GitHub Desktop.
A simple JS script to set standard operating permissions in the Braze UI.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// *=====================================================================================================* // | |
function set_default_permissions() { | |
// Set the user to Limited User so that the options below show. | |
window.document.getElementsByClassName("developer-role-select")[0].value = "Limited" | |
$('.developer-role-select').change(function(){ | |
var data= $(this).val(); | |
}); | |
$('.developer-role-select') | |
.val('"Limited"') | |
.trigger('change'); | |
// Set Department to Marketing if there is none. | |
if (window.document.getElementsByClassName("developer-department-select")[0].value === "") { | |
window.document.getElementsByClassName("developer-department-select")[0].value = 'marketing' | |
$('.developer-department-select').change(function(){ | |
var data= $(this).val(); | |
}); | |
$('.developer-department-select') | |
.val('marketing') | |
.trigger('change'); | |
} | |
// Remove and add all the Groups to the Profile | |
for (var i = 0; i < 9; i++) { | |
if ( window.document.getElementsByClassName("pull-right remove-permitted-app-group-btn").length > 0 ) { | |
window.document.getElementsByClassName("pull-right remove-permitted-app-group-btn")[0].click() | |
} | |
} | |
for (var i = 0; i < 9; i++) { | |
window.document.getElementsByClassName("c-button c-primary-button")[0].click() | |
} | |
// Simulate clicks on the limited permissions that we want. | |
var inputs = window.document.getElementsByTagName('input') | |
inputs = [].slice.call(inputs); | |
inputs = inputs.slice(5) | |
// List of permissions and default permission for each. | |
default_non_admin_access_list =[ | |
// Admin ---> 1 | |
0, | |
// Access Campaings, Canvases, Cards, Segments, Media Library ---> 6 | |
1, | |
// Send Campaigns, Canvases ---> 2 | |
1, | |
// Publish Cards ---> 3 | |
1, | |
// Edit Segments ---> 4 | |
1, | |
// Export User Data ---> 5 | |
0, | |
// View User Profiles ---> 6 | |
1, | |
// Manage Dashboard Users ---> 7 | |
0, | |
// Manage Media Library ---> 8 | |
1, | |
// View Usage Data ---> 9 | |
1, | |
// Import And Update User Data ---> 10 | |
0, | |
// View Billing Details ---> 11 | |
0, | |
// Access Dev Console ---> 12 | |
1, | |
// Manage External Integrations ---> 13 | |
0, | |
// Manage Apps ---> 14 | |
0, | |
// Manage Teams ---> 15 | |
0, | |
// Manage Events,Attributes,Purchases ---> 16 | |
1, | |
// Manage Tags ---> 17 | |
1, | |
// Manage Email Setting ---> 18 | |
0, | |
// Manage Subscription Groups ---> 19 | |
0 | |
] | |
var number_of_app_groups = window.document.getElementsByClassName("app-group-name").length / 2 | |
function set_permissions(permissions) { | |
for (var i = 1; i < inputs.length; i++) { | |
if ( permissions[i % 20] === 1) { inputs[i].click() } | |
} | |
} | |
set_permissions(default_non_admin_access_list) | |
// Save the Permissions, and now you're back at the menu screen. | |
// window.document.getElementsByClassName("c-button c-primary-button developer-save-btn")[0].click() | |
} | |
// *=====================================================================================================* // | |
set_default_permissions() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment