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

Plans: add main plan component — PlanFeatures #6002

Merged
merged 15 commits into from
Jun 20, 2016
Merged

Conversation

lamosty
Copy link
Contributor

@lamosty lamosty commented Jun 13, 2016

Add PlanFeatures component as a part of bigger plans-redesign started in #5715.

Example usage

import PlanFeatures from 'my-sites/plan-features';
import { PLAN_FREE } from 'lib/plans/constants';
import QueryPlans from 'components/data/query-plans';

export default MyComponent() =>
   <div>
      <QueryPlans />
      <PlanFeatures plan={ PLAN_FREE } />
   </div>

Testing

  1. PlanFeatures was added to devdocs into App Components;
  2. Navigate to http://calypso.localhost:3000/devdocs/app-components/plan-features;
  3. See the redesigned plan components (free, premium and business);
  4. Look for errors;
  5. Is everything fine?

Screenshots

selection_022

selection_023

Note: In the second screenshot, the Business plan has a strange price. This is probably related to the recent PR #6001 by @gwwar but she's already working on a better solution here: #6046. That's why I've left it as it is.

If it is not related to that, I'll fix it.

Although this is still work in progress, I think I've arrived to a presentable code so please review. :)

cc @gwwar @rralian @mtias @artpi @retrofox

Test live: https://calypso.live/?branch=add/plan-features-plan

@lamosty lamosty added [Feature] Plans & Upgrades All of the plans on WordPress.com and flow for upgrading plans. [Status] In Progress labels Jun 13, 2016
@lamosty lamosty added this to the Plans: Maintenance milestone Jun 13, 2016
@lamosty lamosty self-assigned this Jun 13, 2016
@lamosty lamosty force-pushed the add/plan-features-plan branch 2 times, most recently from 7f8b8e1 to df44f61 Compare June 15, 2016 16:03
@lamosty lamosty added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jun 15, 2016
obj.plans.indexOf( planName ) !== -1
);

return sortBy( planFeatures, 'order' );
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand what you're doing here, but this may be somewhat difficult to maintain in the future. Maybe add a list of feature references to the plan object instead?

e.g.

    [ PLAN_FREE ]: {
        getFeatures: () => [ FEATURE_3GB_STORAGE, FEATURE_WP_SUBDOMAIN,  ... ]
        getTitle: () => i18n.translate( 'Free' ),
        getPriceTitle: () => i18n.translate( 'Free for life' ),
        getProductId: () => 1,
        getDescription: () => i18n.translate( 'Get a free blog and be on your way to publishing your first post in less than five minutes.' )
    },

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I thought we don't want to duplicate the references (as they are currently made from the opposite direction). But I'll implement this as I think it's a better solution. We also don't need the order prop in features because we can just order them in the array.

@gwwar
Copy link
Contributor

gwwar commented Jun 15, 2016

👍 Looking good so far. #6046 should fix the visual oddities with price. Let me know if you need help with new selectors.

@lamosty lamosty changed the title Plans: add main plan component — PlanFeatures (WIP Plans: add main plan component — PlanFeatures Jun 16, 2016
@lamosty lamosty force-pushed the add/plan-features-plan branch from db4e8f4 to b3a6452 Compare June 16, 2016 13:07
@lamosty
Copy link
Contributor Author

lamosty commented Jun 16, 2016

@gwwar Thanks for all the comments.

I've added the new selectors (in #6082) and rebased this PR on top of that PR so please ignore the noise. Does it look better? :)


[ FEATURE_WP_SUBDOMAIN ]: {
getTitle: () => i18n.translate( 'WordPress.com subdomain' ),
plans: [ PLAN_FREE ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm this could get out of sync too. If we need the reverse lookup maybe lets remove this, and add in helper function like:

getPlansForFeature( feature )

We could also memoize the results if this is called frequently

Copy link
Contributor Author

@lamosty lamosty Jun 20, 2016

Choose a reason for hiding this comment

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

Good point. Do we want to do it in this PR? I don't need the getPlansForFeature helper fn here, that's why I'm asking. I think it's better suited for a standalone PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can leave this for a future PR

@gwwar
Copy link
Contributor

gwwar commented Jun 16, 2016

Looking good! I left a few notes, but when you're ready, this is good to 🚢

@gwwar gwwar added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jun 16, 2016
@lamosty lamosty force-pushed the add/plan-features-plan branch 4 times, most recently from 22e953b to a0ec357 Compare June 20, 2016 14:37
@lamosty
Copy link
Contributor Author

lamosty commented Jun 20, 2016

@gwwar I've rebased this PR on top of master but I'm getting errors now (screenshots below) which I wasn't getting before. I started rebasing this on Friday (so the first rebase includes your #6046). After the first rebase, I think I got no new errors. However, I then pulled in new code in master today, rebased it again and now I'm getting the errors (screenshots below).

selection_026

The first part about state validation failed is a bit unknown to me (I only know that we store state to localForage and on loading it back we validate it — but I don't know what I should do with this error). The second part refers to my-sites/plan-features/index.jsx. I'm getting bill_period_label out of a plan object, like this:

billingTimeFrame: getPlan( state, planProductId ).bill_period_label

However, initially when there are no plans data, it probably fails because undefined.bill_period_label is not a thing (of course). Shouldn't we add the loading placeholder plan like it's currently being done on the /plans page?

@lamosty lamosty force-pushed the add/plan-features-plan branch from 37a15ab to 4c12470 Compare June 20, 2016 16:19
lamosty added 2 commits June 20, 2016 18:47
This component is dumb (ie receives props only) and will be rendered in PlanFeaturesList which will be a smart component.
lamosty added 12 commits June 20, 2016 18:47
+ some other minor modifications
... and remove partial components (ie PlanFeaturesHeader)
Fixes problems with translations being outside the render loop. Props
@gwwar for the idea.
In case we want to change header banner height, the top margin of the
popular plan is recalculated automatically.
This way, we drop dependency on legacy `lib/sites-list` and
`/sites/$site/plans` endpoint.
@lamosty lamosty force-pushed the add/plan-features-plan branch from 4c12470 to fa0633b Compare June 20, 2016 17:05
@lamosty lamosty force-pushed the add/plan-features-plan branch from aba65d5 to 375f0ff Compare June 20, 2016 17:28
@gwwar
Copy link
Contributor

gwwar commented Jun 20, 2016

:shipit:

@lamosty lamosty merged commit a25e262 into master Jun 20, 2016
@lamosty lamosty deleted the add/plan-features-plan branch June 20, 2016 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Plans & Upgrades All of the plans on WordPress.com and flow for upgrading plans.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants