{"action":"created","comment":{"url":"https://api.github.com/repos/DataBiosphere/leonardo/pulls/comments/185163656","pull_request_review_id":116498664,"id":185163656,"diff_hunk":"@@ -0,0 +1,112 @@\n+import React from 'react';\n+import Button from 'material-ui/Button';\n+import Dialog, {\n+  DialogActions,\n+  DialogContent,\n+  DialogContentText,\n+  DialogTitle,\n+} from 'material-ui/Dialog';\n+\n+import { createApiUrl } from '../net'\n+\n+\n+// List of status that disallow deletion.\n+const deletedStatus = [\"Deleting\", \"Deleted\"];\n+\n+\n+/**\n+ * Provide a button to delete the cluster featuring a confirmation dialog\n+ * to prevent accidential deletion.\n+ * @props clusterStatus string of cluster status.\n+ * @props errorHandler function callback to display errors.\n+ * @props cardClusterDeleteCallback function callback to update card state\n+          so that the cluster shows as deleting.\n+ * @props googleAuthToken string access token provided by oauth login.\n+ * @props clusterModel object with cluster information from Leonardo service.\n+ */\n+class DeleteDialog extends React.Component {\n+\n+  constructor(props) {\n+    super(props);\n+    this.state = {\n+      open: false,\n+    };\n+  }\n+\n+  handleClickOpen = () => {\n+    this.setState({ open: true });\n+  }\n+\n+  handleClose = () => {\n+    this.setState({ open: false });\n+  }\n+\n+  handleDeleteConfirm = () => {\n+    var model = this.props.clusterModel;\n+    fetch(\n+      createApiUrl(model.googleProject, model.clusterName),\n+      {\n+        method: \"DELETE\",\n+        headers: {\n+          \"Authorization\": \"Bearer \" + this.props.googleAuthToken,\n+          \"content-type\": \"application/json\"\n+        },\n+        credentials: \"include\"\n+      }\n+    )\n+    // Validate response status.\n+    .then((response) => {\n+      if (response.status < 200 || response.status >= 300) {\n+        console.log(response);\n+        throw new Error(\"Fetch failed: status=\" + response.status.toString());\n+      }\n+      return response;\n+    })\n+    // Run card callback.\n+    .then((response) => {\n+      this.props.cardClusterDeleteCallback();\n+      return response;\n+    })\n+    // Handle any errors.\n+    .catch((error) => this.props.errorHandler(error.toString()));\n+    this.handleClose()\n+  }\n+\n+  render() {\n+    if (deletedStatus.indexOf(this.props.clusterStatus) > -1) {\n+      return <Button disabled size=\"medium\">Delete Instance</Button>;\n+    }\n+    return (\n+      <div>\n+        <Button\n+          size=\"medium\" \n+          onClick={this.handleClickOpen}>\n+          Delete Instance\n+        </Button>\n+        <Dialog\n+          open={this.state.open}\n+          onClose={this.handleClose}\n+          aria-labelledby=\"alert-dialog-title\"\n+          aria-describedby=\"alert-dialog-description\"\n+        >\n+          <DialogTitle id=\"alert-dialog-title\">{\"Delete Instance?\"}</DialogTitle>\n+          <DialogContent>\n+            <DialogContentText id=\"alert-dialog-description\">\n+              Are you sure you want to delete this instance? You cannot undo this operation.\n+            </DialogContentText>\n+          </DialogContent>\n+          <DialogActions>\n+            <Button onClick={this.handleClose} color=\"primary\" autoFocus>\n+              No, don't delete!","path":"ui/src/components/DeleteDialog.js","position":100,"original_position":100,"commit_id":"2c01f70046e6f280c62a912b80235c9c35b3aa89","original_commit_id":"2c01f70046e6f280c62a912b80235c9c35b3aa89","user":{"login":"eap","id":11793462,"avatar_url":"https://avatars0.githubusercontent.com/u/11793462?v=4","gravatar_id":"","url":"https://api.github.com/users/eap","html_url":"https://github.com/eap","followers_url":"https://api.github.com/users/eap/followers","following_url":"https://api.github.com/users/eap/following{/other_user}","gists_url":"https://api.github.com/users/eap/gists{/gist_id}","starred_url":"https://api.github.com/users/eap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eap/subscriptions","organizations_url":"https://api.github.com/users/eap/orgs","repos_url":"https://api.github.com/users/eap/repos","events_url":"https://api.github.com/users/eap/events{/privacy}","received_events_url":"https://api.github.com/users/eap/received_events","type":"User","site_admin":false},"body":"It's probably an issue of react's JSX mini-language not being handled correctly. It seems to have mostly rendered fine but this case of text literals wrapped by xml tags is valid JSX, but the single-quote seems to have mislead github's formatter.","created_at":"2018-05-01T04:10:30Z","updated_at":"2018-05-01T04:10:30Z","html_url":"https://github.com/DataBiosphere/leonardo/pull/328#discussion_r185163656","pull_request_url":"https://api.github.com/repos/DataBiosphere/leonardo/pulls/328","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/DataBiosphere/leonardo/pulls/comments/185163656"},"html":{"href":"https://github.com/DataBiosphere/leonardo/pull/328#discussion_r185163656"},"pull_request":{"href":"https://api.github.com/repos/DataBiosphere/leonardo/pulls/328"}},"in_reply_to_id":185155734},"pull_request":{"url":"https://api.github.com/repos/DataBiosphere/leonardo/pulls/328","id":183134900,"html_url":"https://github.com/DataBiosphere/leonardo/pull/328","diff_url":"https://github.com/DataBiosphere/leonardo/pull/328.diff","patch_url":"https://github.com/DataBiosphere/leonardo/pull/328.patch","issue_url":"https://api.github.com/repos/DataBiosphere/leonardo/issues/328","number":328,"state":"open","locked":false,"title":"User Interface: cluster delete button & dialog.","user":{"login":"eap","id":11793462,"avatar_url":"https://avatars0.githubusercontent.com/u/11793462?v=4","gravatar_id":"","url":"https://api.github.com/users/eap","html_url":"https://github.com/eap","followers_url":"https://api.github.com/users/eap/followers","following_url":"https://api.github.com/users/eap/following{/other_user}","gists_url":"https://api.github.com/users/eap/gists{/gist_id}","starred_url":"https://api.github.com/users/eap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eap/subscriptions","organizations_url":"https://api.github.com/users/eap/orgs","repos_url":"https://api.github.com/users/eap/repos","events_url":"https://api.github.com/users/eap/events{/privacy}","received_events_url":"https://api.github.com/users/eap/received_events","type":"User","site_admin":false},"body":"This change adds a delete button to each cluster card. The button will create a confirmation dialog when clicked. Once confirmed, a delete request is sent. On success, the cluster's status is manually set to \"Deleting\".\r\n\r\nSee the new component in action [here](https://docs.google.com/document/d/1dcN4Edbuiny8e9CIEp4KrY5AZGIT9ULWAuHM78BrdkA)\r\n\r\nIn all cases:\r\n\r\n- [ ] Get two thumbsworth of review and PO signoff if necessary\r\n- [ ] Squash and merge; you can delete your branch after this\r\n- [ ] Test this change deployed correctly and works on dev environment after deployment\r\n","created_at":"2018-04-20T18:16:49Z","updated_at":"2018-05-01T04:10:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"084bc35c491f0241961d66ff761c14f6f1dfeb93","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/DataBiosphere/leonardo/pulls/328/commits","review_comments_url":"https://api.github.com/repos/DataBiosphere/leonardo/pulls/328/comments","review_comment_url":"https://api.github.com/repos/DataBiosphere/leonardo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DataBiosphere/leonardo/issues/328/comments","statuses_url":"https://api.github.com/repos/DataBiosphere/leonardo/statuses/2c01f70046e6f280c62a912b80235c9c35b3aa89","head":{"label":"eap:user-interface-delete","ref":"user-interface-delete","sha":"2c01f70046e6f280c62a912b80235c9c35b3aa89","user":{"login":"eap","id":11793462,"avatar_url":"https://avatars0.githubusercontent.com/u/11793462?v=4","gravatar_id":"","url":"https://api.github.com/users/eap","html_url":"https://github.com/eap","followers_url":"https://api.github.com/users/eap/followers","following_url":"https://api.github.com/users/eap/following{/other_user}","gists_url":"https://api.github.com/users/eap/gists{/gist_id}","starred_url":"https://api.github.com/users/eap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eap/subscriptions","organizations_url":"https://api.github.com/users/eap/orgs","repos_url":"https://api.github.com/users/eap/repos","events_url":"https://api.github.com/users/eap/events{/privacy}","received_events_url":"https://api.github.com/users/eap/received_events","type":"User","site_admin":false},"repo":{"id":114945313,"name":"leonardo","full_name":"eap/leonardo","owner":{"login":"eap","id":11793462,"avatar_url":"https://avatars0.githubusercontent.com/u/11793462?v=4","gravatar_id":"","url":"https://api.github.com/users/eap","html_url":"https://github.com/eap","followers_url":"https://api.github.com/users/eap/followers","following_url":"https://api.github.com/users/eap/following{/other_user}","gists_url":"https://api.github.com/users/eap/gists{/gist_id}","starred_url":"https://api.github.com/users/eap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eap/subscriptions","organizations_url":"https://api.github.com/users/eap/orgs","repos_url":"https://api.github.com/users/eap/repos","events_url":"https://api.github.com/users/eap/events{/privacy}","received_events_url":"https://api.github.com/users/eap/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eap/leonardo","description":"Notebook service","fork":true,"url":"https://api.github.com/repos/eap/leonardo","forks_url":"https://api.github.com/repos/eap/leonardo/forks","keys_url":"https://api.github.com/repos/eap/leonardo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eap/leonardo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eap/leonardo/teams","hooks_url":"https://api.github.com/repos/eap/leonardo/hooks","issue_events_url":"https://api.github.com/repos/eap/leonardo/issues/events{/number}","events_url":"https://api.github.com/repos/eap/leonardo/events","assignees_url":"https://api.github.com/repos/eap/leonardo/assignees{/user}","branches_url":"https://api.github.com/repos/eap/leonardo/branches{/branch}","tags_url":"https://api.github.com/repos/eap/leonardo/tags","blobs_url":"https://api.github.com/repos/eap/leonardo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eap/leonardo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eap/leonardo/git/refs{/sha}","trees_url":"https://api.github.com/repos/eap/leonardo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eap/leonardo/statuses/{sha}","languages_url":"https://api.github.com/repos/eap/leonardo/languages","stargazers_url":"https://api.github.com/repos/eap/leonardo/stargazers","contributors_url":"https://api.github.com/repos/eap/leonardo/contributors","subscribers_url":"https://api.github.com/repos/eap/leonardo/subscribers","subscription_url":"https://api.github.com/repos/eap/leonardo/subscription","commits_url":"https://api.github.com/repos/eap/leonardo/commits{/sha}","git_commits_url":"https://api.github.com/repos/eap/leonardo/git/commits{/sha}","comments_url":"https://api.github.com/repos/eap/leonardo/comments{/number}","issue_comment_url":"https://api.github.com/repos/eap/leonardo/issues/comments{/number}","contents_url":"https://api.github.com/repos/eap/leonardo/contents/{+path}","compare_url":"https://api.github.com/repos/eap/leonardo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eap/leonardo/merges","archive_url":"https://api.github.com/repos/eap/leonardo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eap/leonardo/downloads","issues_url":"https://api.github.com/repos/eap/leonardo/issues{/number}","pulls_url":"https://api.github.com/repos/eap/leonardo/pulls{/number}","milestones_url":"https://api.github.com/repos/eap/leonardo/milestones{/number}","notifications_url":"https://api.github.com/repos/eap/leonardo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eap/leonardo/labels{/name}","releases_url":"https://api.github.com/repos/eap/leonardo/releases{/id}","deployments_url":"https://api.github.com/repos/eap/leonardo/deployments","created_at":"2017-12-21T00:50:47Z","updated_at":"2018-04-25T05:02:31Z","pushed_at":"2018-04-25T05:16:58Z","git_url":"git://github.com/eap/leonardo.git","ssh_url":"git@github.com:eap/leonardo.git","clone_url":"https://github.com/eap/leonardo.git","svn_url":"https://github.com/eap/leonardo","homepage":null,"size":1704,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"DataBiosphere:develop","ref":"develop","sha":"00322ec033b6cd1b9eb38ee0568aef207d886796","user":{"login":"DataBiosphere","id":32805087,"avatar_url":"https://avatars0.githubusercontent.com/u/32805087?v=4","gravatar_id":"","url":"https://api.github.com/users/DataBiosphere","html_url":"https://github.com/DataBiosphere","followers_url":"https://api.github.com/users/DataBiosphere/followers","following_url":"https://api.github.com/users/DataBiosphere/following{/other_user}","gists_url":"https://api.github.com/users/DataBiosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/DataBiosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataBiosphere/subscriptions","organizations_url":"https://api.github.com/users/DataBiosphere/orgs","repos_url":"https://api.github.com/users/DataBiosphere/repos","events_url":"https://api.github.com/users/DataBiosphere/events{/privacy}","received_events_url":"https://api.github.com/users/DataBiosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":96942484,"name":"leonardo","full_name":"DataBiosphere/leonardo","owner":{"login":"DataBiosphere","id":32805087,"avatar_url":"https://avatars0.githubusercontent.com/u/32805087?v=4","gravatar_id":"","url":"https://api.github.com/users/DataBiosphere","html_url":"https://github.com/DataBiosphere","followers_url":"https://api.github.com/users/DataBiosphere/followers","following_url":"https://api.github.com/users/DataBiosphere/following{/other_user}","gists_url":"https://api.github.com/users/DataBiosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/DataBiosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataBiosphere/subscriptions","organizations_url":"https://api.github.com/users/DataBiosphere/orgs","repos_url":"https://api.github.com/users/DataBiosphere/repos","events_url":"https://api.github.com/users/DataBiosphere/events{/privacy}","received_events_url":"https://api.github.com/users/DataBiosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DataBiosphere/leonardo","description":"Notebook service","fork":false,"url":"https://api.github.com/repos/DataBiosphere/leonardo","forks_url":"https://api.github.com/repos/DataBiosphere/leonardo/forks","keys_url":"https://api.github.com/repos/DataBiosphere/leonardo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DataBiosphere/leonardo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DataBiosphere/leonardo/teams","hooks_url":"https://api.github.com/repos/DataBiosphere/leonardo/hooks","issue_events_url":"https://api.github.com/repos/DataBiosphere/leonardo/issues/events{/number}","events_url":"https://api.github.com/repos/DataBiosphere/leonardo/events","assignees_url":"https://api.github.com/repos/DataBiosphere/leonardo/assignees{/user}","branches_url":"https://api.github.com/repos/DataBiosphere/leonardo/branches{/branch}","tags_url":"https://api.github.com/repos/DataBiosphere/leonardo/tags","blobs_url":"https://api.github.com/repos/DataBiosphere/leonardo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DataBiosphere/leonardo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DataBiosphere/leonardo/git/refs{/sha}","trees_url":"https://api.github.com/repos/DataBiosphere/leonardo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DataBiosphere/leonardo/statuses/{sha}","languages_url":"https://api.github.com/repos/DataBiosphere/leonardo/languages","stargazers_url":"https://api.github.com/repos/DataBiosphere/leonardo/stargazers","contributors_url":"https://api.github.com/repos/DataBiosphere/leonardo/contributors","subscribers_url":"https://api.github.com/repos/DataBiosphere/leonardo/subscribers","subscription_url":"https://api.github.com/repos/DataBiosphere/leonardo/subscription","commits_url":"https://api.github.com/repos/DataBiosphere/leonardo/commits{/sha}","git_commits_url":"https://api.github.com/repos/DataBiosphere/leonardo/git/commits{/sha}","comments_url":"https://api.github.com/repos/DataBiosphere/leonardo/comments{/number}","issue_comment_url":"https://api.github.com/repos/DataBiosphere/leonardo/issues/comments{/number}","contents_url":"https://api.github.com/repos/DataBiosphere/leonardo/contents/{+path}","compare_url":"https://api.github.com/repos/DataBiosphere/leonardo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DataBiosphere/leonardo/merges","archive_url":"https://api.github.com/repos/DataBiosphere/leonardo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DataBiosphere/leonardo/downloads","issues_url":"https://api.github.com/repos/DataBiosphere/leonardo/issues{/number}","pulls_url":"https://api.github.com/repos/DataBiosphere/leonardo/pulls{/number}","milestones_url":"https://api.github.com/repos/DataBiosphere/leonardo/milestones{/number}","notifications_url":"https://api.github.com/repos/DataBiosphere/leonardo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DataBiosphere/leonardo/labels{/name}","releases_url":"https://api.github.com/repos/DataBiosphere/leonardo/releases{/id}","deployments_url":"https://api.github.com/repos/DataBiosphere/leonardo/deployments","created_at":"2017-07-11T22:29:16Z","updated_at":"2018-05-01T00:39:51Z","pushed_at":"2018-05-01T00:40:21Z","git_url":"git://github.com/DataBiosphere/leonardo.git","ssh_url":"git@github.com:DataBiosphere/leonardo.git","clone_url":"https://github.com/DataBiosphere/leonardo.git","svn_url":"https://github.com/DataBiosphere/leonardo","homepage":null,"size":1815,"stargazers_count":4,"watchers_count":4,"language":"Scala","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":66,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":4,"open_issues":66,"watchers":4,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/DataBiosphere/leonardo/pulls/328"},"html":{"href":"https://github.com/DataBiosphere/leonardo/pull/328"},"issue":{"href":"https://api.github.com/repos/DataBiosphere/leonardo/issues/328"},"comments":{"href":"https://api.github.com/repos/DataBiosphere/leonardo/issues/328/comments"},"review_comments":{"href":"https://api.github.com/repos/DataBiosphere/leonardo/pulls/328/comments"},"review_comment":{"href":"https://api.github.com/repos/DataBiosphere/leonardo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DataBiosphere/leonardo/pulls/328/commits"},"statuses":{"href":"https://api.github.com/repos/DataBiosphere/leonardo/statuses/2c01f70046e6f280c62a912b80235c9c35b3aa89"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"eap"}}