-
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
ThemesSiteSelectorModal: Fix siteSlug value of null, take two #9368
ThemesSiteSelectorModal: Fix siteSlug value of null, take two #9368
Conversation
@ockham is there a status update on this PR? |
I'll try to get to it this week. |
6d9c9b6
to
4987cee
Compare
Seems we don't need this to fix #9298 after all now, see #9298 (comment). There's a chance we still need it for #14896, but let's re-evaluate once we get to that. |
Spoke too soon. We need these changes even for a simple UI fix, since |
Testing Notes: master This branch |
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.
Raised a couple of questions, but this seems sensible. :)
@@ -83,12 +83,12 @@ const ThemesSiteSelectorModal = React.createClass( { | |||
* but only if it also has a header, because the latter indicates it really needs | |||
* a site to be selected and doesn't work otherwise. | |||
*/ | |||
wrapOption( option ) { | |||
wrapOption( option, name ) { |
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 two occurrences in this component of wrapOption
being called with one argument. Should we fix them to provide a name
? Or have the method default to some value for undefined name
?
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.
D'oh, good spot. What we need is the corresponding object key. I'll fix that.
return Object.assign( | ||
{}, | ||
option, | ||
option.header | ||
? { action: themeId => this.showSiteSelectorModal( option, themeId ) } | ||
? { action: themeId => this.showSiteSelectorModal( name, themeId ) } |
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.
Arguably something to tackle separately, but, since wrapOption
is called within the render
stack, it would be cool to avoid instantiating functions here — preferably only passing data or, at the very least, preëxisting* bound methods.
*: can't resist them diæreses…
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.
Yep, agree. In a way, that's what I'm fixing with this PR here. If there's an easy solution you can think of off the top of your head, I'd be curious to hear 😄
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.
Tested, looks good to me
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.
Code looks good 👍
<Button | ||
primary | ||
key="mainAction" | ||
disabled={ ! 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.
hm, if ! siteId
, then url
is falsy, so we don't reach this code? On the other hand it is nice the way you use the same ! siteId
logic in both branches, so I guess this is fine.
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.
👍
Still need this one @ockham ? |
We we still planning to merge this one? Thanks |
I'll try and look into it on Thu! |
@ockham Any more movement here? This is the oldest open PR in the whole project, we should make a decision to either move on it, or move on. |
Looks like I can't find the time to move on it. Closing it. |
Have
<ThemesSiteSelectorModal />
store only the current option's name (instead of the entire option object) in component state. This way, when Redux state updates, the component'soptions
prop will update and cause a re-render with updatedgetUrl
andaction
fields.To test:
null
instead of the selected site #9298 is fixed. (Also make sure to reproduce that issue onmaster
. Remember to log out and in again each time or you won't be able to repro!)Reverts #9367