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: Re-organize Redux Subtree #8785

Merged
merged 25 commits into from
Dec 14, 2016
Merged

Themes: Re-organize Redux Subtree #8785

merged 25 commits into from
Dec 14, 2016

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Oct 17, 2016

This is the capstone of the Themes Redux State Tree Refactor. See PRs referenced below for a selection of related PRs. It changes the Theme Showcase to use the new <QueryThemes /> component and selectors corresponding to the new themes.queries subtree (instead of the old <ThemesListFetcher /> and friends).

The idea for the new arch is far-reaching de-duplication, following best Redux practices as seen in other parts of Calypso.

  • This means that there's one per-site list of themes objects functioning as the single source of truth; data from different endpoints (think theme details) will be merged into those authoritative theme objects. We try to avoid storing site-specific data inside the theme objects though.
  • All new selectors accept theme IDs as an arg, not entire theme objects. Instead, they look up relevant theme attributes via the new getTheme() selector.

TODO (later PRs):

  • Check if we need more checks like hasFeature( FEATURE_UNLIMITED_PREMIUM_THEMES ), e.g. for a8c-stickered sites (they're showing themes with prices on this branch right now!)

To test:

  • Analytics
  • SSR

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

matticbot commented Oct 17, 2016

@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Oct 17, 2016
@ockham ockham added [Status] In Progress and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Oct 17, 2016
@ockham ockham force-pushed the update/themes-redux-subtree branch from 3bb0124 to 3236c1c Compare October 20, 2016 15:57
@ockham ockham force-pushed the update/themes-redux-subtree branch from 3236c1c to b5fd268 Compare October 28, 2016 19:25
} );
} );

describe( '#athemeActivationFailed()', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typo: athemeActivationFailed

@@ -133,32 +136,30 @@ export function receiveServerError( error ) {
* Returns an action object to be used in signalling that a theme activation
* has been triggered
*
* @param {Object} theme Theme received
* @param {Object} site Site used for activation
* @param {Number} themeId Theme to be activated
Copy link
Contributor Author

Choose a reason for hiding this comment

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

themeIds are strings like twentysixteen or mood :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(There are a couple more instances of this JSDoc argument type in this commit that need fixing as well.)

* @return {Object} Action object
*/
export function activateTheme( theme, site ) {
export function themeActivation( themeId, siteId ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the reason for the rename? I'd rather stick with the verb-like activateTheme.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, probably so it's more in line with themeActivated and stuff like themeActivationFailed? Well what about themeActivate and themeActivateFailure? (failure -- being a noun -- is more consistent with success too, and also with action name constants).

Copy link
Contributor

Choose a reason for hiding this comment

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

themeActivation is just action creator.
activateTheme is still chosen name for function that activates themes 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Action names will still be renamed to have _REQUST part.
As for the naming I have actually struggled a bit.
Naming for function is problematic here as actions and functions using them have logically similar meaning.
So maybe activateTheme for function triggering activation, and a verbose version for action creator activateThemeRequest ( activateThemeRequestSuccess ... )?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

themeActivation is just action creator.
activateTheme is still chosen name for function that activates themes 😄

Ah right 😄 Well if themeActivation is really just a simple AC and only used from activateTheme, what about just inlining it?

search_term: null
};

export function activateTheme( themeId, siteId, trackThemesActivationData = defaultTrackData ) {
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 don't think the default really makes a lot of sense here since we'll always be passing a param for tracking here. If it's just for testing, I think we should rather create a dummy object in tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

That was only for testing. No default value is good because it will force devs to fill this in when they will want to use activate.

.post( '/rest/v1.1/sites/2211667/themes/mine', { theme: 'badTheme' } )
.reply( 404, {
error: 'unknown_theme',
message: 'Unknown theme'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nitpick -- I just used the developer console to see what I'd really get, and the actual error and message are theme_not_found and The specified theme was not found, respectively.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have assumed same values as in requestTheme. Corrected.

@ockham
Copy link
Contributor Author

ockham commented Nov 4, 2016

I'm liking what I see :-) I'm starting to realize how distracting the sheer size of this PR is, so I'm wondering -- should we try and rip out the new activation related actions into a separate PR so we can land those earlier?

@budzanowski
Copy link
Contributor

I would leave that decision to you. It is hard for me to judge if this changes can land on their own. They would still need reducers updated to match, and probably couple of more places. For sure it is better to split if it is possible

@ockham
Copy link
Contributor Author

ockham commented Nov 7, 2016

Yeah, I think I'm pretty sure we should split it out, and I think the changes it is going to require are doable. (This PR here OTOH is otherwise going to be a nightmare to review.)

budzanowski added a commit that referenced this pull request Nov 7, 2016
@budzanowski budzanowski mentioned this pull request Nov 7, 2016
5 tasks
budzanowski added a commit that referenced this pull request Nov 9, 2016
budzanowski added a commit that referenced this pull request Nov 10, 2016
@ockham ockham force-pushed the update/themes-redux-subtree branch 7 times, most recently from 09e64f2 to cbd7095 Compare November 18, 2016 16:20
@ockham ockham force-pushed the update/themes-redux-subtree branch from a8699c4 to af73a2a Compare December 14, 2016 18:09
@ockham ockham added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Dec 14, 2016
@ockham ockham merged commit 782f545 into master Dec 14, 2016
@ockham ockham deleted the update/themes-redux-subtree branch December 14, 2016 20:34
@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 14, 2016
@ockham ockham mentioned this pull request Mar 16, 2017
6 tasks
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.

4 participants