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

Simple Payments: gutenberg block UI #28169

Merged
merged 35 commits into from
Nov 6, 2018
Merged

Conversation

simison
Copy link
Member

@simison simison commented Oct 30, 2018

Adds basic UI for Simple payments Gutenberg block.

Screenshots

UI:

UI screaming warnings:

Preview in editor:

End result at the site:

Todo / known issues

  • Merge API changes Simple payments: allow read+write access to meta fields via REST API jetpack#10402
  • Land D19907-code
  • Missing input error states
    • Improve or add value validation in the block and in the API
    • Highlighting invalid inputs after block de-select
    • Show errors coming from the API
  • Small styling adjustments to other elements:
    • Email help text font size
    • horizontal alignment of currency and price inputs
  • Link "PayPal" word in email help text to paypal.com
  • PayPal image in preview mode doesn't work; need to figure out how to ship png files
  • Limit prices to >= 1.00
  • when I unfocus the block, my 0.5 USD becomes $0.00 (this is probably because of the backend that sanitizes prices to integers right now)
  • Cleanup view.scss — now it's just copied over from Jetpack plugin and we need very little from it for the preview
  • Block is always enabled regardless of the site plan (Poseidon)

Testing instructions

Test in Jetpack

Test in Calypso

Manual checking

Apply these patches and cross-test the block in different editors:

@simison simison added Simple Payments [Goal] Gutenberg Working towards full integration with Gutenberg labels Oct 30, 2018
@simison simison self-assigned this Oct 30, 2018
@matticbot
Copy link
Contributor

matticbot commented Oct 30, 2018

@simison simison force-pushed the add/gutenpack-simplepayments-ui branch 2 times, most recently from b3882eb to 53eecd6 Compare October 30, 2018 23:19
@thomasguillot
Copy link
Contributor

I recorded a screencast that highlights a few issues I noticed:

https://cloudup.com/cM30s7LEbQd

  • The allow multiple items doesn't seem to work
  • The currency seems to be stuck on USD
  • Prices with a decimal are being truncated (e.g. £0.50 becomes £0.00)
  • PayPal price doesn't always update

@simison simison force-pushed the add/gutenpack-simplepayments-ui branch from 53eecd6 to 3873de1 Compare October 31, 2018 13:12
@simison
Copy link
Member Author

simison commented Oct 31, 2018

@roccotripaldi FYI: I tried to register this block using JetpackBlockType but seems like simple-payments isn't a real module and thus the availability check always returns falsy in Jetpack. :-/

import JetpackBlockType from 'gutenberg/extensions/presets/jetpack/utils/jetpack-block-type';

const SimplePaymentsBlock = new JetpackBlockType( 'simple-payments', {
	// ...
} );

SimplePaymentsBlock.register();

@brbrr
Copy link
Contributor

brbrr commented Oct 31, 2018

Small alignment nitpick:

edit post brbrr s test blogzqaaasd wordpress com 2018-10-31 15-23-38

@simison simison requested review from rodrigoi, a team and thomasguillot November 1, 2018 22:06
@simison simison 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 Nov 1, 2018
@simison simison force-pushed the add/gutenpack-simplepayments-ui branch from 41082c9 to c0fe79e Compare November 2, 2018 14:40
@simison
Copy link
Member Author

simison commented Nov 2, 2018

This is pretty close to being ready.

It's missing some error states that might be coming from the API but validations at the frontend already work.

It's unclear to me if prices need to be limited to >= 1.00 as currently Simple Payments in Calypso doesn't limit prices like that.

There might be some accessibility improvements we can still do.

The block also loads even for simple plans; a mechanism to stop that happening is still in the works elsewhere.

@brbrr which browser are you using? I couldn't replicate the alignment issue.

@simison
Copy link
Member Author

simison commented Nov 2, 2018

Looks like there's a small bug where currency doesn't get set to default "USD" unless you change it to something else first.

@MichaelArestad
Copy link
Contributor

image

This error message is a bit dramatic. Can we make it say something like:

Please add the name of the product you are selling.

@MichaelArestad
Copy link
Contributor

image

The textarea doesn't have a border, but is resizable. Perhaps we can use Gutenberg's Paragraph block here instead?

@MichaelArestad
Copy link
Contributor

image

Let's make the error message align with the other error messages. I do understand it is just for the price. I think the copy is slightly better here. We will flag this for copy review after a little iteration.

@MichaelArestad
Copy link
Contributor

image

Can the error message go away as soon as I start typing in that field? (and for the others)

@thomasguillot
Copy link
Contributor

image

Can the error message go away as soon as I start typing in that field? (and for the others)

The idea was to trigger the error messages when we unfocus an unfilled block (kind of like a submit button with a form).

Maybe when we refocus and start filling the fields, the message could/should disappear?

client/gutenberg/extensions/simple-payments/edit.jsx Outdated Show resolved Hide resolved
formattedPrice: {
type: 'string',
default: '',
},
multiple: {
type: 'number',
Copy link
Member

Choose a reason for hiding this comment

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

Related: Automattic/jetpack#10402 (comment)

I'd like to isolate API concerns from component logic. Indicating this is a number is confusing, I'm happy to add toApi/fromApi as necessary.

@sirreal sirreal force-pushed the add/gutenpack-simplepayments-ui branch from 11d63cf to 039d927 Compare November 6, 2018 10:37
Maintain .js extension so diff is clearer.
This was causing a warning. defaultValue is for uncontrolled components.

With the Gutenberg default attribute value, the currency should be
correctly defined.
sirreal
sirreal previously approved these changes Nov 6, 2018
Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

I tested this on a Jetpack site with Automattic/jetpack#10402 and it's working nicely.

I want to confirm Simple Payments in the classic editor continue to work as expected with the default changes, then let's ship and iterate!

@sirreal sirreal dismissed their stale review November 6, 2018 11:36

Intended as comment, not approval.

Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

Simple payments continue to work as expected.

Let's wait for e2e and 🚢 🚢 🚢

@sirreal sirreal added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] Ready to Merge and removed [Status] In Progress [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Nov 6, 2018
@simison simison merged commit 8ed68be into master Nov 6, 2018
@simison simison deleted the add/gutenpack-simplepayments-ui branch November 6, 2018 13:13
@simison
Copy link
Member Author

simison commented Nov 6, 2018

Small alignment nitpick:

edit post brbrr s test blogzqaaasd wordpress com 2018-10-31 15-23-38

Seems to be caused by styles leaking in from Calypso-Gutenberg, opened an issue: #28309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Goal] Gutenberg Working towards full integration with Gutenberg Simple Payments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants