PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 All 257 releases
← All changes | blocks/donation-form-grid/edit/block.js +14 -44 2.3.0 → 4.18.0 View file →
@@ -1,22 +1,15 @@
1 1 /**
2 - * External dependencies
2 + * WordPress dependencies
3 3 */
4 -import { isEmpty, pickBy, isUndefined } from 'lodash';
5 -import { stringify } from 'querystringify';
4 +import { Fragment } from '@wordpress/element';
5 +import ServerSideRender from '@wordpress/server-side-render';
6 +import {withSelect} from '@wordpress/data';
6 7
7 8 /**
8 - * Wordpress dependencies
9 - */
10 -const { __ } = wp.i18n;
11 -const { withAPIData } = wp.components;
12 -
13 -/**
14 9 * Internal dependencies
15 10 */
16 -import GiveBlankSlate from '../../components/blank-slate';
17 -import NoForms from '../../components/no-form';
18 -import FormGridPreview from './components/preview';
11 +import Inspector from './inspector';
19 12
20 13 /**
21 14 * Render Block UI For Editor
22 15 */
@@ -21,42 +14,19 @@
21 14 * Render Block UI For Editor
22 15 */
23 16
24 17 const GiveDonationFormGrid = ( props ) => {
25 - const { latestForms } = props;
26 - const { isLoading, data } = latestForms;
18 + const { attributes } = props;
27 19
28 - // Render block UI
29 - let blockUI;
30 -
31 - if ( isLoading || isUndefined( data ) ) {
32 - blockUI = <GiveBlankSlate title={ __( 'Loading...' ) } isLoader={ true } />;
33 - } else if ( isEmpty( data ) ) {
34 - blockUI = <NoForms />;
35 - } else {
36 - blockUI = <FormGridPreview
37 - html={ data }
38 - { ... { ...props } } />;
39 - }
40 -
41 - return ( <div className={ props.className } key="GiveDonationFormGridBlockUI">{ blockUI }</div> );
20 + return (
21 + <Fragment>
22 + <Inspector { ... { ...props } } />
23 + <ServerSideRender block="give/donation-form-grid" attributes={ attributes } />
24 + </Fragment>
25 + );
42 26 };
43 27
44 -/**
45 - * Export component attaching withAPIdata
46 - */
47 -export default withAPIData( ( props ) => {
48 - const { columns, showGoal, showExcerpt, showFeaturedImage, displayType } = props.attributes;
49 -
50 - const parameters = stringify( pickBy( {
51 - columns: columns,
52 - show_goal: showGoal,
53 - show_excerpt: showExcerpt,
54 - show_featured_image: showFeaturedImage,
55 - display_type: displayType,
56 - }, value => ! isUndefined( value )
57 - ) );
58 -
28 +export default withSelect( ( select ) => {
59 29 return {
60 - latestForms: `/${ giveApiSettings.rest_base }/form-grid/?${ parameters }`,
30 + forms: select( 'core' ).getEntityRecords( 'postType', 'give_forms' ),
61 31 };
62 32 } )( GiveDonationFormGrid );