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

Theme Sheet: Use information from WordPress.org for themes on Jetpack sites #9875

Merged
merged 27 commits into from
Dec 12, 2016

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Dec 7, 2016

Allows us to find out if a theme on a Jetpack site is present on WP.org and act accordingly.

Implements #9869 (comment):

  1. Show the tags in the features, but unlinked? ✅
  2. Remove download as it would imply "download from Jetpack site" and doesn't seem entirely accurate to me. -- I've kept it for now since I thought it might still be useful -- my counter-example being a Jetpress site that was recently transferred and is using a WPCOM theme the user might also want to use elsewhere. Oh well, a bit contrived, I guess 😄
  3. You might also like: could [s]tay, but let's get without it for now. ✅
  4. Support...

(Question about item 4. -- I'm not sure I've implemented it correctly, I'm currently not removing the entire 'Support' tab but only the link to the theme forum. I wasn't sure I understood the idea correctly, and I thought the other two links might still make some sense even on a JP site. Clarification needed 😄)

To do all that, this PR:

  • Adds a fetchThemeInformation method to lib/wporg
  • Changes requestTheme to hit that endpoint if siteId === 'wporg', thus putting themes fetched from there in a new wporg subtree
  • Adds a normalization util to account for different attribute names in objects obtained from the WP.org API
  • Changes the getTheme selector so that if a theme on a JP site is requested, supplementary data (upon availability) such as demo URI, download URI, or taxonomies is merged into the returned object.
  • Adds an isWporgTheme( state, themeId ) aliasing !! getTheme( state, 'wpcom', themeId )
  • Modifies the theme sheet to conditionally hide some UI elements (such as the 'Open Live Demo' link) if some given theme attributes aren't available (for cases where no data from WP.org was available).

To test:

  • Try the theme sheet on a Jetpack site, ideally for a theme that's not on WPCOM. Try two different themes, one that is on WP.org, and one that isn't.
  • WP.org theme: Check that the following UI elements are present and work properly:
    • 'Open Live Demo' link
    • 'Download' button
    • Theme Features (but they don't link anywhere!)
    • Related theme suggestions are not there
    • 'Visit forum' link in the 'Support' tab should point to theme-specific forum on WP.org
  • non-WP.org theme: None of the above UI elements should be present
  • Also check that wpcom theme sheets still work as before.

(For reference, here's an example response containing all the fields we can get from WP.org: https://api.wordpress.org/themes/info/1.1/?action=theme_information&request%5Bslug%5D=twentyfourteen)

@ockham ockham added [Feature Group] Appearance & Themes Features related to the appearance of sites. [Status] In Progress labels Dec 7, 2016
@ockham ockham added this to the Themes: JetPress Rally milestone Dec 7, 2016
@ockham ockham self-assigned this Dec 7, 2016
@matticbot
Copy link
Contributor

matticbot commented Dec 7, 2016

@ockham ockham force-pushed the add/theme-info-fetching-from-wporg branch 4 times, most recently from ae46bfe to f9ac0e8 Compare December 8, 2016 13:56
@ockham ockham changed the title Themes: Enable fetching of theme information from WordPress.org Theme Sheet: Use information from WordPress.org for themes on Jetpack sites Dec 8, 2016
@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 8, 2016
@@ -12,10 +12,7 @@ import { isRequestingActiveTheme } from 'state/themes/selectors';

class QueryActiveTheme extends Component {
static propTypes = {
siteId: PropTypes.oneOfType( [
PropTypes.number,
PropTypes.oneOf( [ 'wpcom' ] )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A theme can only be active on an actual site, not on all of WP.com 😄

(Discovered while adding wporg to some other propTypes and schemas.)

@seear
Copy link
Contributor

seear commented Dec 9, 2016

We may want to hide the Features block if it is empty:

screen shot 2016-12-09 at 13 24 36

Copy link
Contributor

@budzanowski budzanowski left a comment

Choose a reason for hiding this comment

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

Code wise looks good, although hard to follow: to much stuff is going on at the same time. 👍

Copy link
Contributor

@seear seear left a comment

Choose a reason for hiding this comment

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

Code looks good. I've tested with both wporg and custom themes on a Jetpack site.

Only glaring thing is the empty Features panel.

// * If it's a premium theme
// * If it's on a Jetpack site, and the theme object doesn't have a 'download' attr
// Note that not having a 'download' attr would be permissible for a theme on WPCOM
// since we don't provide any for some themes found on WordPress.org (notably the 'Twenties').
Copy link
Contributor

Choose a reason for hiding this comment

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

(notably the 'Twenties')

Think it is just Twenty Sixteen

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 checked a bunch of other Twenties to which the same seems to apply, but possibly not all of them.

@@ -451,6 +469,7 @@ const ThemeSheet = React.createClass( {
return (
<Main className="theme__sheet">
<QueryTheme themeId={ this.props.id } siteId={ siteIdOrWpcom } />
{ isJetpack && <QueryTheme themeId={ this.props.id } siteId="wporg" /> }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the two instances of <QueryTheme/>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, the first one fetches the theme object from the JP site, and the second one fetches the supplementary one from the WP.org API.

context( 'with a wpcom site', () => {
useNock( ( nock ) => {
nock( 'https://public-api.wordpress.com:443' )
.persist()
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think these persist calls are generally necessary unless you want the same result multiple times.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Breaks tests if I remove it for all wpcom, wporg, and JP 😕

@ockham
Copy link
Contributor Author

ockham commented Dec 9, 2016

Code wise looks good, although hard to follow: to much stuff is going on at the same time. 👍

Yeah, sorry about that. I guess I could've split it into even more PRs, but then again, I already did that twice, so I wanted to get it done...

@ockham ockham force-pushed the add/theme-info-fetching-from-wporg branch 2 times, most recently from 839faf9 to 5404e83 Compare December 9, 2016 16:03
@ockham ockham force-pushed the add/theme-info-fetching-from-wporg branch 2 times, most recently from 4eedad4 to 4276754 Compare December 9, 2016 16:48
@ockham ockham force-pushed the add/theme-info-fetching-from-wporg branch from 6e80e0f to 738baab Compare December 9, 2016 17:24
@ockham
Copy link
Contributor Author

ockham commented Dec 9, 2016

We may want to hide the Features block if it is empty

Done in 8cbee7e

Copy link
Contributor

@seear seear left a comment

Choose a reason for hiding this comment

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

:shipit:

@ockham
Copy link
Contributor Author

ockham commented Dec 9, 2016

(Mini-fix to schema.js to get rid of a state validation warning.)

const term = isValidTerm( item.slug ) ? item.slug : `feature:${ item.slug }`;
return (
<li key={ 'theme-features-item-' + item.slug }>
<a href={ `/design/filter/${ term }/${ siteSlug || '' }` }>{ item.name }</a>
{ isJetpack
? <a>{ item.name }</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious if adding the <a> is actually doing anything here. Are styles applied to it because its an anchor?
Maybe it could just be { item.name }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we're styling it. (I had removed it and noticed it didn't look the same.) I opted for keeping the element instead of tweaking the styling 😄

@ockham ockham merged commit 47f1a19 into master Dec 12, 2016
@ockham ockham deleted the add/theme-info-fetching-from-wporg branch December 12, 2016 12:48
@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 12, 2016
@folletto
Copy link
Contributor

Remove download as it would imply "download from Jetpack site" and doesn't seem entirely accurate to me. -- I've kept it for now since I thought it might still be useful -- my counter-example being a Jetpress site that was recently transferred and is using a WPCOM theme the user might also want to use elsewhere. Oh well, a bit contrived, I guess

Keep it only if it's already working flawlessly. If you need even just 10 minutes of extra work to make it work across .com/Jetpack (how does Jetpack zip the theme to allow its download?) remove it. It's not a priority right now.

Question about item 4. -- I'm not sure I've implemented it correctly, I'm currently not removing the entire 'Support' tab but only the link to the theme forum. I wasn't sure I understood the idea correctly, and I thought the other two links might still make some sense even on a JP site. Clarification needed 😄

Ok, let me branch it out! :)

For Jetpack:

  1. If it's a local / uploaded / custom theme → the Support tab disappears as we can't provide support from .com, nor we know if there's a .org forum.
  2. If it's a Business User → show the tab with only renderContactUsCard ("Need extra help?")

@ockham
Copy link
Contributor Author

ockham commented Dec 12, 2016

Keep it only if it's already working flawlessly. If you need even just 10 minutes of extra work to make it work across .com/Jetpack (how does Jetpack zip the theme to allow its download?) remove it. It's not a priority right now.

Oh, maybe I wasn't quite clear -- we're only showing the Download link if the theme is found on WP.org, and has a download URI (pointing to a ready-made zip, that is) already. Otherwise we're hiding it.

@folletto
Copy link
Contributor

Oh, maybe I wasn't quite clear -- we're only showing the Download link if the theme is found on WP.org, and has a download URI (pointing to a ready-made zip, that is) already. Otherwise we're hiding it.

Ok cool, I thought the whole "check .org's availability" was postponed. :)

Excellent then! :D

@ockham
Copy link
Contributor Author

ockham commented Dec 12, 2016

For Jetpack:

Ok cool, I thought the whole "check .org's availability" was postponed. :)

Hehe, no, that's what this PR does 😄 (cf. #9869 (comment)):

I thought initially that the is-on-dotorg check might be a bit too difficult to implement given that we're on a rather tight schedule, but some tinkering (#9875) revealed that it's probably not that hard after all.

@ockham
Copy link
Contributor Author

ockham commented Dec 12, 2016

If it's a local / uploaded / custom theme → the Support tab disappears as we can't provide support from .com, nor we know if there's a .org forum.

Oh, I was trying to implement #9869 (comment)

My suggestion would be:

So if you look at the 'Support' tab's forum link for a theme on a JP site that's also found on WP.org, it will point to that theme's WP.org support forum right now.

@folletto
Copy link
Contributor

So if you look at the 'Support' tab's forum link for a theme on a JP site that's also found on WP.org, it will point to that theme's WP.org support forum right now.

Same as the above. I was working on the assumption .org's checking wasn't included right now, in that case:

  1. If there is a .org forum, show its block.
  2. If there is Business Plan enabled, show its block.
  3. If the Support tab is empty (none of the above) hide it.

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.

6 participants