Skip to content

Commit

Permalink
Simple Payments: gutenberg block UI (#28169)
Browse files Browse the repository at this point in the history
  • Loading branch information
simison authored Nov 6, 2018
1 parent 54aa7ff commit 8ed68be
Show file tree
Hide file tree
Showing 14 changed files with 618 additions and 227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import {
import EmptyContent from 'components/empty-content';
import Banner from 'components/banner';
import canCurrentUser from 'state/selectors/can-current-user';
import { DEFAULT_CURRENCY } from 'lib/simple-payments/constants';

// Utility function for checking the state of the Payment Buttons list
const isEmptyArray = a => Array.isArray( a ) && a.length === 0;
Expand Down Expand Up @@ -152,7 +153,7 @@ class SimplePaymentsDialog extends Component {
title: '',
description: '',
price: '',
currency: 'USD',
currency: DEFAULT_CURRENCY,
multiple: false,
email: '',
featuredImageId: null,
Expand Down Expand Up @@ -219,7 +220,7 @@ class SimplePaymentsDialog extends Component {
}
}

const initialCurrency = currencyCode || 'USD';
const initialCurrency = currencyCode || DEFAULT_CURRENCY;
const initialEmail = get( paymentButtons, '0.email', currentUserEmail );

return { ...initialFields, currency: initialCurrency, email: initialEmail };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/**
* /* eslint-disable wpcalypso/jsx-classname-namespace
*
* @format
*/
/** @format */

/**
* External dependencies
Expand All @@ -23,6 +19,9 @@ import FormRadio from 'components/forms/form-radio';
import log from 'lib/catch-js-errors/log';
import PopoverMenuItem from 'components/popover/menu-item';
import ProductImage from './product-image';
import { DEFAULT_CURRENCY } from 'lib/simple-payments/constants';

/* eslint-disable wpcalypso/jsx-classname-namespace */

class ProductListItem extends Component {
static propTypes = {
Expand All @@ -41,7 +40,7 @@ class ProductListItem extends Component {
handleEditClick = () => this.props.onEditClick( this.props.paymentId );
handleTrashClick = () => this.props.onTrashClick( this.props.paymentId );

formatPrice( price, currency = 'USD' ) {
formatPrice( price, currency = DEFAULT_CURRENCY ) {
if ( isNaN( price ) ) {
log( 'Simple Payments: invalid price value', {
siteId: this.props.siteId,
Expand Down
4 changes: 0 additions & 4 deletions client/gutenberg/editor/edit-post/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ if ( isEnabled( 'gutenberg/block/jetpack-preset' ) ) {
require( 'gutenberg/extensions/presets/jetpack/editor.js' );
}

if ( isEnabled('gutenberg/block/simple-payments') ) {
require( 'gutenberg/extensions/simple-payments/editor.js' );
}

function Editor( { settings, hasFixedToolbar, post, overridePost, onError, ...props } ) {
if ( ! post ) {
return null;
Expand Down
1 change: 1 addition & 0 deletions client/gutenberg/extensions/presets/jetpack/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ import './editor-shared/block-category'; // Register the Jetpack category
import 'gutenberg/extensions/markdown/editor';
import 'gutenberg/extensions/publicize/editor';
import 'gutenberg/extensions/related-posts/editor';
import 'gutenberg/extensions/simple-payments/editor';
import 'gutenberg/extensions/tiled-gallery/editor';
3 changes: 2 additions & 1 deletion client/gutenberg/extensions/presets/jetpack/index.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
"markdown",
"publicize"
"publicize",
"simple-payments"
]
Loading

0 comments on commit 8ed68be

Please sign in to comment.