Skip to content

Commit

Permalink
Add loading and missing post states
Browse files Browse the repository at this point in the history
Closes #211
  • Loading branch information
George Hotelling committed Nov 18, 2019
1 parent cd713c8 commit c9d9797
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/blocks/query/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
WritingFlow,
} from '@wordpress/block-editor';
import { cloneBlock, createBlock } from '@wordpress/blocks';
import { PanelBody } from '@wordpress/components';
import { PanelBody, Placeholder, Spinner } from '@wordpress/components';
import { compose } from '@wordpress/compose';
import { EntityProvider } from '@wordpress/core-data';
import { withSelect, withDispatch } from '@wordpress/data';
Expand Down Expand Up @@ -122,7 +122,15 @@ class Edit extends Component {
</PanelBody>
</InspectorControls>
<Fragment>
{ ( query || [] ).map( post => {
{ ! query && (
<Placeholder>
<Spinner />
</Placeholder>
) }
{ query && ! query.length && (
<Placeholder>{ __( 'Sorry, no posts were found.', 'newspack-blocks' ) }</Placeholder>
) }
{ query && !! query.length && query.map( post => {
if ( ! blocksTree[ post.id ] ) return null;
return (
<article className={ post.id === editingPost ? 'is-editing' : '' } key={ post.id }>
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions src/components/query-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import AutocompleteTokenField from '../../blocks/homepage-articles/components/au
*/
import apiFetch from '@wordpress/api-fetch';
import { BaseControl } from '@wordpress/components';
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
import { Component, Fragment } from '@wordpress/element';
import { decodeEntities } from '@wordpress/html-entities';
import { __ } from '@wordpress/i18n';
Expand Down

0 comments on commit c9d9797

Please sign in to comment.