{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/console/pulls/comments/237649164","pull_request_review_id":179991760,"id":237649164,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNzY0OTE2NA==","diff_hunk":"@@ -0,0 +1,206 @@\n+/* eslint-disable no-undef, no-unused-vars */\n+import * as _ from 'lodash-es';\n+import * as React from 'react';\n+import * as fuzzy from 'fuzzysearch';\n+\n+import { Firehose, LoadingInline, Dropdown, ResourceName, ResourceIcon } from '.';\n+\n+/* Component StorageClassDropdown - creates a dropdown list of storage classes */\n+\n+class StorageClassDropdown_ extends React.Component<StorageClassDropdownProps, StorageClassDropdownState> {\n+    state = {\n+      items: {},\n+      name: this.props.name,\n+      selectedKey: null,\n+      title: <LoadingInline />,\n+      defaultClass: null,\n+    };\n+\n+    componentWillMount() {\n+      this.componentWillReceiveProps(this.props);\n+    }\n+\n+    componentWillReceiveProps(nextProps) {\n+      const { loaded, loadError, resources } = nextProps;\n+\n+      if (loadError) {\n+        this.setState({\n+          title: (\n+            <div className=\"cos-error-title\">Error Loading {nextProps.desc}</div>\n+          ),\n+        });\n+        return;\n+      }\n+      if (!loaded) {\n+        return;\n+      }\n+\n+      const state = {\n+        items: {},\n+        title: {},\n+        defaultClass: '',\n+      };\n+      const unorderedItems = {};\n+      const noStorageClass = 'No storage class';\n+      _.each(resources, ({ data }, kindLabel) => {\n+        _.reduce(\n+          data,\n+          (acc, resource) => {\n+            acc[resource.metadata.name] = {\n+              kindLabel,\n+              name: resource.metadata.name,\n+              description: resource.metadata.annotations ? resource.metadata.annotations.description : '',\n+              default: resource.metadata.annotations ? resource.metadata.annotations['storageclass.kubernetes.io/is-default-class'] === 'true' ? true : false : '',\n+              accessMode: resource.metadata.annotations ? resource.metadata.annotations['storage.alpha.openshift.io/access-mode'] : '',\n+              provisioner: resource.provisioner,\n+              type: resource.parameters ? resource.parameters.type : '',\n+              zone: resource.parameters ? resource.parameters.zone : '',\n+            };\n+            return acc;\n+          },\n+          unorderedItems\n+        );\n+      });\n+\n+      // Determine if there is a default storage class\n+      _.each(unorderedItems, (item, name) => {\n+        if ((item as any).default) {\n+          state.defaultClass = name;\n+        }\n+      });\n+      const { selectedKey } = this.state;\n+      if (!state.defaultClass) {\n+        // Add No Storage Class option if there is not a default storage class\n+        unorderedItems[''] = { kindLabel: '', name: noStorageClass };\n+      }\n+\n+      if (!this.props.loaded || !selectedKey ) {\n+        state.title = <span className=\"text-muted\">{nextProps.placeholder}</span>;\n+      }\n+\n+      if (selectedKey) {\n+        const item = unorderedItems[selectedKey];\n+        if (item) {\n+          state.title = this.getTitle(item.kindLabel, item.name);\n+        }\n+      }\n+\n+      if (!selectedKey && state.defaultClass) {\n+        const item = unorderedItems[state.defaultClass];\n+        if (item) {\n+          state.title = this.getTitle(item.kindLabel, item.name);\n+        }\n+      }\n+\n+      Object.keys(unorderedItems).sort().forEach(function(key) {\n+        state.items[key] = unorderedItems[key];\n+      });\n+      this.setState(state);\n+    }\n+\n+    componentDidUpdate() {\n+      const {defaultClass, selectedKey } = this.state;\n+      if (!selectedKey && defaultClass) {\n+        this.onChange(defaultClass);\n+      }\n+    }\n+\n+    shouldComponentUpdate(nextProps, nextState) {\n+      return !_.isEqual(this.state, nextState);\n+    }\n+\n+    autocompleteFilter = (text, item) => fuzzy(text, item.props.name);\n+\n+    getTitle = (kindLabel, name) => {\n+      return kindLabel ? <ResourceName kind=\"StorageClass\" name={name} /> : <span >{name}</span>;\n+    }\n+\n+    onChange = key => {\n+      const { name, kindLabel, accessMode } = _.get(this.state, ['items', key], {});\n+      this.setState({\n+        selectedKey: key,\n+        title: this.getTitle(kindLabel, name),\n+      });\n+      this.props.onChange(key, accessMode);\n+    };\n+\n+    render() {\n+      const { placeholder, id, loaded } = this.props;\n+      const items = {};\n+      _.each(\n+        this.state.items,\n+        (props, key) =>\n+          (items[key] = key ? <StorageClassDropdownEntry {...props} /> : <StorageClassDropdownNoStorageClassOption {...props} />)\n+      );\n+\n+      const { selectedKey, defaultClass } = this.state;\n+\n+      const Component = <Dropdown\n+        autocompleteFilter={this.autocompleteFilter}\n+        autocompletePlaceholder={placeholder}\n+        items={items}\n+        selectedKey={selectedKey}\n+        title={this.state.title}\n+        onChange={this.onChange}\n+        id={id}\n+        menuClassName=\"dropdown-menu--text-wrap\"\n+      />;\n+      // Only show the dropdown if 'no storage class' is not the only option which depends on defaultClass\n+      const itemsAvailableToShow = (_.size(items)>1 && !defaultClass) || (_.size(items)>0 && defaultClass);\n+      const helpMes = defaultClass ? `Default storage class ${defaultClass} will be used if no other storage class selected.` : 'Optional storage class for the new claim.';","path":"frontend/public/components/utils/storage-class-dropdown.tsx","position":150,"original_position":150,"commit_id":"4c9bc44dcc2e711492fccfbdf61820781a37337a","original_commit_id":"4c9bc44dcc2e711492fccfbdf61820781a37337a","user":{"login":"spadgett","id":1167259,"node_id":"MDQ6VXNlcjExNjcyNTk=","avatar_url":"https://avatars1.githubusercontent.com/u/1167259?v=4","gravatar_id":"","url":"https://api.github.com/users/spadgett","html_url":"https://github.com/spadgett","followers_url":"https://api.github.com/users/spadgett/followers","following_url":"https://api.github.com/users/spadgett/following{/other_user}","gists_url":"https://api.github.com/users/spadgett/gists{/gist_id}","starred_url":"https://api.github.com/users/spadgett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spadgett/subscriptions","organizations_url":"https://api.github.com/users/spadgett/orgs","repos_url":"https://api.github.com/users/spadgett/repos","events_url":"https://api.github.com/users/spadgett/events{/privacy}","received_events_url":"https://api.github.com/users/spadgett/received_events","type":"User","site_admin":false},"body":"If we're preselecting the default class and we force a selection, do we need to \"default storage class will be used...\" message?","created_at":"2018-11-29T20:36:06Z","updated_at":"2018-11-29T20:50:41Z","html_url":"https://github.com/openshift/console/pull/812#discussion_r237649164","pull_request_url":"https://api.github.com/repos/openshift/console/pulls/812","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/openshift/console/pulls/comments/237649164"},"html":{"href":"https://github.com/openshift/console/pull/812#discussion_r237649164"},"pull_request":{"href":"https://api.github.com/repos/openshift/console/pulls/812"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/console/pulls/812","id":230944381,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMwOTQ0Mzgx","html_url":"https://github.com/openshift/console/pull/812","diff_url":"https://github.com/openshift/console/pull/812.diff","patch_url":"https://github.com/openshift/console/pull/812.patch","issue_url":"https://api.github.com/repos/openshift/console/issues/812","number":812,"state":"open","locked":false,"title":"Update Create PVC form with UXD suggested changes","user":{"login":"zherman0","id":18728857,"node_id":"MDQ6VXNlcjE4NzI4ODU3","avatar_url":"https://avatars0.githubusercontent.com/u/18728857?v=4","gravatar_id":"","url":"https://api.github.com/users/zherman0","html_url":"https://github.com/zherman0","followers_url":"https://api.github.com/users/zherman0/followers","following_url":"https://api.github.com/users/zherman0/following{/other_user}","gists_url":"https://api.github.com/users/zherman0/gists{/gist_id}","starred_url":"https://api.github.com/users/zherman0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zherman0/subscriptions","organizations_url":"https://api.github.com/users/zherman0/orgs","repos_url":"https://api.github.com/users/zherman0/repos","events_url":"https://api.github.com/users/zherman0/events{/privacy}","received_events_url":"https://api.github.com/users/zherman0/received_events","type":"User","site_admin":false},"body":"We have some feedback on how to make the Create PVC form better and this change addresses that:\r\n1) Change name from Create Storage to Create Persistent Volume Claim\r\n2) Add more details about the storage classes in the dropdown selector (this required creating new dropdown component)\r\n![updated-dropdown](https://user-images.githubusercontent.com/18728857/48576047-befea080-e8d0-11e8-93bf-3ca79d7ca568.png)\r\n\r\n3) Disable radio buttons if storage class is selected that has accessMode defined\r\n(Note: Hard to see that the radios are disabled in picture below, but they are with the storage class's accessMode selected)\r\n![sc-with-accessmode-disabled-radio](https://user-images.githubusercontent.com/18728857/48576094-e05f8c80-e8d0-11e8-9065-da3161e3cdf2.png)\r\n\r\n4) Added default storage class handling.  The default storage class is identified as \"(default)\" in the dropdown.  Also, we update the help message.  \r\n![default-sc](https://user-images.githubusercontent.com/18728857/48581579-78647280-e8df-11e8-9c5c-3259f62d121f.png)\r\n![default-sc-help-msg](https://user-images.githubusercontent.com/18728857/48581585-7bf7f980-e8df-11e8-9614-dde67a1d90af.png)\r\n","created_at":"2018-11-14T18:55:31Z","updated_at":"2018-11-29T20:50:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1cd87552d0582de7a0ec135cca7ddb1d3d70be9f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":926924366,"node_id":"MDU6TGFiZWw5MjY5MjQzNjY=","url":"https://api.github.com/repos/openshift/console/labels/size/L","name":"size/L","color":"ee9900","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/openshift/console/pulls/812/commits","review_comments_url":"https://api.github.com/repos/openshift/console/pulls/812/comments","review_comment_url":"https://api.github.com/repos/openshift/console/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/console/issues/812/comments","statuses_url":"https://api.github.com/repos/openshift/console/statuses/4c9bc44dcc2e711492fccfbdf61820781a37337a","head":{"label":"zherman0:con1001","ref":"con1001","sha":"4c9bc44dcc2e711492fccfbdf61820781a37337a","user":{"login":"zherman0","id":18728857,"node_id":"MDQ6VXNlcjE4NzI4ODU3","avatar_url":"https://avatars0.githubusercontent.com/u/18728857?v=4","gravatar_id":"","url":"https://api.github.com/users/zherman0","html_url":"https://github.com/zherman0","followers_url":"https://api.github.com/users/zherman0/followers","following_url":"https://api.github.com/users/zherman0/following{/other_user}","gists_url":"https://api.github.com/users/zherman0/gists{/gist_id}","starred_url":"https://api.github.com/users/zherman0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zherman0/subscriptions","organizations_url":"https://api.github.com/users/zherman0/orgs","repos_url":"https://api.github.com/users/zherman0/repos","events_url":"https://api.github.com/users/zherman0/events{/privacy}","received_events_url":"https://api.github.com/users/zherman0/received_events","type":"User","site_admin":false},"repo":{"id":140342837,"node_id":"MDEwOlJlcG9zaXRvcnkxNDAzNDI4Mzc=","name":"console","full_name":"zherman0/console","private":false,"owner":{"login":"zherman0","id":18728857,"node_id":"MDQ6VXNlcjE4NzI4ODU3","avatar_url":"https://avatars0.githubusercontent.com/u/18728857?v=4","gravatar_id":"","url":"https://api.github.com/users/zherman0","html_url":"https://github.com/zherman0","followers_url":"https://api.github.com/users/zherman0/followers","following_url":"https://api.github.com/users/zherman0/following{/other_user}","gists_url":"https://api.github.com/users/zherman0/gists{/gist_id}","starred_url":"https://api.github.com/users/zherman0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zherman0/subscriptions","organizations_url":"https://api.github.com/users/zherman0/orgs","repos_url":"https://api.github.com/users/zherman0/repos","events_url":"https://api.github.com/users/zherman0/events{/privacy}","received_events_url":"https://api.github.com/users/zherman0/received_events","type":"User","site_admin":false},"html_url":"https://github.com/zherman0/console","description":"OpenShift Cluster Console UI","fork":true,"url":"https://api.github.com/repos/zherman0/console","forks_url":"https://api.github.com/repos/zherman0/console/forks","keys_url":"https://api.github.com/repos/zherman0/console/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zherman0/console/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zherman0/console/teams","hooks_url":"https://api.github.com/repos/zherman0/console/hooks","issue_events_url":"https://api.github.com/repos/zherman0/console/issues/events{/number}","events_url":"https://api.github.com/repos/zherman0/console/events","assignees_url":"https://api.github.com/repos/zherman0/console/assignees{/user}","branches_url":"https://api.github.com/repos/zherman0/console/branches{/branch}","tags_url":"https://api.github.com/repos/zherman0/console/tags","blobs_url":"https://api.github.com/repos/zherman0/console/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zherman0/console/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zherman0/console/git/refs{/sha}","trees_url":"https://api.github.com/repos/zherman0/console/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zherman0/console/statuses/{sha}","languages_url":"https://api.github.com/repos/zherman0/console/languages","stargazers_url":"https://api.github.com/repos/zherman0/console/stargazers","contributors_url":"https://api.github.com/repos/zherman0/console/contributors","subscribers_url":"https://api.github.com/repos/zherman0/console/subscribers","subscription_url":"https://api.github.com/repos/zherman0/console/subscription","commits_url":"https://api.github.com/repos/zherman0/console/commits{/sha}","git_commits_url":"https://api.github.com/repos/zherman0/console/git/commits{/sha}","comments_url":"https://api.github.com/repos/zherman0/console/comments{/number}","issue_comment_url":"https://api.github.com/repos/zherman0/console/issues/comments{/number}","contents_url":"https://api.github.com/repos/zherman0/console/contents/{+path}","compare_url":"https://api.github.com/repos/zherman0/console/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zherman0/console/merges","archive_url":"https://api.github.com/repos/zherman0/console/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zherman0/console/downloads","issues_url":"https://api.github.com/repos/zherman0/console/issues{/number}","pulls_url":"https://api.github.com/repos/zherman0/console/pulls{/number}","milestones_url":"https://api.github.com/repos/zherman0/console/milestones{/number}","notifications_url":"https://api.github.com/repos/zherman0/console/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zherman0/console/labels{/name}","releases_url":"https://api.github.com/repos/zherman0/console/releases{/id}","deployments_url":"https://api.github.com/repos/zherman0/console/deployments","created_at":"2018-07-09T21:14:08Z","updated_at":"2018-11-26T22:27:00Z","pushed_at":"2018-11-28T20:50:13Z","git_url":"git://github.com/zherman0/console.git","ssh_url":"git@github.com:zherman0/console.git","clone_url":"https://github.com/zherman0/console.git","svn_url":"https://github.com/zherman0/console","homepage":"https://www.openshift.org","size":89203,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openshift:master","ref":"master","sha":"1cc44feea4c72a5ee5e954dc9f3d8f1d30dff07c","user":{"login":"openshift","id":792337,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc5MjMzNw==","avatar_url":"https://avatars3.githubusercontent.com/u/792337?v=4","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"repo":{"id":129436456,"node_id":"MDEwOlJlcG9zaXRvcnkxMjk0MzY0NTY=","name":"console","full_name":"openshift/console","private":false,"owner":{"login":"openshift","id":792337,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc5MjMzNw==","avatar_url":"https://avatars3.githubusercontent.com/u/792337?v=4","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/openshift/console","description":"OpenShift Cluster Console UI","fork":false,"url":"https://api.github.com/repos/openshift/console","forks_url":"https://api.github.com/repos/openshift/console/forks","keys_url":"https://api.github.com/repos/openshift/console/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openshift/console/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openshift/console/teams","hooks_url":"https://api.github.com/repos/openshift/console/hooks","issue_events_url":"https://api.github.com/repos/openshift/console/issues/events{/number}","events_url":"https://api.github.com/repos/openshift/console/events","assignees_url":"https://api.github.com/repos/openshift/console/assignees{/user}","branches_url":"https://api.github.com/repos/openshift/console/branches{/branch}","tags_url":"https://api.github.com/repos/openshift/console/tags","blobs_url":"https://api.github.com/repos/openshift/console/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openshift/console/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openshift/console/git/refs{/sha}","trees_url":"https://api.github.com/repos/openshift/console/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openshift/console/statuses/{sha}","languages_url":"https://api.github.com/repos/openshift/console/languages","stargazers_url":"https://api.github.com/repos/openshift/console/stargazers","contributors_url":"https://api.github.com/repos/openshift/console/contributors","subscribers_url":"https://api.github.com/repos/openshift/console/subscribers","subscription_url":"https://api.github.com/repos/openshift/console/subscription","commits_url":"https://api.github.com/repos/openshift/console/commits{/sha}","git_commits_url":"https://api.github.com/repos/openshift/console/git/commits{/sha}","comments_url":"https://api.github.com/repos/openshift/console/comments{/number}","issue_comment_url":"https://api.github.com/repos/openshift/console/issues/comments{/number}","contents_url":"https://api.github.com/repos/openshift/console/contents/{+path}","compare_url":"https://api.github.com/repos/openshift/console/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openshift/console/merges","archive_url":"https://api.github.com/repos/openshift/console/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openshift/console/downloads","issues_url":"https://api.github.com/repos/openshift/console/issues{/number}","pulls_url":"https://api.github.com/repos/openshift/console/pulls{/number}","milestones_url":"https://api.github.com/repos/openshift/console/milestones{/number}","notifications_url":"https://api.github.com/repos/openshift/console/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openshift/console/labels{/name}","releases_url":"https://api.github.com/repos/openshift/console/releases{/id}","deployments_url":"https://api.github.com/repos/openshift/console/deployments","created_at":"2018-04-13T17:54:59Z","updated_at":"2018-11-29T20:45:30Z","pushed_at":"2018-11-29T20:45:25Z","git_url":"git://github.com/openshift/console.git","ssh_url":"git@github.com:openshift/console.git","clone_url":"https://github.com/openshift/console.git","svn_url":"https://github.com/openshift/console","homepage":"https://www.openshift.org","size":89383,"stargazers_count":34,"watchers_count":34,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":49,"mirror_url":null,"archived":false,"open_issues_count":38,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":49,"open_issues":38,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/console/pulls/812"},"html":{"href":"https://github.com/openshift/console/pull/812"},"issue":{"href":"https://api.github.com/repos/openshift/console/issues/812"},"comments":{"href":"https://api.github.com/repos/openshift/console/issues/812/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/console/pulls/812/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/console/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/console/pulls/812/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/console/statuses/4c9bc44dcc2e711492fccfbdf61820781a37337a"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"spadgett"}}