-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversation
3bb0124
to
3236c1c
Compare
3236c1c
to
b5fd268
Compare
} ); | ||
} ); | ||
|
||
describe( '#athemeActivationFailed()', () => { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
themeId
s are strings like twentysixteen
or mood
:-)
There was a problem hiding this comment.
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 ) { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
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
... )?
There was a problem hiding this comment.
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 ) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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? |
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 |
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.) |
09e64f2
to
cbd7095
Compare
Instead of THEMES_RECEIVE_SERVER_ERROR. Drop the latter.
a8699c4
to
af73a2a
Compare
… to getThemesLastPageForQuery
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 newthemes.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.
getTheme()
selector.TODO (later PRs):
hasFeature( FEATURE_UNLIMITED_PREMIUM_THEMES )
, e.g. for a8c-stickered sites (they're showing themes with prices on this branch right now!)To test: