| @@ -1,22 +1,14 @@ | ||
| 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 | 6 | |
| 7 | 7 | /** |
| 8 | - * Wordpress dependencies | |
| 9 | - */ | |
| 10 | -const { __ } = wp.i18n; | |
| 11 | -const { withAPIData } = wp.components; | |
| 12 | - | |
| 13 | -/** | |
| 14 | 8 | * Internal dependencies |
| 15 | 9 | */ |
| 16 | -import GiveBlankSlate from '../../components/blank-slate'; | |
| 17 | -import NoForms from '../../components/no-form'; | |
| 18 | -import DonorWallPreview from './components/preview'; | |
| 10 | +import Inspector from './inspector'; | |
| 19 | 11 | |
| 20 | 12 | /** |
| 21 | 13 | * Render Block UI For Editor |
| 22 | 14 | */ |
| @@ -21,45 +13,18 @@ | ||
| 21 | 13 | * Render Block UI For Editor |
| 22 | 14 | */ |
| 23 | 15 | |
| 24 | 16 | const GiveDonorWall = ( props ) => { |
| 25 | - console.log( props ) | |
| 26 | - const { latestForms } = props; | |
| 27 | - const { isLoading, data } = latestForms; | |
| 17 | + const { attributes } = props; | |
| 28 | 18 | |
| 29 | - // Render block UI | |
| 30 | - let blockUI; | |
| 31 | - | |
| 32 | - if ( isLoading || isUndefined( data ) ) { | |
| 33 | - blockUI = <GiveBlankSlate title={ __( 'Loading...' ) } isLoader={ true } />; | |
| 34 | - } else if ( isEmpty( data ) ) { | |
| 35 | - blockUI = <NoForms />; | |
| 36 | - } else { | |
| 37 | - blockUI = <DonorWallPreview | |
| 38 | - html={ data } | |
| 39 | - { ... { ...props } } />; | |
| 40 | - } | |
| 41 | - | |
| 42 | - return ( <div className={ props.className } key="GiveDonorWallBlockUI">{ blockUI }</div> ); | |
| 19 | + return ( | |
| 20 | + <Fragment> | |
| 21 | + <Inspector { ... { ...props } } /> | |
| 22 | + <ServerSideRender block="give/donor-wall" attributes={ attributes } /> | |
| 23 | + </Fragment> | |
| 24 | + ); | |
| 43 | 25 | }; |
| 44 | 26 | |
| 45 | -/** | |
| 46 | - * Export component attaching withAPIData | |
| 47 | - */ | |
| 48 | -export default withAPIData( ( props ) => { | |
| 49 | - const { columns, showAvatar, showName, showTotal, showDate, showComments } = props.attributes; | |
| 27 | +export default GiveDonorWall; | |
| 50 | 28 | |
| 51 | - const parameters = stringify( pickBy( { | |
| 52 | - columns: columns, | |
| 53 | - show_avatar: showAvatar, | |
| 54 | - show_name: showName, | |
| 55 | - show_total: showTotal, | |
| 56 | - show_time: showDate, | |
| 57 | - show_comments: showComments, | |
| 58 | - }, | |
| 59 | - value => ! isUndefined( value ) ) | |
| 60 | - ); | |
| 29 | +// @todo show no donor template if donor does not exist. | |
| 61 | 30 | |
| 62 | - return { | |
| 63 | - latestForms: `/${ giveApiSettings.rest_base }/donor-wall/?${ parameters }`, | |
| 64 | - }; | |
| 65 | -} )( GiveDonorWall ); | |