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

Purchases: Add option to remove expiring purchases #2602

Merged
merged 21 commits into from
Jan 26, 2016

Conversation

drewblaisdell
Copy link
Contributor

Fixes #1402 by adding an option to ManagePurchase that opens a dialog to remove an expiring purchase.

screen shot 2016-01-19 at 4 59 25 pm

Testing

  • Point your hosts file at your sandbox.
  • Apply this patch: D906-code
  • Visit /purchases/:site/:purchase_id for a site/purchase that has auto-renew disabled and is outside the refund period.
  • You should see an option to 'Remove [product]'. Clicking it will open the dialog above.
  • Click 'Remove' and assert that the buttons are disabled, and that you are eventually redirected to /purchases with a notice indicating that the purchase was removed.
  • Assert that the purchase that was removed no longer appears in the list below.
  • Product review
  • Code review

@drewblaisdell drewblaisdell added [Status] In Progress [Type] Task [Feature] Purchase Management Related to managing purchases such as subscriptions, plans, history, auto-renew, cancellation, etc. labels Jan 20, 2016
@drewblaisdell drewblaisdell changed the title Purchases: Add option to remove a purchase Purchases: Add option to remove expired purchases Jan 20, 2016
@drewblaisdell drewblaisdell self-assigned this Jan 20, 2016

getInitialState() {
return {
isDialogOpen: false
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we name this property showDialog as we did in other components? That's also what the readme file suggests in its examples.

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'm a fan of prefixing boolean values with "is" to indicate that they are boolean. showDialog without context sounds like it actually shows the dialog (like closeDialog, which is a method name this file uses). A couple checkout components use isDialogVisible for this value, presumably for the same reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm this sort of fan as well - I just wanted to stay consistent with the rest of our code. Looks like you updated it to isDialogVisible, that's perfect.

@drewblaisdell drewblaisdell changed the title Purchases: Add option to remove expired purchases Purchases: Add option to remove expiring purchases Jan 20, 2016
@drewblaisdell drewblaisdell force-pushed the add/remove-option-purchases branch 4 times, most recently from 361fa31 to b7a4342 Compare January 21, 2016 01:31
@drewblaisdell
Copy link
Contributor Author

One outstanding issue here (possibly the only one) is that when the /me/purchases/:purchase_id/remove endpoint returns new purchases, these new purchases are added to PurchasesStore, but the purchase that was removed remains in memory and still appears on PurchasesList until the page is refreshed.

@@ -21,6 +22,7 @@ import NoticeAction from 'components/notice/notice-action';
import { oldShowcaseUrl } from 'lib/themes/helpers';
import paths from '../paths';
import PaymentLogo from 'components/payment-logo';
import RemovePurchase from '../remove-purchase';
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be one line below in order to keep imports sorted.

@mikeshelton1503
Copy link
Contributor

For the remove option, let's use the Trash pattern by adding the trash can icon. Also, let's remove the arrow icon from the right since it's not going taking you to a new screen:

image

@stephanethomas
Copy link
Contributor

I've removed some old code, fixed expired purchases that weren't taken into account, and updated the remove link to look as requested.

@drewblaisdell drewblaisdell force-pushed the add/remove-option-purchases branch 2 times, most recently from 5b25c11 to da94c39 Compare January 22, 2016 01:05
@drewblaisdell drewblaisdell 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 Jan 22, 2016
@drewblaisdell
Copy link
Contributor Author

Thanks @stephanethomas. I added da94c39 to remove purchases from the PurchasesStore when they are not present in the response from either endpoint that returns purchases. This should be ready for review now.


return (
<CompactCard className="remove-purchase__card" onClick={ this.openDialog }>
<a >
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stephanethomas Do you think it is better to use an anchor with no href attribute here, or use cursor: pointer;?

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem with using an hrefattribute in this anchor is that the cursor will only change if you hover the link itself whereas we probably want to change it whenever the cursor enters the card (especially since the onclick event applies to the whole card). So cursor: pointer; would be needed anyway (@ebinnion or @lezama: that's probably something you want to fix in the <DeleteUser /> component).

Note I had to inject this anchor in this CompactCard because I wasn't able to use its href prop in a way which would give me similar results.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note I don't mind adding href="#" to this anchor since this is pretty much a convention. If not, we should get rid of this unnecessary white space though.

@fabianapsimoes
Copy link
Contributor

We have a different copy for the dialog when removing domains (#1402 (comment)):

Remove [domain name]
This will remove [domain name] from your account. By removing, you are canceling the domain registration. This may stop you from using it again, even with another service.

Right now, it shows the same copy for all kinds of upgrades:

screenshot-calypso localhost 3000 2016-01-22 12-19-38

I wonder if we should tweak the confirmation notice as well. Right now it says The purchase was removed from [site], but maybe we want to give more context for domain removals? Not sure. cc @mikeshelton1503

@fabianapsimoes fabianapsimoes added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jan 22, 2016
@fabianapsimoes
Copy link
Contributor

This doesn't look great in smaller screens if the domain name is a bit long:

screenshot-calypso localhost 3000 2016-01-22 12-21-38

@fabianapsimoes
Copy link
Contributor

I tried removing the domain fabianaupgrades20151120125457.net from my account, but that left the Domain Mapping associated to it behind:

screenshot-calypso localhost 3000 2016-01-22 12-25-05

I haven't been able to test this with a domain that had privacy enabled as well. I'd expect that to leave a subscription in the admin tools which won't be displayed in /purchases.

Edit: Just tested that case. It does exactly what I expected above ^.

@fabianapsimoes
Copy link
Contributor

Right now, removing a plan will leave the domain associated to it behind. That can be confusing to users looking to get rid of all their purchases with WordPress.com. We should add some messaging explaining the domain will remain in the account. cc @mikeshelton1503

@fabianapsimoes
Copy link
Contributor

Related to the issue I reported here, I noticed that removing a domain does not cancel its registration. I've tested this with both testingupgrades.org and fabianaupgrades20151120125457.net, and the registrations should have been canceled with WWD.

@fabianapsimoes
Copy link
Contributor

@Lochlaer I'm curious how well this flow works for Google Apps. Could you give it a try?

You should see:

  • "Cancel and Refund" within the refund window, which will remove the subscriptions and trigger a refund.
  • "Cancel" outside of the refund window, which will just disable auto-renewal and leave the subscriptions behind, still active until expiration.
  • "Remove" also outside the refund window after clicking "Cancel" (it might take a few seconds for the option to appear). This will remove the subscriptions and should terminate Google Apps use.

Seems everything works as expected on WordPress.com. Is it all OK from Google's end as well?

@stephanethomas
Copy link
Contributor

I have updated the dialog to display a custom text for domain registrations. I have also fixed the heading on small screens. I'm not a big fan of this fix but otherwise it would mean updating styles from the <Dialog /> shared component - something that is always tricky (note we used a similar approach in the checkout).

@fabianapsimoes fabianapsimoes added [Status] Ready to Merge and removed [Status] Needs Design Review Add this when you'd like to get a review / feedback from the Design team on your PR [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jan 26, 2016
drewblaisdell and others added 21 commits January 26, 2016 11:08
…se page

We don't need this text any longer since we moved removal of purchase into a dedicated component.
Users should now be able to remove any purchase that is not subscribed expect when it is included in a plan.
This also removes the chevron on the right.
Previously, purchases that were absent from the request to
`/me/purchases` were kept in memory.
…ge Purchase page

This fixes a display issue that happens with small screens when the product name or the domain name are too long.
… Purchase page

This fixes a display issue that happens with small screens when the product name or the domain name are too long and can't be wrapped.
…Purchase page

This also adds a default url to an empty anchor.
This adds the name of the purchase - except for domains where this removes the site url - to match the copy used in the dialog. This also removes an unnecessary component in a translation as well as a variable.
This also adds information for translators and removes a tag that cannot contain block-level elements.
@drewblaisdell drewblaisdell force-pushed the add/remove-option-purchases branch from 4e058a6 to 4eb6160 Compare January 26, 2016 19:09
drewblaisdell added a commit that referenced this pull request Jan 26, 2016
Purchases: Add option to remove expiring purchases
@drewblaisdell drewblaisdell merged commit 9790bc7 into master Jan 26, 2016
@drewblaisdell drewblaisdell deleted the add/remove-option-purchases branch January 26, 2016 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Purchase Management Related to managing purchases such as subscriptions, plans, history, auto-renew, cancellation, etc. [Type] Task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants