Skip to content

Commit

Permalink
Hide actions for themes that are not block based
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Apr 19, 2024
1 parent 195b50d commit 2ea07e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
18 changes: 6 additions & 12 deletions packages/edit-site/src/components/add-new-pattern/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { DropdownMenu } from '@wordpress/components';
import { useState, useRef } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import { plus, symbol, symbolFilled, upload } from '@wordpress/icons';
import { useSelect, useDispatch } from '@wordpress/data';
import { useDispatch } from '@wordpress/data';
import { privateApis as routerPrivateApis } from '@wordpress/router';
import {
privateApis as editPatternsPrivateApis,
store as patternsStore,
} from '@wordpress/patterns';
import { store as coreStore } from '@wordpress/core-data';
import { store as noticesStore } from '@wordpress/notices';

/**
Expand All @@ -37,9 +36,6 @@ export default function AddNewPattern() {
const [ showPatternModal, setShowPatternModal ] = useState( false );
const [ showTemplatePartModal, setShowTemplatePartModal ] =
useState( false );
const isBlockBasedTheme = useSelect( ( select ) => {
return select( coreStore ).getCurrentTheme()?.is_block_theme;
}, [] );
const { createPatternFromFile } = unlock( useDispatch( patternsStore ) );
const { createSuccessNotice, createErrorNotice } =
useDispatch( noticesStore );
Expand Down Expand Up @@ -81,13 +77,11 @@ export default function AddNewPattern() {
},
];

if ( isBlockBasedTheme ) {
controls.push( {
icon: symbolFilled,
onClick: () => setShowTemplatePartModal( true ),
title: __( 'Create template part' ),
} );
}
controls.push( {
icon: symbolFilled,
onClick: () => setShowTemplatePartModal( true ),
title: __( 'Create template part' ),
} );

controls.push( {
icon: upload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default function SidebarNavigationScreenPatterns() {
'Manage what template parts are available when editing the site.'
)
}
actions={ <AddNewPattern /> }
actions={ isBlockBasedTheme && <AddNewPattern /> }
content={
<>
{ isLoading && __( 'Loading items…' ) }
Expand Down

0 comments on commit 2ea07e2

Please sign in to comment.