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: Add site-selector modal to theme sheet #5354

Merged
merged 3 commits into from
May 19, 2016
Merged

Conversation

seear
Copy link
Contributor

@seear seear commented May 12, 2016

screen shot 2016-05-12 at 12 29 12

To Test

Expected: Site selector modal dialog should appear

  • pick a site
  • click Activate

Expected: URL will change to selected site, Thanks modal will appear

Expected: Site selector as before, which will end up at the checkout

@seear seear changed the title Themes: Add site-selector Themes: Add site-selector modal to theme sheet May 12, 2016
@seear seear added [Feature Group] Appearance & Themes Features related to the appearance of sites. [Status] In Progress labels May 12, 2016
@seear seear added this to the Themes: Showcase M4-ThemeSheets milestone May 12, 2016
@seear seear self-assigned this May 12, 2016
@seear seear force-pushed the add/theme-sheet-selector branch 2 times, most recently from a9aa252 to 813729c Compare May 17, 2016 13:30
@seear seear 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 May 17, 2016
minimumFractionDigits: 0,
} );
} else if ( price && price.display ) {
theme.price = price.display;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't they all have that display field? At least the premium ones?

@ockham
Copy link
Contributor

ockham commented May 18, 2016

I'd love if we could do without bf4a8c4, since the issue will hit us again for everything that runs i18n.translate in module scope on the server, and I don't think we should have to guard it in functions everywhere. Rather, I hope we can init i18n earlier. If we're lucky, we only need to change middleware order here. I'll see if that works.

@seear
Copy link
Contributor Author

seear commented May 18, 2016

since the issue will hit us again for everything that runs i18n.translate in module scope on the server

Is that common? Seems to me like this code is wrong in translating on build. If we ever sort out i18n on the server we will want to translate dynamically, no?

@ockham
Copy link
Contributor

ockham commented May 18, 2016

Hmm, interesting point. I guess I was inspired by copying client behavior, where IIRC i18n is set up during boot. Need to give that some more thought.

Anyway, this code seems to make the PR work without bf4a8c4: https://gist.github.com/ockham/24688ac1317220c23f5e8fbdc0d9b26a

@seear
Copy link
Contributor Author

seear commented May 19, 2016

@ockham: Should we go with bf4a8c4 or https://gist.github.com/ockham/24688ac1317220c23f5e8fbdc0d9b26a for the i18n?

I don't have a strong opinion either way.

@ockham
Copy link
Contributor

ockham commented May 19, 2016

I think the gist I posted initializes i18n at a level that's more consistent with client behavior, so I'd be inclined to go with that.

@seear
Copy link
Contributor Author

seear commented May 19, 2016

@ockham:

I've applied that gist to branch add/theme-sheet-selector-temp

Still getting following error:

/Users/seear/scratch/a8c_repos/wp-calypso/build/webpack:/client/lib/mixins/i18n/index.js:272
    return i18nState.jed[ jedMethod ].apply( i18nState.jed, jedArgs );
                     ^
TypeError: Cannot read property 'gettext' of undefined
    at getTranslationFromJed (/Users/seear/scratch/a8c_repos/wp-calypso/build/webpack:/client/lib/mixins/i18n/index.js:272:22)
    at Object.translate (/Users/seear/scratch/a8c_repos/wp-calypso/build/webpack:/client/lib/mixins/i18n/index.js:356:17)
    at Object.<anonymous> (/Users/seear/scratch/a8c_repos/wp-calypso/build/webpack:/client/my-sites/themes/action-labels.js:10:15)
    at __webpack_require__ (/Users/seear/scratch/a8c_repos/wp-calypso/build/webpack:/webpack/bootstrap 895f2a1ebdfac463d7a7:19:1)
    at Object.<anonymous> (/Users/seear/scratch/a8c_repos/wp-calypso/build/webpack:/client/my-sites/theme/main.jsx:35:81)
    at __webpack_require__ (/Users/seear/scratch/a8c_repos/wp-calypso/build/webpack:/webpack/bootstrap 895f2a1ebdfac463d7a7:19:1)
    at Object.<anonymous> (/Users/seear/scratch/a8c_repos/wp-calypso/build/webpack:/client/my-sites/theme/controller.jsx:7:33)
    at __webpack_require__ (/Users/seear/scratch/a8c_repos/wp-calypso/build/webpack:/webpack/bootstrap 895f2a1ebdfac463d7a7:19:1)
    at Object.<anonymous> (/Users/seear/scratch/a8c_repos/wp-calypso/build/webpack:/client/my-sites/theme/index.node.js:5:40)
    at __webpack_require__ (/Users/seear/scratch/a8c_repos/wp-calypso/build/webpack:/webpack/bootstrap 895f2a1ebdfac463d7a7:19:1)
make: *** [run] Error 1

Am I missing something?

@ockham
Copy link
Contributor

ockham commented May 19, 2016

Am I missing something?

No, my bad, since I forgot to unstub i18n in my gist. Since section modules are dynamically required in server/pages, while the i18n.init() call is wrapped in an app.get(), we'd probably need to move the i18n init to an even more global stage (further up in server/pages, or even server/boot), or make sure it's inside the same app.get() route handler.

However, I had another look inside client/lib/mixins/i18n, and I don't like what I see. There's a global singleton state thing that, among other things, holds the current locale. So moving i18n init to a more global stage is a definite no-no, or every user is going to end up getting pages with the locale the first user accessing Calypso after a deploy had. (I think we haven't seen that in wpcalypso yet due to limited usage, but we don't want to try that in production. I think it's possible to try in dev by starting Calypso, switching language, reloading the theme sheet, and inspecting page source.)

Not sure if this can be cleanly mitigated by moving the init to the more localized app.get() route handler, but I'm thinking our best bet for now will be to NMR i18n by something that returns { translate: identity }. This will allow us to unstub stuff like action-labels, and continue to use translate() elsewhere.

Not entirely sure about the i18n mixin and localize yet, tho. Maybe this warrants a GH issue of its own, in which case I guess it's fine to merge this PR -- but without squashing the action-labels commit with the others so we can more easily revert later.

@ockham
Copy link
Contributor

ockham commented May 19, 2016

Or maybe I'm overthinking :-D Turns out i18n.initialize() -- without a bootstrap parameter falls back to the default language as specified in config. So probably not that harmful to have that in a global state on the server after all...

@seear
Copy link
Contributor Author

seear commented May 19, 2016

it's fine to merge this PR -- but without squashing the action-labels commit with the others so we can more easily revert later.

ok, I'll squash into two commits and merge.

I don't think we need to worry about i18n.initialize() too much until we start using anything other than the default locale on the server.

@ockham
Copy link
Contributor

ockham commented May 19, 2016

Pushed another commit to the temp branch that fixes i18n init by moving to server/pages module state, which I now think should be fine.

@seear seear force-pushed the add/theme-sheet-selector branch from 1aabd15 to cb1f396 Compare May 19, 2016 15:38
seear and others added 3 commits May 19, 2016 16:41
* Add sourcePath prop to site-selector for specifying the redirect target.
* Use v1.2 themes API price format in details selector to allow price to work with selector
@seear seear force-pushed the add/theme-sheet-selector branch from cb1f396 to 7e5fef6 Compare May 19, 2016 15:44
@seear seear merged commit b5c6846 into master May 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 May 19, 2016
@seear seear deleted the add/theme-sheet-selector branch May 19, 2016 15:47
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.

3 participants