{"action":"created","comment":{"url":"https://api.github.com/repos/juju/juju-gui/pulls/comments/83928003","pull_request_review_id":4737202,"id":83928003,"diff_hunk":"@@ -108,6 +110,117 @@ YUI.add('user-profile-model-list', function() {\n     },\n \n     /**\n+      Display the confirmation for destroying a model.\n+\n+      @method _displayConfirmation\n+      @param {Object} model the model to destroy. A model should at least have\n+                            a name and uuid.\n+    */\n+    _displayConfirmation: function(model) {\n+      this.setState({modelToBeDestroyed: model});\n+    },\n+\n+    /**\n+      Generate the confirmation for destroying a model.\n+\n+      @method _displayConfirmation\n+      @return {Object} the confirmation component.\n+    */\n+    _generateConfirmation: function() {\n+      const model = this.state.modelToBeDestroyed;\n+      const addNotification = this.props.addNotification;\n+      if (!model) {\n+        return;\n+      }\n+      if (model.isAdmin) {\n+        addNotification({\n+          title: 'Cannot destroy model',\n+          message: 'The controller model cannot be destroyed.',\n+          level: 'error'\n+        });\n+        return;\n+      }\n+      const buttons = [{\n+        title: 'Cancel',\n+        action: this._displayConfirmation.bind(this, null),\n+        type: 'base'\n+      }, {\n+        title: 'Destroy',\n+        action: this._destroyModel,\n+        type: 'destructive'\n+      }];\n+      const message = `Are you sure you want to destroy ${model.name}?`\n+        + ' All the applications and units included in the model will be'\n+        + ' destroyed. This action cannot be undone.';\n+      return (\n+        <juju.components.ConfirmationPopup\n+          buttons={buttons}\n+          message={message}\n+          title=\"Destroy model\" />);\n+    },\n+\n+    /**\n+      Makes a request of the controller to delete a selected model.\n+\n+      @method _destroyModel\n+    */\n+    _destroyModel: function() {\n+      const model = this.state.modelToBeDestroyed;\n+      const uuid = model.uuid;\n+      // Hide the confirmation popup.\n+      this._displayConfirmation(null);\n+      const xhr = this.props.destroyModels([uuid], this._destroyModelCallback);\n+      this.xhrs.push(xhr);\n+    },\n+\n+    /**\n+      Callback for the controller delete model call.\n+\n+      @method _destroyModelCallback\n+      @param {String} err The error from the request, or null.\n+      @param {Array} modelList The list of models.\n+    */\n+    _destroyModelCallback: function(err, results) {\n+      const addNotification = this.props.addNotification;\n+      // Handle global errors.\n+      if (err) {\n+        addNotification({\n+          title: 'Model destruction failed',\n+          message: 'The model failed to be destroyed: ' + err,\n+          level: 'error'\n+        });\n+        return;\n+      }\n+      // Ignore all but the first UUID.\n+      const uuid = Object.keys(results)[0];","path":"jujugui/static/gui/src/app/components/user-profile/model-list/model-list.js","position":115,"original_position":115,"commit_id":"2ad4e1414b40b9ae2fb170737d17467f2a626c81","original_commit_id":"2ad4e1414b40b9ae2fb170737d17467f2a626c81","user":{"login":"hatched","id":532033,"avatar_url":"https://avatars.githubusercontent.com/u/532033?v=3","gravatar_id":"","url":"https://api.github.com/users/hatched","html_url":"https://github.com/hatched","followers_url":"https://api.github.com/users/hatched/followers","following_url":"https://api.github.com/users/hatched/following{/other_user}","gists_url":"https://api.github.com/users/hatched/gists{/gist_id}","starred_url":"https://api.github.com/users/hatched/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hatched/subscriptions","organizations_url":"https://api.github.com/users/hatched/orgs","repos_url":"https://api.github.com/users/hatched/repos","events_url":"https://api.github.com/users/hatched/events{/privacy}","received_events_url":"https://api.github.com/users/hatched/received_events","type":"User","site_admin":false},"body":"I'm not really sure about this implementation. It seems like looping through all of them would be just as much work and would allow us to easily add the ability to delete more at once in the future.","created_at":"2016-10-18T19:07:08Z","updated_at":"2016-10-18T19:07:08Z","html_url":"https://github.com/juju/juju-gui/pull/2127#discussion_r83928003","pull_request_url":"https://api.github.com/repos/juju/juju-gui/pulls/2127","_links":{"self":{"href":"https://api.github.com/repos/juju/juju-gui/pulls/comments/83928003"},"html":{"href":"https://github.com/juju/juju-gui/pull/2127#discussion_r83928003"},"pull_request":{"href":"https://api.github.com/repos/juju/juju-gui/pulls/2127"}}},"pull_request":{"url":"https://api.github.com/repos/juju/juju-gui/pulls/2127","id":89232237,"html_url":"https://github.com/juju/juju-gui/pull/2127","diff_url":"https://github.com/juju/juju-gui/pull/2127.diff","patch_url":"https://github.com/juju/juju-gui/pull/2127.patch","issue_url":"https://api.github.com/repos/juju/juju-gui/issues/2127","number":2127,"state":"open","locked":false,"title":"Re-enable destroy model in the profile.","user":{"login":"kadams54","id":378036,"avatar_url":"https://avatars.githubusercontent.com/u/378036?v=3","gravatar_id":"","url":"https://api.github.com/users/kadams54","html_url":"https://github.com/kadams54","followers_url":"https://api.github.com/users/kadams54/followers","following_url":"https://api.github.com/users/kadams54/following{/other_user}","gists_url":"https://api.github.com/users/kadams54/gists{/gist_id}","starred_url":"https://api.github.com/users/kadams54/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kadams54/subscriptions","organizations_url":"https://api.github.com/users/kadams54/orgs","repos_url":"https://api.github.com/users/kadams54/repos","events_url":"https://api.github.com/users/kadams54/events{/privacy}","received_events_url":"https://api.github.com/users/kadams54/received_events","type":"User","site_admin":false},"body":"Fixes #2106.","created_at":"2016-10-13T16:01:06Z","updated_at":"2016-10-18T19:12:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b37da89e789f7dde21220d2c30527f5cd128a4bc","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/juju/juju-gui/milestones/16","html_url":"https://github.com/juju/juju-gui/milestones/2.2.2","labels_url":"https://api.github.com/repos/juju/juju-gui/milestones/16/labels","id":2050413,"number":16,"title":"2.2.2","description":"","creator":{"login":"hatched","id":532033,"avatar_url":"https://avatars.githubusercontent.com/u/532033?v=3","gravatar_id":"","url":"https://api.github.com/users/hatched","html_url":"https://github.com/hatched","followers_url":"https://api.github.com/users/hatched/followers","following_url":"https://api.github.com/users/hatched/following{/other_user}","gists_url":"https://api.github.com/users/hatched/gists{/gist_id}","starred_url":"https://api.github.com/users/hatched/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hatched/subscriptions","organizations_url":"https://api.github.com/users/hatched/orgs","repos_url":"https://api.github.com/users/hatched/repos","events_url":"https://api.github.com/users/hatched/events{/privacy}","received_events_url":"https://api.github.com/users/hatched/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":17,"state":"open","created_at":"2016-10-05T18:31:06Z","updated_at":"2016-10-18T17:44:15Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/juju/juju-gui/pulls/2127/commits","review_comments_url":"https://api.github.com/repos/juju/juju-gui/pulls/2127/comments","review_comment_url":"https://api.github.com/repos/juju/juju-gui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/juju/juju-gui/issues/2127/comments","statuses_url":"https://api.github.com/repos/juju/juju-gui/statuses/2ad4e1414b40b9ae2fb170737d17467f2a626c81","head":{"label":"kadams54:delete-model","ref":"delete-model","sha":"2ad4e1414b40b9ae2fb170737d17467f2a626c81","user":{"login":"kadams54","id":378036,"avatar_url":"https://avatars.githubusercontent.com/u/378036?v=3","gravatar_id":"","url":"https://api.github.com/users/kadams54","html_url":"https://github.com/kadams54","followers_url":"https://api.github.com/users/kadams54/followers","following_url":"https://api.github.com/users/kadams54/following{/other_user}","gists_url":"https://api.github.com/users/kadams54/gists{/gist_id}","starred_url":"https://api.github.com/users/kadams54/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kadams54/subscriptions","organizations_url":"https://api.github.com/users/kadams54/orgs","repos_url":"https://api.github.com/users/kadams54/repos","events_url":"https://api.github.com/users/kadams54/events{/privacy}","received_events_url":"https://api.github.com/users/kadams54/received_events","type":"User","site_admin":false},"repo":{"id":17426336,"name":"juju-gui","full_name":"kadams54/juju-gui","owner":{"login":"kadams54","id":378036,"avatar_url":"https://avatars.githubusercontent.com/u/378036?v=3","gravatar_id":"","url":"https://api.github.com/users/kadams54","html_url":"https://github.com/kadams54","followers_url":"https://api.github.com/users/kadams54/followers","following_url":"https://api.github.com/users/kadams54/following{/other_user}","gists_url":"https://api.github.com/users/kadams54/gists{/gist_id}","starred_url":"https://api.github.com/users/kadams54/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kadams54/subscriptions","organizations_url":"https://api.github.com/users/kadams54/orgs","repos_url":"https://api.github.com/users/kadams54/repos","events_url":"https://api.github.com/users/kadams54/events{/privacy}","received_events_url":"https://api.github.com/users/kadams54/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kadams54/juju-gui","description":"Juju-GUI is a web-based GUI for Juju <https://juju.ubuntu.com/>.","fork":true,"url":"https://api.github.com/repos/kadams54/juju-gui","forks_url":"https://api.github.com/repos/kadams54/juju-gui/forks","keys_url":"https://api.github.com/repos/kadams54/juju-gui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kadams54/juju-gui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kadams54/juju-gui/teams","hooks_url":"https://api.github.com/repos/kadams54/juju-gui/hooks","issue_events_url":"https://api.github.com/repos/kadams54/juju-gui/issues/events{/number}","events_url":"https://api.github.com/repos/kadams54/juju-gui/events","assignees_url":"https://api.github.com/repos/kadams54/juju-gui/assignees{/user}","branches_url":"https://api.github.com/repos/kadams54/juju-gui/branches{/branch}","tags_url":"https://api.github.com/repos/kadams54/juju-gui/tags","blobs_url":"https://api.github.com/repos/kadams54/juju-gui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kadams54/juju-gui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kadams54/juju-gui/git/refs{/sha}","trees_url":"https://api.github.com/repos/kadams54/juju-gui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kadams54/juju-gui/statuses/{sha}","languages_url":"https://api.github.com/repos/kadams54/juju-gui/languages","stargazers_url":"https://api.github.com/repos/kadams54/juju-gui/stargazers","contributors_url":"https://api.github.com/repos/kadams54/juju-gui/contributors","subscribers_url":"https://api.github.com/repos/kadams54/juju-gui/subscribers","subscription_url":"https://api.github.com/repos/kadams54/juju-gui/subscription","commits_url":"https://api.github.com/repos/kadams54/juju-gui/commits{/sha}","git_commits_url":"https://api.github.com/repos/kadams54/juju-gui/git/commits{/sha}","comments_url":"https://api.github.com/repos/kadams54/juju-gui/comments{/number}","issue_comment_url":"https://api.github.com/repos/kadams54/juju-gui/issues/comments{/number}","contents_url":"https://api.github.com/repos/kadams54/juju-gui/contents/{+path}","compare_url":"https://api.github.com/repos/kadams54/juju-gui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kadams54/juju-gui/merges","archive_url":"https://api.github.com/repos/kadams54/juju-gui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kadams54/juju-gui/downloads","issues_url":"https://api.github.com/repos/kadams54/juju-gui/issues{/number}","pulls_url":"https://api.github.com/repos/kadams54/juju-gui/pulls{/number}","milestones_url":"https://api.github.com/repos/kadams54/juju-gui/milestones{/number}","notifications_url":"https://api.github.com/repos/kadams54/juju-gui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kadams54/juju-gui/labels{/name}","releases_url":"https://api.github.com/repos/kadams54/juju-gui/releases{/id}","deployments_url":"https://api.github.com/repos/kadams54/juju-gui/deployments","created_at":"2014-03-05T03:12:51Z","updated_at":"2016-01-11T14:41:14Z","pushed_at":"2016-10-18T18:04:17Z","git_url":"git://github.com/kadams54/juju-gui.git","ssh_url":"git@github.com:kadams54/juju-gui.git","clone_url":"https://github.com/kadams54/juju-gui.git","svn_url":"https://github.com/kadams54/juju-gui","homepage":null,"size":118737,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"juju:develop","ref":"develop","sha":"43bfde68c8a00540eb7fad93d1be993ee062e905","user":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?v=3","gravatar_id":"","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"repo":{"id":14960387,"name":"juju-gui","full_name":"juju/juju-gui","owner":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?v=3","gravatar_id":"","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/juju/juju-gui","description":"Juju-GUI is a web-based GUI for Juju <https://jujucharms.com/>.","fork":false,"url":"https://api.github.com/repos/juju/juju-gui","forks_url":"https://api.github.com/repos/juju/juju-gui/forks","keys_url":"https://api.github.com/repos/juju/juju-gui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juju/juju-gui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juju/juju-gui/teams","hooks_url":"https://api.github.com/repos/juju/juju-gui/hooks","issue_events_url":"https://api.github.com/repos/juju/juju-gui/issues/events{/number}","events_url":"https://api.github.com/repos/juju/juju-gui/events","assignees_url":"https://api.github.com/repos/juju/juju-gui/assignees{/user}","branches_url":"https://api.github.com/repos/juju/juju-gui/branches{/branch}","tags_url":"https://api.github.com/repos/juju/juju-gui/tags","blobs_url":"https://api.github.com/repos/juju/juju-gui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juju/juju-gui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juju/juju-gui/git/refs{/sha}","trees_url":"https://api.github.com/repos/juju/juju-gui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juju/juju-gui/statuses/{sha}","languages_url":"https://api.github.com/repos/juju/juju-gui/languages","stargazers_url":"https://api.github.com/repos/juju/juju-gui/stargazers","contributors_url":"https://api.github.com/repos/juju/juju-gui/contributors","subscribers_url":"https://api.github.com/repos/juju/juju-gui/subscribers","subscription_url":"https://api.github.com/repos/juju/juju-gui/subscription","commits_url":"https://api.github.com/repos/juju/juju-gui/commits{/sha}","git_commits_url":"https://api.github.com/repos/juju/juju-gui/git/commits{/sha}","comments_url":"https://api.github.com/repos/juju/juju-gui/comments{/number}","issue_comment_url":"https://api.github.com/repos/juju/juju-gui/issues/comments{/number}","contents_url":"https://api.github.com/repos/juju/juju-gui/contents/{+path}","compare_url":"https://api.github.com/repos/juju/juju-gui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juju/juju-gui/merges","archive_url":"https://api.github.com/repos/juju/juju-gui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juju/juju-gui/downloads","issues_url":"https://api.github.com/repos/juju/juju-gui/issues{/number}","pulls_url":"https://api.github.com/repos/juju/juju-gui/pulls{/number}","milestones_url":"https://api.github.com/repos/juju/juju-gui/milestones{/number}","notifications_url":"https://api.github.com/repos/juju/juju-gui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juju/juju-gui/labels{/name}","releases_url":"https://api.github.com/repos/juju/juju-gui/releases{/id}","deployments_url":"https://api.github.com/repos/juju/juju-gui/deployments","created_at":"2013-12-05T17:15:48Z","updated_at":"2016-10-04T11:38:19Z","pushed_at":"2016-10-18T18:04:17Z","git_url":"git://github.com/juju/juju-gui.git","ssh_url":"git@github.com:juju/juju-gui.git","clone_url":"https://github.com/juju/juju-gui.git","svn_url":"https://github.com/juju/juju-gui","homepage":"","size":123199,"stargazers_count":101,"watchers_count":101,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":57,"mirror_url":null,"open_issues_count":100,"forks":57,"open_issues":100,"watchers":101,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/juju/juju-gui/pulls/2127"},"html":{"href":"https://github.com/juju/juju-gui/pull/2127"},"issue":{"href":"https://api.github.com/repos/juju/juju-gui/issues/2127"},"comments":{"href":"https://api.github.com/repos/juju/juju-gui/issues/2127/comments"},"review_comments":{"href":"https://api.github.com/repos/juju/juju-gui/pulls/2127/comments"},"review_comment":{"href":"https://api.github.com/repos/juju/juju-gui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/juju/juju-gui/pulls/2127/commits"},"statuses":{"href":"https://api.github.com/repos/juju/juju-gui/statuses/2ad4e1414b40b9ae2fb170737d17467f2a626c81"}}}}
{"actor":{"display_login":"hatched"}}