{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/70689602","id":70689602,"diff_hunk":"@@ -14,49 +17,98 @@ import { trackClick } from './helpers';\n \n const ThemesSiteSelectorModal = React.createClass( {\n \tpropTypes: {\n-\t\tname: React.PropTypes.string.isRequired,\n-\t\tlabel: React.PropTypes.string.isRequired,\n-\t\theader: React.PropTypes.string.isRequired,\n-\t\tselectedTheme: PropTypes.object.isRequired,\n-\t\tonHide: PropTypes.func,\n-\t\taction: PropTypes.func,\n+\t\toptions: React.PropTypes.objectOf( React.PropTypes.shape( {\n+\t\t\tlabel: React.PropTypes.string,\n+\t\t\theader: React.PropTypes.string,\n+\t\t\taction: React.PropTypes.func\n+\t\t} ) ),\n+\t\tselectedSite: React.PropTypes.object,\n \t\t// Will be prepended to site slug for a redirect on selection\n \t\tsourcePath: PropTypes.string.isRequired,\n \t},\n \n+\tgetInitialState() {\n+\t\treturn {\n+\t\t\tselectedTheme: {},\n+\t\t\tselectedOption: {},\n+\t\t};\n+\t},\n+\n \tredirectAndCallAction( site ) {\n+\t\tconst action = this.state.selectedOption.action;\n+\t\tconst theme = this.state.selectedTheme;\n \t\t/**\n \t\t * Since this implies a route change, defer it in case other state\n \t\t * changes are enqueued, e.g. setSelectedTheme.\n \t\t */\n \t\tdefer( () => {\n \t\t\ttrackClick( 'site selector', this.props.name );\n \t\t\tpage( this.props.sourcePath + '/' + site.slug );\n-\t\t\tthis.props.action( this.props.selectedTheme, site );\n+\t\t\taction( theme, site );\n \t\t} );\n \t},\n \n+\tshowSiteSelectorModal( option, theme ) {\n+\t\tthis.setState( { selectedTheme: theme, selectedOption: option } );\n+\t},\n+\n+\thideSiteSelectorModal() {\n+\t\tthis.showSiteSelectorModal( {}, {} );\n+\t},\n+\n+\tisThemeOrActionSet() {\n+\t\treturn ! isEmpty( this.state.selectedTheme ) || ! isEmpty( this.state.selectedOption );","path":"client/my-sites/themes/themes-site-selector-modal.jsx","position":61,"original_position":61,"commit_id":"9687851f45edd09ad574a8a6f03ddd2e3bc8aea6","original_commit_id":"9687851f45edd09ad574a8a6f03ddd2e3bc8aea6","user":{"login":"seear","id":7767559,"avatar_url":"https://avatars.githubusercontent.com/u/7767559?v=3","gravatar_id":"","url":"https://api.github.com/users/seear","html_url":"https://github.com/seear","followers_url":"https://api.github.com/users/seear/followers","following_url":"https://api.github.com/users/seear/following{/other_user}","gists_url":"https://api.github.com/users/seear/gists{/gist_id}","starred_url":"https://api.github.com/users/seear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seear/subscriptions","organizations_url":"https://api.github.com/users/seear/orgs","repos_url":"https://api.github.com/users/seear/repos","events_url":"https://api.github.com/users/seear/events{/privacy}","received_events_url":"https://api.github.com/users/seear/received_events","type":"User","site_admin":false},"body":"So if the action is set, but not the theme, we should go ahead and show the preview?","created_at":"2016-07-13T19:12:34Z","updated_at":"2016-07-13T19:12:34Z","html_url":"https://github.com/Automattic/wp-calypso/pull/6349#discussion_r70689602","pull_request_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6349","_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/70689602"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/6349#discussion_r70689602"},"pull_request":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6349"}}},"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6349","id":75394833,"html_url":"https://github.com/Automattic/wp-calypso/pull/6349","diff_url":"https://github.com/Automattic/wp-calypso/pull/6349.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/6349.patch","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6349","number":6349,"state":"open","locked":false,"title":"Themes: Make a ThemesSiteSelectorModal Higher-Order Component","user":{"login":"ockham","id":96308,"avatar_url":"https://avatars.githubusercontent.com/u/96308?v=3","gravatar_id":"","url":"https://api.github.com/users/ockham","html_url":"https://github.com/ockham","followers_url":"https://api.github.com/users/ockham/followers","following_url":"https://api.github.com/users/ockham/following{/other_user}","gists_url":"https://api.github.com/users/ockham/gists{/gist_id}","starred_url":"https://api.github.com/users/ockham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ockham/subscriptions","organizations_url":"https://api.github.com/users/ockham/orgs","repos_url":"https://api.github.com/users/ockham/repos","events_url":"https://api.github.com/users/ockham/events{/privacy}","received_events_url":"https://api.github.com/users/ockham/received_events","type":"User","site_admin":false},"body":"The idea here is to provide a higher-order component to just wrap `MultiSite` so that the latter can transparently use e.g. `props.options.activate` (just like `SingleSite`), with the HoC taking care of site selection and then invoking the correct action.\r\n\r\nFurthermore, theme options are now declared at `connect` stage, which allows us to bind early (e.g. to site), again enabling us to just call the action in the wrapped component (without having to differentiate between binding or not binding there).\r\n\r\nTurns out that as a side effect we can actually compose `MultiSite` and `SingleSite` from that HoC, and (un-`connect`ed) `LoggedOut`, so the latter is renamed to `ThemeShowcase`.\r\n\r\nNo visual changes, except for some label changes: _this PR now purports to change theme sheet preview action button functionality the way #6027 would do_. Check testing instructions there!\r\n\r\nTo test:\r\n_This needs some thorough testing._ As this PR touches pretty much all theme actions, we need to test them all. \r\n* That is, every item inside the '...' menu for a random theme in logged-out and multi-site mode\r\n* and also for an active one in single-site mode.\r\n* Furthermore, try single site mode with a Jetpack site\r\n* Finally, test the action button inside the Theme Preview\r\n* And the 'Current Theme' bar options in single-site mode (again also with a Jetpack site).\r\n\r\nTODO, in future PRs:\r\n* Move `<Head>`  to `ThemeShowcase`, drop `makeElement`\r\n* Pass `getScreenshotOption` to `ThemeSelection`, call there (or maybe only in `ThemesList`)\r\n* Unify  `screenshotOption` and `defaultOption` handling\r\n* Kill the `ThemeSelection` component and file, and inline their contents into `ThemeShowcase`. (That abstraction/indirection doesn't make much sense anymore.)\r\n* Implement the `CurrentTheme` bar component in terms of theme `options`\r\n* Rename `sourcePath` to `siteBasePath` for consistency with `my-sites/controller` and other site selector components\r\n* Rename theme options to better reflect their labels. support -> setup, help -> support, preview -> demo etc.\r\n\r\nTest live: https://calypso.live/?branch=update/themes-themes-site-selector-modal-hoc\r\n\r\ncc @sirbrillig because, pie.","created_at":"2016-06-27T23:09:35Z","updated_at":"2016-07-13T19:12:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3676357fc56eef0e096928d1c7640dc7a5a071c2","assignee":{"login":"ockham","id":96308,"avatar_url":"https://avatars.githubusercontent.com/u/96308?v=3","gravatar_id":"","url":"https://api.github.com/users/ockham","html_url":"https://github.com/ockham","followers_url":"https://api.github.com/users/ockham/followers","following_url":"https://api.github.com/users/ockham/following{/other_user}","gists_url":"https://api.github.com/users/ockham/gists{/gist_id}","starred_url":"https://api.github.com/users/ockham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ockham/subscriptions","organizations_url":"https://api.github.com/users/ockham/orgs","repos_url":"https://api.github.com/users/ockham/repos","events_url":"https://api.github.com/users/ockham/events{/privacy}","received_events_url":"https://api.github.com/users/ockham/received_events","type":"User","site_admin":false},"assignees":[{"login":"ockham","id":96308,"avatar_url":"https://avatars.githubusercontent.com/u/96308?v=3","gravatar_id":"","url":"https://api.github.com/users/ockham","html_url":"https://github.com/ockham","followers_url":"https://api.github.com/users/ockham/followers","following_url":"https://api.github.com/users/ockham/following{/other_user}","gists_url":"https://api.github.com/users/ockham/gists{/gist_id}","starred_url":"https://api.github.com/users/ockham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ockham/subscriptions","organizations_url":"https://api.github.com/users/ockham/orgs","repos_url":"https://api.github.com/users/ockham/repos","events_url":"https://api.github.com/users/ockham/events{/privacy}","received_events_url":"https://api.github.com/users/ockham/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/Automattic/wp-calypso/milestones/35","html_url":"https://github.com/Automattic/wp-calypso/milestones/Themes:%20Maintenance","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones/35/labels","id":1429662,"number":35,"title":"Themes: Maintenance","description":"","creator":{"login":"folletto","id":4389,"avatar_url":"https://avatars.githubusercontent.com/u/4389?v=3","gravatar_id":"","url":"https://api.github.com/users/folletto","html_url":"https://github.com/folletto","followers_url":"https://api.github.com/users/folletto/followers","following_url":"https://api.github.com/users/folletto/following{/other_user}","gists_url":"https://api.github.com/users/folletto/gists{/gist_id}","starred_url":"https://api.github.com/users/folletto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/folletto/subscriptions","organizations_url":"https://api.github.com/users/folletto/orgs","repos_url":"https://api.github.com/users/folletto/repos","events_url":"https://api.github.com/users/folletto/events{/privacy}","received_events_url":"https://api.github.com/users/folletto/received_events","type":"User","site_admin":false},"open_issues":15,"closed_issues":18,"state":"open","created_at":"2015-11-25T16:14:32Z","updated_at":"2016-07-12T16:58:02Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6349/commits","review_comments_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6349/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/6349/comments","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/9687851f45edd09ad574a8a6f03ddd2e3bc8aea6","head":{"label":"Automattic:update/themes-themes-site-selector-modal-hoc","ref":"update/themes-themes-site-selector-modal-hoc","sha":"9687851f45edd09ad574a8a6f03ddd2e3bc8aea6","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-07-13T12:14:21Z","pushed_at":"2016-07-13T19:06:19Z","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":81904,"stargazers_count":7571,"watchers_count":7571,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":943,"mirror_url":null,"open_issues_count":1321,"forks":943,"open_issues":1321,"watchers":7571,"default_branch":"master"}},"base":{"label":"Automattic:master","ref":"master","sha":"456e0b9739d55e13ece39d224d9a04668d383261","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-07-13T12:14:21Z","pushed_at":"2016-07-13T19:06:19Z","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":81904,"stargazers_count":7571,"watchers_count":7571,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":943,"mirror_url":null,"open_issues_count":1321,"forks":943,"open_issues":1321,"watchers":7571,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6349"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/6349"},"issue":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/6349"},"comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/6349/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6349/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/6349/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/wp-calypso/statuses/9687851f45edd09ad574a8a6f03ddd2e3bc8aea6"}}}}
{"actor":{"display_login":"seear"}}