{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/addons-frontend/pulls/comments/105688040","pull_request_review_id":26572347,"id":105688040,"diff_hunk":"@@ -305,3 +297,80 @@ export function render404IfConfigKeyIsFalse(\n     return <Component {...props} />;\n   };\n }\n+\n+export function getCompatibleVersions({ addon, clientApp } = {}) {\n+  let maxVersion = null;\n+  let minVersion = null;\n+  if (\n+    addon && addon.current_version && addon.current_version.compatibility\n+  ) {\n+    if (addon.current_version.compatibility[clientApp]) {\n+      maxVersion = addon.current_version.compatibility[clientApp].max;\n+      minVersion = addon.current_version.compatibility[clientApp].min;\n+    } else {\n+      log.error(\n+        'addon found with no compatibility info for valid clientApp',\n+        { addon, clientApp }\n+      );\n+    }\n+  }\n+\n+  return { maxVersion, minVersion };\n+}\n+\n+export function isCompatibleWithUserAgent({\n+  _log = log, maxVersion, minVersion, userAgentInfo,\n+} = {}) {\n+  // If the userAgent is false there was likely a programming error.\n+  if (!userAgentInfo) {\n+    throw new Error('userAgentInfo is required');\n+  }\n+\n+  const { browser, os } = userAgentInfo;\n+\n+  // We need a Firefox browser compatible with add-ons (Firefox for iOS does\n+  // not currently support add-ons).\n+  if (browser.name === 'Firefox' && os.name === 'iOS') {\n+    return { compatible: false, reason: INCOMPATIBLE_FIREFOX_FOR_IOS };\n+  }\n+\n+  if (browser.name === 'Firefox') {\n+    // Do version checks, if this add-on has minimum or maximum version\n+    // requirements.\n+    // The mozilla-version-comparator API is quite strange; a result of\n+    // `1` means the first argument is higher in version than the second.\n+    if (maxVersion && mozCompare(browser.version, maxVersion) === 1) {\n+      return { compatible: false, reason: INCOMPATIBLE_OVER_MAX_VERSION };\n+    }\n+\n+    // A result of `-1` means the second argument is a lower version than the\n+    // first.\n+    if (minVersion && mozCompare(browser.version, minVersion) === -1) {\n+      if (minVersion === '*') {\n+        _log.error(oneLine`minVersion of \"*\" was passed to\n+          isCompatibleWithUserAgent(); bad add-on version data`,\n+          { browserVersion: browser.version, minVersion }\n+        );\n+      }\n+\n+      return { compatible: false, reason: INCOMPATIBLE_UNDER_MIN_VERSION };\n+    }\n+\n+    // If we made it here we're compatible (yay!)\n+    return { compatible: true };","path":"src/core/utils.js","position":108,"original_position":108,"commit_id":"8fa20f69dd74198994fd46358669b0e966a2c3af","original_commit_id":"8fa20f69dd74198994fd46358669b0e966a2c3af","user":{"login":"kumar303","id":55398,"avatar_url":"https://avatars2.githubusercontent.com/u/55398?v=3","gravatar_id":"","url":"https://api.github.com/users/kumar303","html_url":"https://github.com/kumar303","followers_url":"https://api.github.com/users/kumar303/followers","following_url":"https://api.github.com/users/kumar303/following{/other_user}","gists_url":"https://api.github.com/users/kumar303/gists{/gist_id}","starred_url":"https://api.github.com/users/kumar303/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kumar303/subscriptions","organizations_url":"https://api.github.com/users/kumar303/orgs","repos_url":"https://api.github.com/users/kumar303/repos","events_url":"https://api.github.com/users/kumar303/events{/privacy}","received_events_url":"https://api.github.com/users/kumar303/received_events","type":"User","site_admin":false},"body":"Now that I can see the big picture, I think this should set `reason` to `null` because otherwise this result may cause failures in things that check for an `undefined` value. I know that nothing should be using the `reason` value when `compatible` is `false` but `null` makes it more compatible with the other modes just in case.","created_at":"2017-03-13T15:24:09Z","updated_at":"2017-03-13T15:25:36Z","html_url":"https://github.com/mozilla/addons-frontend/pull/1980#discussion_r105688040","pull_request_url":"https://api.github.com/repos/mozilla/addons-frontend/pulls/1980","_links":{"self":{"href":"https://api.github.com/repos/mozilla/addons-frontend/pulls/comments/105688040"},"html":{"href":"https://github.com/mozilla/addons-frontend/pull/1980#discussion_r105688040"},"pull_request":{"href":"https://api.github.com/repos/mozilla/addons-frontend/pulls/1980"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/addons-frontend/pulls/1980","id":109404785,"html_url":"https://github.com/mozilla/addons-frontend/pull/1980","diff_url":"https://github.com/mozilla/addons-frontend/pull/1980.diff","patch_url":"https://github.com/mozilla/addons-frontend/pull/1980.patch","issue_url":"https://api.github.com/repos/mozilla/addons-frontend/issues/1980","number":1980,"state":"open","locked":false,"title":"Disable incompat versions and browsers","user":{"login":"tofumatt","id":90871,"avatar_url":"https://avatars1.githubusercontent.com/u/90871?v=3","gravatar_id":"","url":"https://api.github.com/users/tofumatt","html_url":"https://github.com/tofumatt","followers_url":"https://api.github.com/users/tofumatt/followers","following_url":"https://api.github.com/users/tofumatt/following{/other_user}","gists_url":"https://api.github.com/users/tofumatt/gists{/gist_id}","starred_url":"https://api.github.com/users/tofumatt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tofumatt/subscriptions","organizations_url":"https://api.github.com/users/tofumatt/orgs","repos_url":"https://api.github.com/users/tofumatt/repos","events_url":"https://api.github.com/users/tofumatt/events{/privacy}","received_events_url":"https://api.github.com/users/tofumatt/received_events","type":"User","site_admin":false},"body":"Fixes #1935.\r\n\r\nThis prevents non-Firefox browsers and incompatible versions of Firefox (based on an addon's `current_version.compatibility[clientApp].max` and `current_version.compatibility[clientApp].min` values) from showing the install buttons and theme preview toggles as enabled.\r\n\r\nI need to tidy up a lot of tests as they introduced state into some components and I also need to add tests, but I'm gonna do it in the morning when I get up 😄 \r\n\r\n(This works but is quite rough now so no sense doing prelim review 😉)\r\n\r\n### Screenshots\r\n\r\n![screen shot 2017-03-07 at 04 01 31](https://cloud.githubusercontent.com/assets/90871/23641872/02cb8978-02ef-11e7-9dbf-614defc65b81.png)\r\n![screen shot 2017-03-07 at 04 01 14](https://cloud.githubusercontent.com/assets/90871/23641873/02cbf6ce-02ef-11e7-9cd0-a5fc548315bf.png)\r\n![screen shot 2017-03-07 at 04 00 54](https://cloud.githubusercontent.com/assets/90871/23641874/02ccbbf4-02ef-11e7-8137-d680cda6e238.png)\r\n![screen shot 2017-03-07 at 04 00 43](https://cloud.githubusercontent.com/assets/90871/23641871/02c9793a-02ef-11e7-8811-b1ddb1d93ccb.png)\r\n","created_at":"2017-03-07T04:30:47Z","updated_at":"2017-03-13T15:25:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ddc2908e161e43c93e3b22d60020e0676bf4d859","assignee":{"login":"kumar303","id":55398,"avatar_url":"https://avatars2.githubusercontent.com/u/55398?v=3","gravatar_id":"","url":"https://api.github.com/users/kumar303","html_url":"https://github.com/kumar303","followers_url":"https://api.github.com/users/kumar303/followers","following_url":"https://api.github.com/users/kumar303/following{/other_user}","gists_url":"https://api.github.com/users/kumar303/gists{/gist_id}","starred_url":"https://api.github.com/users/kumar303/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kumar303/subscriptions","organizations_url":"https://api.github.com/users/kumar303/orgs","repos_url":"https://api.github.com/users/kumar303/repos","events_url":"https://api.github.com/users/kumar303/events{/privacy}","received_events_url":"https://api.github.com/users/kumar303/received_events","type":"User","site_admin":false},"assignees":[{"login":"kumar303","id":55398,"avatar_url":"https://avatars2.githubusercontent.com/u/55398?v=3","gravatar_id":"","url":"https://api.github.com/users/kumar303","html_url":"https://github.com/kumar303","followers_url":"https://api.github.com/users/kumar303/followers","following_url":"https://api.github.com/users/kumar303/following{/other_user}","gists_url":"https://api.github.com/users/kumar303/gists{/gist_id}","starred_url":"https://api.github.com/users/kumar303/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kumar303/subscriptions","organizations_url":"https://api.github.com/users/kumar303/orgs","repos_url":"https://api.github.com/users/kumar303/repos","events_url":"https://api.github.com/users/kumar303/events{/privacy}","received_events_url":"https://api.github.com/users/kumar303/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/addons-frontend/pulls/1980/commits","review_comments_url":"https://api.github.com/repos/mozilla/addons-frontend/pulls/1980/comments","review_comment_url":"https://api.github.com/repos/mozilla/addons-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/addons-frontend/issues/1980/comments","statuses_url":"https://api.github.com/repos/mozilla/addons-frontend/statuses/8fa20f69dd74198994fd46358669b0e966a2c3af","head":{"label":"mozilla:disable-incompat-versions-ff-1935","ref":"disable-incompat-versions-ff-1935","sha":"8fa20f69dd74198994fd46358669b0e966a2c3af","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars1.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":52104368,"name":"addons-frontend","full_name":"mozilla/addons-frontend","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars1.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/addons-frontend","description":"Front-end infrastructure and code to complement mozilla/addons-server","fork":false,"url":"https://api.github.com/repos/mozilla/addons-frontend","forks_url":"https://api.github.com/repos/mozilla/addons-frontend/forks","keys_url":"https://api.github.com/repos/mozilla/addons-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/addons-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/addons-frontend/teams","hooks_url":"https://api.github.com/repos/mozilla/addons-frontend/hooks","issue_events_url":"https://api.github.com/repos/mozilla/addons-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/addons-frontend/events","assignees_url":"https://api.github.com/repos/mozilla/addons-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/addons-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/addons-frontend/tags","blobs_url":"https://api.github.com/repos/mozilla/addons-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/addons-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/addons-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/addons-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/addons-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/addons-frontend/languages","stargazers_url":"https://api.github.com/repos/mozilla/addons-frontend/stargazers","contributors_url":"https://api.github.com/repos/mozilla/addons-frontend/contributors","subscribers_url":"https://api.github.com/repos/mozilla/addons-frontend/subscribers","subscription_url":"https://api.github.com/repos/mozilla/addons-frontend/subscription","commits_url":"https://api.github.com/repos/mozilla/addons-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/addons-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/addons-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/addons-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/addons-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/addons-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/addons-frontend/merges","archive_url":"https://api.github.com/repos/mozilla/addons-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/addons-frontend/downloads","issues_url":"https://api.github.com/repos/mozilla/addons-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/addons-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/addons-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/addons-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/addons-frontend/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/addons-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/addons-frontend/deployments","created_at":"2016-02-19T17:25:57Z","updated_at":"2017-03-06T01:19:54Z","pushed_at":"2017-03-13T14:01:26Z","git_url":"git://github.com/mozilla/addons-frontend.git","ssh_url":"git@github.com:mozilla/addons-frontend.git","clone_url":"https://github.com/mozilla/addons-frontend.git","svn_url":"https://github.com/mozilla/addons-frontend","homepage":null,"size":218235,"stargazers_count":24,"watchers_count":24,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":253,"forks":30,"open_issues":253,"watchers":24,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"92abf13179e9ad6f408d9d1a5915aa60e3a6f52d","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars1.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":52104368,"name":"addons-frontend","full_name":"mozilla/addons-frontend","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars1.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/addons-frontend","description":"Front-end infrastructure and code to complement mozilla/addons-server","fork":false,"url":"https://api.github.com/repos/mozilla/addons-frontend","forks_url":"https://api.github.com/repos/mozilla/addons-frontend/forks","keys_url":"https://api.github.com/repos/mozilla/addons-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/addons-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/addons-frontend/teams","hooks_url":"https://api.github.com/repos/mozilla/addons-frontend/hooks","issue_events_url":"https://api.github.com/repos/mozilla/addons-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/addons-frontend/events","assignees_url":"https://api.github.com/repos/mozilla/addons-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/addons-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/addons-frontend/tags","blobs_url":"https://api.github.com/repos/mozilla/addons-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/addons-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/addons-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/addons-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/addons-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/addons-frontend/languages","stargazers_url":"https://api.github.com/repos/mozilla/addons-frontend/stargazers","contributors_url":"https://api.github.com/repos/mozilla/addons-frontend/contributors","subscribers_url":"https://api.github.com/repos/mozilla/addons-frontend/subscribers","subscription_url":"https://api.github.com/repos/mozilla/addons-frontend/subscription","commits_url":"https://api.github.com/repos/mozilla/addons-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/addons-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/addons-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/addons-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/addons-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/addons-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/addons-frontend/merges","archive_url":"https://api.github.com/repos/mozilla/addons-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/addons-frontend/downloads","issues_url":"https://api.github.com/repos/mozilla/addons-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/addons-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/addons-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/addons-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/addons-frontend/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/addons-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/addons-frontend/deployments","created_at":"2016-02-19T17:25:57Z","updated_at":"2017-03-06T01:19:54Z","pushed_at":"2017-03-13T14:01:26Z","git_url":"git://github.com/mozilla/addons-frontend.git","ssh_url":"git@github.com:mozilla/addons-frontend.git","clone_url":"https://github.com/mozilla/addons-frontend.git","svn_url":"https://github.com/mozilla/addons-frontend","homepage":null,"size":218235,"stargazers_count":24,"watchers_count":24,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":253,"forks":30,"open_issues":253,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/addons-frontend/pulls/1980"},"html":{"href":"https://github.com/mozilla/addons-frontend/pull/1980"},"issue":{"href":"https://api.github.com/repos/mozilla/addons-frontend/issues/1980"},"comments":{"href":"https://api.github.com/repos/mozilla/addons-frontend/issues/1980/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/addons-frontend/pulls/1980/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/addons-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/addons-frontend/pulls/1980/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/addons-frontend/statuses/8fa20f69dd74198994fd46358669b0e966a2c3af"}}}}
{"actor":{"display_login":"kumar303"}}