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

Add 'No saved blocks' message to Inserter #4182

Merged
merged 1 commit into from
Dec 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions editor/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,31 @@ export class InserterMenu extends Component {

renderTabView( tab ) {
const blocksForTab = this.getBlocksForTab( tab );

// If the Recent tab is selected, don't render category headers
if ( 'recent' === tab ) {
return this.renderBlocks( blocksForTab );
}

const visibleBlocks = this.getVisibleBlocksByCategory( blocksForTab );
if ( 'embed' === tab ) {
return this.renderBlocks( visibleBlocks.embed );
// If the Saved tab is selected and we have no results, display a friendly message
if ( 'saved' === tab && blocksForTab.length === 0 ) {
return (
<p className="editor-inserter__no-tab-content-message">
{ __( 'No saved blocks.' ) }
</p>
);
}

const visibleBlocksByCategory = this.getVisibleBlocksByCategory( blocksForTab );

// If our results have only blocks from one category, don't render category headers
const categories = Object.keys( visibleBlocksByCategory );
if ( categories.length === 1 ) {
const [ soleCategory ] = categories;
return this.renderBlocks( visibleBlocksByCategory[ soleCategory ] );
}

return this.renderCategories( visibleBlocks );
return this.renderCategories( visibleBlocksByCategory );
}

interceptArrows( event ) {
Expand Down
6 changes: 6 additions & 0 deletions editor/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ input[type="search"].editor-inserter__search {
flex-shrink: 0;
margin-top: 1px;
}

.editor-inserter__no-tab-content-message {
font-style: italic;
margin-top: 3em;
text-align: center;
}
}

.editor-inserter__tab {
Expand Down