├── .gitignore ├── assets ├── logo.png ├── banner.png ├── logo-small.png ├── screenshot-0.png ├── screenshot-1.png ├── screenshot-2.png ├── logo-promotion.png ├── icon_nav_bar_active.png ├── icon_nav_bar_hover.png └── icon_nav_bar_inactive.png ├── templates ├── layout.hdbs ├── deleting.hdbs ├── error.hdbs ├── non-admin.hdbs ├── loading.hdbs └── page.hdbs ├── manifest.json ├── app.css ├── translations └── en.json ├── README.md ├── LICENCE └── app.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_store 2 | tmp 3 | assets/.DS_store -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/bulk_delete_orgs_app/master/assets/logo.png -------------------------------------------------------------------------------- /assets/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/bulk_delete_orgs_app/master/assets/banner.png -------------------------------------------------------------------------------- /assets/logo-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/bulk_delete_orgs_app/master/assets/logo-small.png -------------------------------------------------------------------------------- /assets/screenshot-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/bulk_delete_orgs_app/master/assets/screenshot-0.png -------------------------------------------------------------------------------- /assets/screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/bulk_delete_orgs_app/master/assets/screenshot-1.png -------------------------------------------------------------------------------- /assets/screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/bulk_delete_orgs_app/master/assets/screenshot-2.png -------------------------------------------------------------------------------- /assets/logo-promotion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/bulk_delete_orgs_app/master/assets/logo-promotion.png -------------------------------------------------------------------------------- /assets/icon_nav_bar_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/bulk_delete_orgs_app/master/assets/icon_nav_bar_active.png -------------------------------------------------------------------------------- /assets/icon_nav_bar_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/bulk_delete_orgs_app/master/assets/icon_nav_bar_hover.png -------------------------------------------------------------------------------- /assets/icon_nav_bar_inactive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zendesk/bulk_delete_orgs_app/master/assets/icon_nav_bar_inactive.png -------------------------------------------------------------------------------- /templates/layout.hdbs: -------------------------------------------------------------------------------- 1 |
2 |
5 |
6 | 8 | -------------------------------------------------------------------------------- /templates/deleting.hdbs: -------------------------------------------------------------------------------- 1 |
2 | 3 |

Deleting...

4 | 5 |
6 |
7 |
8 | 9 |
-------------------------------------------------------------------------------- /templates/error.hdbs: -------------------------------------------------------------------------------- 1 |

Uh oh, looks like something went wrong. Please try again, or report an error if the issue persists.

-------------------------------------------------------------------------------- /templates/non-admin.hdbs: -------------------------------------------------------------------------------- 1 |
2 |

It looks like you're not an admin in this account. This tool is designed to be used by admininstators; please contact an admin to make any changes.

3 |
-------------------------------------------------------------------------------- /templates/loading.hdbs: -------------------------------------------------------------------------------- 1 |
2 | 3 |

Just a moment while we load the Orgs...

4 | 5 |
6 |
7 |
8 | 9 |
-------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Bulk Delete Organisations", 3 | "author": { 4 | "name": "Zendesk Labs", 5 | "email": "zenlabs@zendesk.com", 6 | "url": "https://github.com/zendesklabs/bulk_delete_orgs_app" 7 | }, 8 | "defaultLocale": "en", 9 | "private": false, 10 | "location": "nav_bar", 11 | "version": "1.3", 12 | "frameworkVersion": "1.0" 13 | } -------------------------------------------------------------------------------- /app.css: -------------------------------------------------------------------------------- 1 | #bulk-actions { 2 | margin-bottom: 1em; 3 | } 4 | 5 | .spinner-div { 6 | padding-top: 4em; 7 | } 8 | 9 | .top-par { 10 | padding: 1em; 11 | } 12 | 13 | .redButton { 14 | background: red; 15 | color: white; 16 | } 17 | 18 | .org-name-head, .org-name-cell { 19 | width: 50%; 20 | } 21 | 22 | .created-head, .created-cell { 23 | width: 25%; 24 | } 25 | 26 | .mark-head, .mark-cell { 27 | width: 25%; 28 | } 29 | 30 | .loading-container, 31 | .deleting-container { 32 | width: 50%; 33 | margin: 0 auto 34 | } 35 | 36 | .loading-container > p, 37 | .deleting-container > p { 38 | margin: 3em auto; 39 | text-align: center; 40 | } 41 | 42 | .pagination > .ellipses > a:hover, 43 | .pagination > .ellipses > a:focus { 44 | background: none; 45 | color: #000; 46 | } 47 | -------------------------------------------------------------------------------- /translations/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": { 3 | "package": "app_name", 4 | "description": { 5 | "value": "Play the famous zen tunes in your help desk.", 6 | "title": "app description" 7 | }, 8 | "name": { 9 | "value": "Buddha Machine", 10 | "title": "app name" 11 | } 12 | }, 13 | 14 | "loading": { 15 | "value": "Welcome to this Sample App", 16 | "title": "loading placeholder" 17 | }, 18 | 19 | "fetch": { 20 | "done": { 21 | "value": "Good", 22 | "title": "fetch success" 23 | }, 24 | "fail": { 25 | "value": "failed to fecth information from the server", 26 | "title": "fetch failure" 27 | } 28 | }, 29 | 30 | "id": { 31 | "value": "ID", 32 | "title": "user id" 33 | }, 34 | 35 | "email": { 36 | "value": "Email", 37 | "title": "user email" 38 | }, 39 | 40 | "name": { 41 | "value": "Name", 42 | "title": "user name" 43 | }, 44 | 45 | "role": { 46 | "value": "Role", 47 | "title": "user role" 48 | }, 49 | 50 | "groups": { 51 | "value": "Groups", 52 | "title": "user groups" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | :warning: *Use of this software is subject to important terms and conditions as set forth in the License file* :warning: 2 | 3 | # Bulk Delete Organizations 4 | 5 | ## Description: 6 | 7 | This app offers an easy way to delete many organisations at one time. Admins can see a list of all of their orgs, paginated to 50 per page. Orgs can be selected and deselected individually or using bulk actions, and deleted. 8 | 9 | ## App location: 10 | 11 | * Navigation Bar 12 | 13 | ## Features: 14 | 15 | * Mark orgs individually via a checkbox 16 | * Select all on current page 17 | * Select all 18 | * Remove all selected 19 | * Delete selected orgs 20 | 21 | ## Set-up/installation instructions: 22 | 23 | No additional steps are required to install this app 24 | 25 | ## Contribution: 26 | 27 | Pull requests are welcome. 28 | 29 | ## Screenshot(s): 30 | 31 | Basic interface: 32 | 33 | ![](http://i.imgur.com/oMHZipo.png) 34 | 35 | ... 36 | 37 | ![](http://i.imgur.com/rMruxtY.png) 38 | 39 | Confirmation modal: 40 | 41 | ![](http://i.imgur.com/83x8OCJ.png) 42 | 43 | When selecting none: 44 | 45 | ![](http://i.imgur.com/ptzFXGD.png) 46 | 47 | Non-admin message: 48 | 49 | ![](http://i.imgur.com/Q27fsGc.png) 50 | -------------------------------------------------------------------------------- /templates/page.hdbs: -------------------------------------------------------------------------------- 1 |
2 | 3 |

You can delete organisations in bulk using the tool below

4 | 5 |
6 | 7 | 8 | 9 | 10 |
11 | 12 | 15 | 16 |
17 | 18 | 21 | 22 |
23 | 24 |
25 |
26 | 27 | 28 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | Copyright 2016 Zendesk 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | Capitalized terms used herein have the meaning set forth in the Zendesk, Inc. 16 | (“Zendesk”) Terms of Service (available at www.zendesk.com/company/terms) (the “Terms”). 17 | The software made available herein constitutes “ZendeskLabs Software” which may be 18 | implemented to enable features or functionality to be utilized in connection with a 19 | subscription to the Service. 20 | Notwithstanding anything to the contrary set forth in the Terms or any other 21 | agreement by and between you and Zendesk, ZendeskLabs Software is provided 22 | “AS IS” and on an “AS AVAILABLE” basis, and that Zendesk makes no warranty 23 | as to the ZendeskLabs Software. 24 | 25 | ZENDESK DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 26 | TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 27 | NONINFRINGEMENT AND THOSE ARISING FROM A COURSE OF DEALING OR USAGE OF TRADE 28 | RELATED TO THE ZENDESKLABS SOFTWARE, ITS USE OR ANY INABILITY TO USE IT OR 29 | THE RESULTS OF ITS USE. 30 | 31 | Use of ZendeskLabs Software is subject to the following risks and conditions: 32 | (i) the ZendeskLabs Software is not an component of the Service that 33 | has been designed for commercial release for by Zendesk; 34 | 35 | (ii) the ZendeskLabs Software may not be in final form and may contain errors, 36 | design flaws or other problems; (iii) the ZendeskLabs Software is not expected to 37 | function fully or adequately upon installation, and it is expected and anticipated that 38 | further testing, modification and development may be necessary to make the 39 | ZendeskLabs Software functional; 40 | 41 | (iv) it may not be possible to make the ZendeskLabs Software functional; 42 | 43 | (v) use of the ZendeskLabs Software may result in unexpected results, loss of data, 44 | project delays or other unpredictable damage or loss; and 45 | 46 | (vi) Zendesk is under no obligation to release and/or offer for sale commercial 47 | versions of the ZendeskLabs Software, and Zendesk has the right to unilaterally 48 | abandon development or availability of the ZendeskLabs Software at any time and 49 | without any obligation or liability to You. You further agree that Zendesk shall 50 | have no obligation to correct any bugs, defects or errors in the ZendeskLabs Software 51 | or otherwise to support or maintain the ZendeskLabs Software. 52 | 53 | If you elect to utilize any ZendeskLabs Software, you are agreeing to release Zendesk 54 | from any claim with regard to the ZendeskLabs Software, its operation, availability or 55 | its failure to operate or be available. Without limiting the generality of the foregoing, 56 | 57 | You acknowledge and agree that neither the use, availability nor operation of any 58 | ZendeskLabs Software shall be subject to any service level commitment applicable to the Service. 59 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 3 | var PAGE_SIZE = 500, 4 | 5 | timedStatusCheck, 6 | allOrgs, 7 | numTables, 8 | orgsToBeDeleted = [], 9 | deletionProgress, 10 | totalPagesToDelete; 11 | 12 | return { 13 | events: { 14 | 'pane.activated':'init', 15 | 'app.willDestroy':'stopTimeOut', 16 | 'orgsGetRequest.done':'checkForMoreOrgs', 17 | 'orgsGetRequest.fail':'showError', 18 | 'orgsGetRequestPaginated.done':'checkForMoreOrgs', 19 | 'orgsGetRequestPaginated.fail':'showError', 20 | 'bulkDeleteOrgsRequest.done':'checkDeletionStatus', 21 | 'bulkDeleteOrgsRequest.fail':'showError', 22 | 'checkDeletionStatusRequest.done':'checkDeletionStatus', 23 | 'checkDeletionStatusRequest.fail':'showError', 24 | 'click .submit':'showModal', 25 | 'click .confirmDelete':'gatherIDs', 26 | 'click #closeConfirmModal':'removeParagraph', 27 | 'click .toggle-button':'togglePage', 28 | 'click #reload-orgs':'startAgain', 29 | 'click #select-page':'selectPage', 30 | 'click #select-all': 'selectAll', 31 | 'click #clear-all': 'clearAll' 32 | }, 33 | 34 | requests: { 35 | // GET all of the orgs in the account 36 | orgsGetRequest: function() { 37 | return { 38 | url: '/api/v2/organizations.json', 39 | type: 'GET', 40 | dataType: 'json' 41 | }; 42 | }, 43 | 44 | // GET page pid of the orgs list 45 | orgsGetRequestPaginated: function(pid) { 46 | return { 47 | url: '/api/v2/organizations.json?page=' + pid, 48 | type: 'GET', 49 | dataType: 'json' 50 | }; 51 | }, 52 | 53 | // Delete all orgs identified by the ids variable 54 | bulkDeleteOrgsRequest: function(ids) { 55 | return { 56 | url: '/api/v2/organizations/destroy_many.json?ids=' + ids, 57 | type: 'DELETE', 58 | dataType: 'json' 59 | }; 60 | }, 61 | 62 | // Check the status of job identified by the id variable 63 | checkDeletionStatusRequest: function(id) { 64 | return { 65 | url: '/api/v2/job_statuses/' + id, 66 | type: 'GET', 67 | dataType: 'json' 68 | }; 69 | } 70 | }, 71 | 72 | // Initialise: make a GET request for the orgs if an admin, and show a message if not 73 | init: function() { 74 | if (this.currentUser().role() == 'admin') { 75 | this.switchTo('loading'); 76 | this.ajax('orgsGetRequest'); 77 | } else { 78 | this.switchTo('non-admin'); 79 | } 80 | 81 | }, 82 | 83 | // After making the GET request, check if there are more pages 84 | checkForMoreOrgs: function(data) { 85 | var orgsSoFar = allOrgs||[], 86 | eqaulIndex, 87 | pageNum, 88 | totalPages = Math.ceil(data.count/100), 89 | barPercent; 90 | 91 | orgsSoFar = orgsSoFar.concat(data.organizations); 92 | allOrgs = orgsSoFar; 93 | 94 | if (!data.next_page) { 95 | this.showOrgsList(); 96 | } else { 97 | eqaulIndex = data.next_page.indexOf("="); 98 | pageNum = data.next_page.slice(eqaulIndex+1); 99 | barPercent = 100*pageNum/totalPages; 100 | this.$('.bar').css('width', barPercent + "%"); 101 | this.ajax('orgsGetRequestPaginated', pageNum); 102 | } 103 | }, 104 | 105 | // Display the orgs on a table 106 | showOrgsList: function(data) { 107 | this.switchTo('page'); 108 | 109 | var orgsArray = allOrgs, 110 | orgsArrayLength = orgsArray.length, 111 | TABLE_SIZE = 50, 112 | table, 113 | row, 114 | button; 115 | 116 | numTables = Math.ceil(orgsArrayLength/TABLE_SIZE); 117 | this.sortOrgs(orgsArray); 118 | this.formatDates(orgsArray); 119 | 120 | for (var i=0; i