{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/61496702","id":61496702,"diff_hunk":"@@ -0,0 +1,130 @@\n+/**\n+ * External dependencies\n+ */\n+import debugFactory from 'debug';\n+import map from 'lodash/map';\n+\n+/**\n+ * Internal dependencies\n+ */\n+import { createSiteDomainObject } from './assembler';\n+import i18n from 'lib/mixins/i18n';\n+import wpcom from 'lib/wp';\n+import {\n+\tSITE_DOMAINS_RECEIVE,\n+\tSITE_DOMAINS_REQUEST,\n+\tSITE_DOMAINS_REQUEST_SUCCESS,\n+\tSITE_DOMAINS_REQUEST_FAILURE,\n+} from 'state/action-types';\n+\n+/**\n+ * Module vars\n+ */\n+const debug = debugFactory( 'calypso:site-domains:actions' );\n+\n+/**\n+ * `action-creator`\n+ * Returns an action object to be used in signalling that\n+ * an object containing the domains for\n+ * a given site have been received.\n+ *\n+ * @param {Number} siteId - identifier of the site\n+ * @param {Object} response - WP REST-API domains endpoint response\n+ * @returns {Object} the action object\n+ */\n+export const createDomainsReceiveAction = ( siteId, response ) => {\n+\tconst { domains } = response;\n+\n+\treturn {\n+\t\ttype: SITE_DOMAINS_RECEIVE,\n+\t\tsiteId,\n+\t\tdomains: map( domains, createSiteDomainObject )\n+\t};\n+};\n+\n+/**\n+ * `action-creator`\n+ * Return SITE_DOMAINS_REQUEST action object\n+ *\n+ * @param {Number} siteId - side identifier\n+ * @return {Object} siteId - action object\n+ */\n+export const createDomainsRequestAction = siteId => {\n+\treturn {\n+\t\ttype: SITE_DOMAINS_REQUEST,\n+\t\tsiteId\n+\t};\n+};\n+\n+/**\n+ * `action-creator`\n+ * Return SITE_DOMAINS_REQUEST_SUCCESS action object\n+ *\n+ * @param {Number} siteId - side identifier\n+ * @return {Object} siteId - action object\n+ */\n+export const createDomainsRequestSuccessAction = siteId => {\n+\treturn {\n+\t\ttype: SITE_DOMAINS_REQUEST_SUCCESS,\n+\t\tsiteId\n+\t};\n+};\n+\n+/**\n+ * `action-creator`\n+ * Return SITE_DOMAINS_REQUEST_FAILURE action object\n+ *\n+ * @param {Number} siteId - site identifier\n+ * @param {Object} error - error message according to REST-API error response\n+ * @return {Object} action object\n+ */\n+export const createDomainsRequestFailureAction = ( siteId, error ) => {\n+\treturn {\n+\t\ttype: SITE_DOMAINS_REQUEST_FAILURE,\n+\t\tsiteId,\n+\t\terror: error ? String( error ) : Boolean( error )\n+\t};\n+};\n+\n+/**\n+ * Fetches domains for the given site.\n+ *\n+ * @param {Number} siteId - identifier of the site\n+ * @returns {Function} a promise that will resolve once fetching is completed\n+ */\n+export function fetchSiteDomains( siteId ) {\n+\treturn dispatch => {\n+\t\tdispatch( createDomainsRequestAction( siteId ) );\n+\n+\t\treturn new Promise( resolve => {\n+\t\t\twpcom\n+\t\t\t.site( siteId )\n+\t\t\t.domainsList( ( error, data ) => {\n+\t\t\t\tif ( error ) {\n+\t\t\t\t\tdebug( 'Fetching site domains failed: ', error );\n+\n+\t\t\t\t\tconst errorMessage = error.message || i18n.translate( 'There was a problem fetching site domains. Please try again later or contact support.' );\n+\n+\t\t\t\t\tdispatch( createDomainsRequestFailureAction( siteId, errorMessage ) );\n+\n+\t\t\t\t\treturn;\n+\t\t\t\t}\n+\n+\t\t\t\tdispatch( createDomainsReceiveAction( siteId, data ) );\n+\t\t\t\tresolve();\n+\t\t\t} );\n+\t\t} );\n+\t};\n+}\n+\n+/**\n+ * Clears domains and fetches them for the given site.\n+ *\n+ * @param {Number} siteId - identifier of the site\n+ * @returns {Function} the corresponding action thunk\n+ */\n+export function refreshSiteDomains( siteId ) {","path":"client/state/sites/domains/actions.js","position":126,"original_position":126,"commit_id":"c9ee414db60fe428a93162abbda41c15d91165e2","original_commit_id":"c9ee414db60fe428a93162abbda41c15d91165e2","user":{"login":"gwwar","id":1270189,"avatar_url":"https://avatars.githubusercontent.com/u/1270189?v=3","gravatar_id":"","url":"https://api.github.com/users/gwwar","html_url":"https://github.com/gwwar","followers_url":"https://api.github.com/users/gwwar/followers","following_url":"https://api.github.com/users/gwwar/following{/other_user}","gists_url":"https://api.github.com/users/gwwar/gists{/gist_id}","starred_url":"https://api.github.com/users/gwwar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gwwar/subscriptions","organizations_url":"https://api.github.com/users/gwwar/orgs","repos_url":"https://api.github.com/users/gwwar/repos","events_url":"https://api.github.com/users/gwwar/events{/privacy}","received_events_url":"https://api.github.com/users/gwwar/received_events","type":"User","site_admin":false},"body":"Do we need this? We can dispatch fetchSiteDomains in a QueryComponent. See: https://github.com/Automattic/wp-calypso/blob/master/docs/our-approach-to-data.md#query-components","created_at":"2016-04-28T20:27:01Z","updated_at":"2016-04-28T20:27:01Z","html_url":"https://github.com/Automattic/wp-calypso/pull/4953#discussion_r61496702","pull_request_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/4953","_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/61496702"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/4953#discussion_r61496702"},"pull_request":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/4953"}}},"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/4953","id":67442805,"html_url":"https://github.com/Automattic/wp-calypso/pull/4953","diff_url":"https://github.com/Automattic/wp-calypso/pull/4953.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/4953.patch","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/4953","number":4953,"state":"open","locked":false,"title":"Domains: implement redux site-domains","user":{"login":"retrofox","id":77539,"avatar_url":"https://avatars.githubusercontent.com/u/77539?v=3","gravatar_id":"","url":"https://api.github.com/users/retrofox","html_url":"https://github.com/retrofox","followers_url":"https://api.github.com/users/retrofox/followers","following_url":"https://api.github.com/users/retrofox/following{/other_user}","gists_url":"https://api.github.com/users/retrofox/gists{/gist_id}","starred_url":"https://api.github.com/users/retrofox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/retrofox/subscriptions","organizations_url":"https://api.github.com/users/retrofox/orgs","repos_url":"https://api.github.com/users/retrofox/repos","events_url":"https://api.github.com/users/retrofox/events{/privacy}","received_events_url":"https://api.github.com/users/retrofox/received_events","type":"User","site_admin":false},"body":"This PR implement redux for site domains data. By the moment it only supports fetching data from WordPress REST-API.\r\nI think we should move whole stuff from `/client/lib/domains` folder to here.\r\n\r\n### Testing\r\n\r\n```cli\r\nnpm run test-client client/state/sites/domains/test/actions -- -w\r\nnpm run test-client client/state/sites/domains/test/reducer -- -w\r\nnpm run test-client client/state/sites/domains/test/selectors -- -w\r\n```\r\n\r\ncc @aduth @gwwar","created_at":"2016-04-22T00:27:02Z","updated_at":"2016-04-28T20:27:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a67a660ad6c05532631d17ed4a5af707b8738cd9","assignee":null,"milestone":{"url":"https://api.github.com/repos/Automattic/wp-calypso/milestones/76","html_url":"https://github.com/Automattic/wp-calypso/milestones/Plans%20Iteration%201","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones/76/labels","id":1689084,"number":76,"title":"Plans Iteration 1","description":"","creator":{"login":"rralian","id":134044,"avatar_url":"https://avatars.githubusercontent.com/u/134044?v=3","gravatar_id":"","url":"https://api.github.com/users/rralian","html_url":"https://github.com/rralian","followers_url":"https://api.github.com/users/rralian/followers","following_url":"https://api.github.com/users/rralian/following{/other_user}","gists_url":"https://api.github.com/users/rralian/gists{/gist_id}","starred_url":"https://api.github.com/users/rralian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rralian/subscriptions","organizations_url":"https://api.github.com/users/rralian/orgs","repos_url":"https://api.github.com/users/rralian/repos","events_url":"https://api.github.com/users/rralian/events{/privacy}","received_events_url":"https://api.github.com/users/rralian/received_events","type":"User","site_admin":false},"open_issues":18,"closed_issues":51,"state":"open","created_at":"2016-04-07T10:12:31Z","updated_at":"2016-04-28T20:07:35Z","due_on":"2016-04-30T05:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/4953/commits","review_comments_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/4953/comments","review_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/4953/comments","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/c9ee414db60fe428a93162abbda41c15d91165e2","head":{"label":"Automattic:add/redux-site-domains","ref":"add/redux-site-domains","sha":"c9ee414db60fe428a93162abbda41c15d91165e2","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":45936895,"name":"wp-calypso","full_name":"Automattic/wp-calypso","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":false,"url":"https://api.github.com/repos/Automattic/wp-calypso","forks_url":"https://api.github.com/repos/Automattic/wp-calypso/forks","keys_url":"https://api.github.com/repos/Automattic/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/wp-calypso/teams","hooks_url":"https://api.github.com/repos/Automattic/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/wp-calypso/events","assignees_url":"https://api.github.com/repos/Automattic/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/wp-calypso/tags","blobs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/Automattic/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/Automattic/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/Automattic/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/Automattic/wp-calypso/subscription","commits_url":"https://api.github.com/repos/Automattic/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/wp-calypso/merges","archive_url":"https://api.github.com/repos/Automattic/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/wp-calypso/downloads","issues_url":"https://api.github.com/repos/Automattic/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/wp-calypso/deployments","created_at":"2015-11-10T20:00:16Z","updated_at":"2016-04-28T09:38:30Z","pushed_at":"2016-04-28T20:25:31Z","git_url":"git://github.com/Automattic/wp-calypso.git","ssh_url":"git@github.com:Automattic/wp-calypso.git","clone_url":"https://github.com/Automattic/wp-calypso.git","svn_url":"https://github.com/Automattic/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":74898,"stargazers_count":7215,"watchers_count":7215,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":875,"mirror_url":null,"open_issues_count":1297,"forks":875,"open_issues":1297,"watchers":7215,"default_branch":"master"}},"base":{"label":"Automattic:master","ref":"master","sha":"139b6562a6a6c4fb609605c28ac73c32db519177","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":45936895,"name":"wp-calypso","full_name":"Automattic/wp-calypso","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":false,"url":"https://api.github.com/repos/Automattic/wp-calypso","forks_url":"https://api.github.com/repos/Automattic/wp-calypso/forks","keys_url":"https://api.github.com/repos/Automattic/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/wp-calypso/teams","hooks_url":"https://api.github.com/repos/Automattic/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/wp-calypso/events","assignees_url":"https://api.github.com/repos/Automattic/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/wp-calypso/tags","blobs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/Automattic/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/Automattic/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/Automattic/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/Automattic/wp-calypso/subscription","commits_url":"https://api.github.com/repos/Automattic/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/wp-calypso/merges","archive_url":"https://api.github.com/repos/Automattic/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/wp-calypso/downloads","issues_url":"https://api.github.com/repos/Automattic/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/wp-calypso/deployments","created_at":"2015-11-10T20:00:16Z","updated_at":"2016-04-28T09:38:30Z","pushed_at":"2016-04-28T20:25:31Z","git_url":"git://github.com/Automattic/wp-calypso.git","ssh_url":"git@github.com:Automattic/wp-calypso.git","clone_url":"https://github.com/Automattic/wp-calypso.git","svn_url":"https://github.com/Automattic/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":74898,"stargazers_count":7215,"watchers_count":7215,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":875,"mirror_url":null,"open_issues_count":1297,"forks":875,"open_issues":1297,"watchers":7215,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/4953"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/4953"},"issue":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/4953"},"comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/4953/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/4953/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/4953/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/wp-calypso/statuses/c9ee414db60fe428a93162abbda41c15d91165e2"}}}}