diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/index.js b/packages/edit-site/src/components/global-styles/font-library-modal/index.js index b190780bd4e279..5a81b7f39fada5 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/index.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/index.js @@ -6,7 +6,8 @@ import { Modal, privateApis as componentsPrivateApis, } from '@wordpress/components'; -import { useResourcePermissions } from '@wordpress/core-data'; +import { useSelect } from '@wordpress/data'; +import { store as coreStore } from '@wordpress/core-data'; import { useContext } from '@wordpress/element'; /** @@ -48,12 +49,16 @@ function FontLibraryModal( { initialTabId = 'installed-fonts', } ) { const { collections, setNotice } = useContext( FontLibraryContext ); - const { canCreate } = useResourcePermissions( 'font-families' ); + + const canUserCreate = useSelect( ( select ) => { + const { canUser } = select( coreStore ); + return canUser( 'create', 'font-families' ); + } ); const tabs = [ ...DEFAULT_TABS, - ...( canCreate ? UPLOAD_TABS : [] ), - ...( canCreate ? tabsFromCollections( collections || [] ) : [] ), + ...( canUserCreate ? UPLOAD_TABS : [] ), + ...( canUserCreate ? tabsFromCollections( collections || [] ) : [] ), ]; // Reset notice when new tab is selected. diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js b/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js index 99c99e44a43afc..715c7804258245 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js @@ -12,6 +12,8 @@ import { Spinner, FlexItem, } from '@wordpress/components'; +import { store as coreStore } from '@wordpress/core-data'; +import { useSelect } from '@wordpress/data'; /** * Internal dependencies @@ -173,11 +175,17 @@ function InstalledFonts() { function Footer( { shouldDisplayDeleteButton, handleUninstallClick } ) { const { saveFontFamilies, fontFamiliesHasChanges, isInstalling } = useContext( FontLibraryContext ); + + const canUserDelete = useSelect( ( select ) => { + const { canUser } = select( coreStore ); + return canUser( 'delete', 'font-families' ); + } ); + return ( { isInstalling && }
- { shouldDisplayDeleteButton && ( + { canUserDelete && shouldDisplayDeleteButton && (