{"action":"created","comment":{"url":"https://api.github.com/repos/paritytech/js-ui/pulls/comments/157516576","pull_request_review_id":84170755,"id":157516576,"diff_hunk":"@@ -14,64 +14,81 @@\n // You should have received a copy of the GNU General Public License\n // along with Parity.  If not, see <http://www.gnu.org/licenses/>.\n \n-import React from 'react';\n+import React, { Component } from 'react';\n+import { observer } from 'mobx-react';\n import PropTypes from 'prop-types';\n-\n-import { createIcon } from '../Icons';\n+import DappsUrlStore from '@parity/mobx/lib/dapps/DappsUrlStore';\n \n import styles from './dappIcon.css';\n \n-export default function DappIcon ({ app, className, small }, { api }) {\n-  const { dappsUrl } = api;\n-  const classes = [\n-    styles.icon, styles[small ? 'small' : 'normal'], className\n-  ].join(' ');\n+@observer\n+class DappIcon extends Component {\n+  static contextTypes = {\n+    api: PropTypes.object.isRequired\n+  };\n \n-  if (app['semantic-icon']) {\n-    return createIcon(app['semantic-icon'], { className: classes });\n-  }\n+  static propTypes = {\n+    app: PropTypes.object.isRequired,\n+    className: PropTypes.string,\n+    raised: PropTypes.bool,\n+    size: PropTypes.oneOf(['small', 'normal'])\n+  };\n \n-  let imageSrc;\n-  let imageRef;\n+  static defaultProps = {\n+    raised: true,\n+    size: 'normal'\n+  };\n \n-  if (app.type === 'builtin' || app.type === 'view') {\n-    let dapphost = process.env.DAPPS_URL || (\n-      process.env.NODE_ENV === 'production'\n-        ? `${dappsUrl}/ui`\n-        : ''\n-    );\n+  state = {\n+    hasError: false // Do not show broken image when fetching image gives error\n+  };\n+\n+  dappsUrlStore = DappsUrlStore.get(this.context.api);\n+\n+  handleError = () => {\n+    this.setState({ hasError: true });\n+  };\n+\n+  render () {\n+    const { app, className, raised, size } = this.props;\n+    const dappHost = (process.env.DAPPS_URL || `${this.dappsUrlStore.dappsUrl}/ui`).trimRight('/');\n \n-    if (dapphost === '/') {\n-      dapphost = '';\n+    const classes = [styles.icon, raised && styles.raised, styles[size], className].join(' ');\n+\n+    if (!this.dappsUrlStore.dappsUrl) {\n+      return <div className={classes} />; // A blank frame\n     }\n \n-    const fallbackSrc = window.location.protocol === 'file:'\n-      ? `dapps/${app.id}/icon.png`\n-      : `${dapphost}/dapps/${app.id}/icon.png`;\n+    let imageSrc;\n+\n+    switch (app.type) {\n+      case 'view': {\n+        const fallbackSrc =\n+          window.location.protocol === 'file:' ? `dapps/${app.id}/icon.png` : `${dappHost}/dapps/${app.id}/icon.png`;","path":"src/DappIcon/dappIcon.js","position":78,"original_position":78,"commit_id":"994b84d9385ce5b4f686f1451aaae82ef587ac2a","original_commit_id":"994b84d9385ce5b4f686f1451aaae82ef587ac2a","user":{"login":"jacogr","id":1424473,"avatar_url":"https://avatars2.githubusercontent.com/u/1424473?v=4","gravatar_id":"","url":"https://api.github.com/users/jacogr","html_url":"https://github.com/jacogr","followers_url":"https://api.github.com/users/jacogr/followers","following_url":"https://api.github.com/users/jacogr/following{/other_user}","gists_url":"https://api.github.com/users/jacogr/gists{/gist_id}","starred_url":"https://api.github.com/users/jacogr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacogr/subscriptions","organizations_url":"https://api.github.com/users/jacogr/orgs","repos_url":"https://api.github.com/users/jacogr/repos","events_url":"https://api.github.com/users/jacogr/events{/privacy}","received_events_url":"https://api.github.com/users/jacogr/received_events","type":"User","site_admin":false},"body":"We are using it for Electron. (WIP, will become important going forward)","created_at":"2017-12-18T15:33:24Z","updated_at":"2017-12-18T15:33:24Z","html_url":"https://github.com/paritytech/js-ui/pull/29#discussion_r157516576","pull_request_url":"https://api.github.com/repos/paritytech/js-ui/pulls/29","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/paritytech/js-ui/pulls/comments/157516576"},"html":{"href":"https://github.com/paritytech/js-ui/pull/29#discussion_r157516576"},"pull_request":{"href":"https://api.github.com/repos/paritytech/js-ui/pulls/29"}},"in_reply_to_id":157515335},"pull_request":{"url":"https://api.github.com/repos/paritytech/js-ui/pulls/29","id":158942289,"html_url":"https://github.com/paritytech/js-ui/pull/29","diff_url":"https://github.com/paritytech/js-ui/pull/29.diff","patch_url":"https://github.com/paritytech/js-ui/pull/29.patch","issue_url":"https://api.github.com/repos/paritytech/js-ui/issues/29","number":29,"state":"open","locked":false,"title":"Fix bug not showing dappIcon","user":{"login":"amaurymartiny","id":1293565,"avatar_url":"https://avatars0.githubusercontent.com/u/1293565?v=4","gravatar_id":"","url":"https://api.github.com/users/amaurymartiny","html_url":"https://github.com/amaurymartiny","followers_url":"https://api.github.com/users/amaurymartiny/followers","following_url":"https://api.github.com/users/amaurymartiny/following{/other_user}","gists_url":"https://api.github.com/users/amaurymartiny/gists{/gist_id}","starred_url":"https://api.github.com/users/amaurymartiny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amaurymartiny/subscriptions","organizations_url":"https://api.github.com/users/amaurymartiny/orgs","repos_url":"https://api.github.com/users/amaurymartiny/repos","events_url":"https://api.github.com/users/amaurymartiny/events{/privacy}","received_events_url":"https://api.github.com/users/amaurymartiny/received_events","type":"User","site_admin":false},"body":"- Fix bug of dappIcons not showing\r\n- Remove imageRef when hiding broken images, use CSS class instead","created_at":"2017-12-18T15:27:32Z","updated_at":"2017-12-18T15:33:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bc99a55126012739fb5f3fbfa628d27f5908b58b","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/paritytech/js-ui/pulls/29/commits","review_comments_url":"https://api.github.com/repos/paritytech/js-ui/pulls/29/comments","review_comment_url":"https://api.github.com/repos/paritytech/js-ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/paritytech/js-ui/issues/29/comments","statuses_url":"https://api.github.com/repos/paritytech/js-ui/statuses/994b84d9385ce5b4f686f1451aaae82ef587ac2a","head":{"label":"paritytech:am-dappicon","ref":"am-dappicon","sha":"994b84d9385ce5b4f686f1451aaae82ef587ac2a","user":{"login":"paritytech","id":14176906,"avatar_url":"https://avatars2.githubusercontent.com/u/14176906?v=4","gravatar_id":"","url":"https://api.github.com/users/paritytech","html_url":"https://github.com/paritytech","followers_url":"https://api.github.com/users/paritytech/followers","following_url":"https://api.github.com/users/paritytech/following{/other_user}","gists_url":"https://api.github.com/users/paritytech/gists{/gist_id}","starred_url":"https://api.github.com/users/paritytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paritytech/subscriptions","organizations_url":"https://api.github.com/users/paritytech/orgs","repos_url":"https://api.github.com/users/paritytech/repos","events_url":"https://api.github.com/users/paritytech/events{/privacy}","received_events_url":"https://api.github.com/users/paritytech/received_events","type":"Organization","site_admin":false},"repo":{"id":98533487,"name":"js-ui","full_name":"paritytech/js-ui","owner":{"login":"paritytech","id":14176906,"avatar_url":"https://avatars2.githubusercontent.com/u/14176906?v=4","gravatar_id":"","url":"https://api.github.com/users/paritytech","html_url":"https://github.com/paritytech","followers_url":"https://api.github.com/users/paritytech/followers","following_url":"https://api.github.com/users/paritytech/following{/other_user}","gists_url":"https://api.github.com/users/paritytech/gists{/gist_id}","starred_url":"https://api.github.com/users/paritytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paritytech/subscriptions","organizations_url":"https://api.github.com/users/paritytech/orgs","repos_url":"https://api.github.com/users/paritytech/repos","events_url":"https://api.github.com/users/paritytech/events{/privacy}","received_events_url":"https://api.github.com/users/paritytech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/paritytech/js-ui","description":"Shared UI components for the Parity wallet & dapps","fork":false,"url":"https://api.github.com/repos/paritytech/js-ui","forks_url":"https://api.github.com/repos/paritytech/js-ui/forks","keys_url":"https://api.github.com/repos/paritytech/js-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paritytech/js-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paritytech/js-ui/teams","hooks_url":"https://api.github.com/repos/paritytech/js-ui/hooks","issue_events_url":"https://api.github.com/repos/paritytech/js-ui/issues/events{/number}","events_url":"https://api.github.com/repos/paritytech/js-ui/events","assignees_url":"https://api.github.com/repos/paritytech/js-ui/assignees{/user}","branches_url":"https://api.github.com/repos/paritytech/js-ui/branches{/branch}","tags_url":"https://api.github.com/repos/paritytech/js-ui/tags","blobs_url":"https://api.github.com/repos/paritytech/js-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paritytech/js-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paritytech/js-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/paritytech/js-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paritytech/js-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/paritytech/js-ui/languages","stargazers_url":"https://api.github.com/repos/paritytech/js-ui/stargazers","contributors_url":"https://api.github.com/repos/paritytech/js-ui/contributors","subscribers_url":"https://api.github.com/repos/paritytech/js-ui/subscribers","subscription_url":"https://api.github.com/repos/paritytech/js-ui/subscription","commits_url":"https://api.github.com/repos/paritytech/js-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/paritytech/js-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/paritytech/js-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/paritytech/js-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/paritytech/js-ui/contents/{+path}","compare_url":"https://api.github.com/repos/paritytech/js-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paritytech/js-ui/merges","archive_url":"https://api.github.com/repos/paritytech/js-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paritytech/js-ui/downloads","issues_url":"https://api.github.com/repos/paritytech/js-ui/issues{/number}","pulls_url":"https://api.github.com/repos/paritytech/js-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/paritytech/js-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/paritytech/js-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paritytech/js-ui/labels{/name}","releases_url":"https://api.github.com/repos/paritytech/js-ui/releases{/id}","deployments_url":"https://api.github.com/repos/paritytech/js-ui/deployments","created_at":"2017-07-27T12:31:12Z","updated_at":"2017-11-15T12:48:16Z","pushed_at":"2017-12-18T15:27:32Z","git_url":"git://github.com/paritytech/js-ui.git","ssh_url":"git@github.com:paritytech/js-ui.git","clone_url":"https://github.com/paritytech/js-ui.git","svn_url":"https://github.com/paritytech/js-ui","homepage":null,"size":3270,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":2,"open_issues":6,"watchers":3,"default_branch":"master"}},"base":{"label":"paritytech:master","ref":"master","sha":"ef71ed045cbbd345c5de8656917ac5d737f4a46a","user":{"login":"paritytech","id":14176906,"avatar_url":"https://avatars2.githubusercontent.com/u/14176906?v=4","gravatar_id":"","url":"https://api.github.com/users/paritytech","html_url":"https://github.com/paritytech","followers_url":"https://api.github.com/users/paritytech/followers","following_url":"https://api.github.com/users/paritytech/following{/other_user}","gists_url":"https://api.github.com/users/paritytech/gists{/gist_id}","starred_url":"https://api.github.com/users/paritytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paritytech/subscriptions","organizations_url":"https://api.github.com/users/paritytech/orgs","repos_url":"https://api.github.com/users/paritytech/repos","events_url":"https://api.github.com/users/paritytech/events{/privacy}","received_events_url":"https://api.github.com/users/paritytech/received_events","type":"Organization","site_admin":false},"repo":{"id":98533487,"name":"js-ui","full_name":"paritytech/js-ui","owner":{"login":"paritytech","id":14176906,"avatar_url":"https://avatars2.githubusercontent.com/u/14176906?v=4","gravatar_id":"","url":"https://api.github.com/users/paritytech","html_url":"https://github.com/paritytech","followers_url":"https://api.github.com/users/paritytech/followers","following_url":"https://api.github.com/users/paritytech/following{/other_user}","gists_url":"https://api.github.com/users/paritytech/gists{/gist_id}","starred_url":"https://api.github.com/users/paritytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paritytech/subscriptions","organizations_url":"https://api.github.com/users/paritytech/orgs","repos_url":"https://api.github.com/users/paritytech/repos","events_url":"https://api.github.com/users/paritytech/events{/privacy}","received_events_url":"https://api.github.com/users/paritytech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/paritytech/js-ui","description":"Shared UI components for the Parity wallet & dapps","fork":false,"url":"https://api.github.com/repos/paritytech/js-ui","forks_url":"https://api.github.com/repos/paritytech/js-ui/forks","keys_url":"https://api.github.com/repos/paritytech/js-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paritytech/js-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paritytech/js-ui/teams","hooks_url":"https://api.github.com/repos/paritytech/js-ui/hooks","issue_events_url":"https://api.github.com/repos/paritytech/js-ui/issues/events{/number}","events_url":"https://api.github.com/repos/paritytech/js-ui/events","assignees_url":"https://api.github.com/repos/paritytech/js-ui/assignees{/user}","branches_url":"https://api.github.com/repos/paritytech/js-ui/branches{/branch}","tags_url":"https://api.github.com/repos/paritytech/js-ui/tags","blobs_url":"https://api.github.com/repos/paritytech/js-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paritytech/js-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paritytech/js-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/paritytech/js-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paritytech/js-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/paritytech/js-ui/languages","stargazers_url":"https://api.github.com/repos/paritytech/js-ui/stargazers","contributors_url":"https://api.github.com/repos/paritytech/js-ui/contributors","subscribers_url":"https://api.github.com/repos/paritytech/js-ui/subscribers","subscription_url":"https://api.github.com/repos/paritytech/js-ui/subscription","commits_url":"https://api.github.com/repos/paritytech/js-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/paritytech/js-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/paritytech/js-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/paritytech/js-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/paritytech/js-ui/contents/{+path}","compare_url":"https://api.github.com/repos/paritytech/js-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paritytech/js-ui/merges","archive_url":"https://api.github.com/repos/paritytech/js-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paritytech/js-ui/downloads","issues_url":"https://api.github.com/repos/paritytech/js-ui/issues{/number}","pulls_url":"https://api.github.com/repos/paritytech/js-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/paritytech/js-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/paritytech/js-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paritytech/js-ui/labels{/name}","releases_url":"https://api.github.com/repos/paritytech/js-ui/releases{/id}","deployments_url":"https://api.github.com/repos/paritytech/js-ui/deployments","created_at":"2017-07-27T12:31:12Z","updated_at":"2017-11-15T12:48:16Z","pushed_at":"2017-12-18T15:27:32Z","git_url":"git://github.com/paritytech/js-ui.git","ssh_url":"git@github.com:paritytech/js-ui.git","clone_url":"https://github.com/paritytech/js-ui.git","svn_url":"https://github.com/paritytech/js-ui","homepage":null,"size":3270,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":2,"open_issues":6,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/paritytech/js-ui/pulls/29"},"html":{"href":"https://github.com/paritytech/js-ui/pull/29"},"issue":{"href":"https://api.github.com/repos/paritytech/js-ui/issues/29"},"comments":{"href":"https://api.github.com/repos/paritytech/js-ui/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/paritytech/js-ui/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/paritytech/js-ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/paritytech/js-ui/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/paritytech/js-ui/statuses/994b84d9385ce5b4f686f1451aaae82ef587ac2a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jacogr"}}