Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Themes, Actions: Install WP.com theme on Jetpack action. #9924

Merged
merged 24 commits into from
Dec 19, 2016

Conversation

budzanowski
Copy link
Contributor

@budzanowski budzanowski commented Dec 9, 2016

Info

Implements action creator tor trigger install endpoint. Requires implementation from #9923.
Implements install tracking reducer.

Testing

Not connected yet.

TODO

@budzanowski budzanowski added the [Feature Group] Appearance & Themes Features related to the appearance of sites. label Dec 9, 2016
@budzanowski budzanowski added this to the Themes: JetPress Rally milestone Dec 9, 2016
@budzanowski budzanowski self-assigned this Dec 9, 2016
@matticbot
Copy link
Contributor

@budzanowski budzanowski added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Dec 9, 2016
* @param {Object} action Action payload
* @return {Object} Updated state
*/
export function installThemeOnJetpackRequests( state = {}, action ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reducer indicates whether install is in progress or not, so probably needs the word progress in it.

Copy link
Contributor Author

@budzanowski budzanowski Dec 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change it to have word progress - I have no preferences here :) I made it this way to follow general pattern of naming reducers we have in this file:
themeRequests , activeThemeRequests and couple of others indicate if the "progress" is ongoing but don't have word progress in theme.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it this way to follow general pattern of naming reducers we have in this file

ok, that makes sense.

case THEME_INSTALL_ON_JETPACK_REQUEST_FAILURE:
return Object.assign( {}, state, {
[ action.siteId ]: Object.assign( {}, state[ action.siteId ], {
[ action.themeId ]: THEME_INSTALL_ON_JETPACK_REQUEST === action.type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, we would need to know the id of the theme to determine whether a site is currently installing something. Maybe themeId should be a value rather than a key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed: we should store full relation site - theme - bool. We rely on selectors to figure out proper answer to different type of questions like for example; is there an install process for site ongoing or what themes are being installed right now.

@budzanowski budzanowski force-pushed the add/install-action-wpcom-theme-on-jetpack branch from e0dc375 to 7b9197a Compare December 11, 2016 00:09

return wpcom.undocumented().installThemeOnJetpack( siteId, wpcomThemeId )
.then( ( ) => {
dispatch( {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could dispatch receiveTheme with the API result here if we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am adding it but It looks like we do only receive limited subset of theme data from the endpoint.

error
} );
// push the error forward so connected then() can catch it.
throw error;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where will this be handled?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we shouldn't throw here at all? I think the idea is that we're already catching it above and handling it as graceful as possible by dispatching THEME_INSTALL_ON_JETPACK_REQUEST_FAILURE. Cf other network request... actions.

@@ -509,6 +509,9 @@ export const THEME_ACTIVATE_REQUEST_FAILURE = 'THEME_ACTIVATE_REQUEST_FAILURE';
export const THEME_REQUEST = 'THEME_REQUEST';
export const THEME_REQUEST_FAILURE = 'THEME_REQUEST_FAILURE';
export const THEME_REQUEST_SUCCESS = 'THEME_REQUEST_SUCCESS';
export const THEME_INSTALL_ON_JETPACK_REQUEST = 'THEME_INSTALL_ON_JETPACK_REQUEST';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nitpick but we should keep this list alphabetized 😄

@ockham ockham force-pushed the add/install-action-wpcom-theme-on-jetpack branch from 5946b8f to 7b62f5c Compare December 16, 2016 20:08
@ockham
Copy link
Contributor

ockham commented Dec 16, 2016

Rebased.

@ockham ockham force-pushed the add/install-action-wpcom-theme-on-jetpack branch from 590f7d3 to 12c6d10 Compare December 16, 2016 23:14
@ockham
Copy link
Contributor

ockham commented Dec 16, 2016

Renamed and polished some stuff as per #10126 (comment). We'll implement activateWpcomThemeOnJetpack using this (and rename to installAndActivate 😉 ), and installAndTryAndCustomize in subsequent PRs.

@budzanowski budzanowski merged commit c9474af into master Dec 19, 2016
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Dec 19, 2016
@budzanowski budzanowski deleted the add/install-action-wpcom-theme-on-jetpack branch December 19, 2016 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature Group] Appearance & Themes Features related to the appearance of sites.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants