Skip to content

Commit d1933ab

Browse files
committed
Include resource ID when checking delete permissions.
1 parent 428ef1f commit d1933ab

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ function InstalledFonts() {
102102
handleBack={ !! libraryFontSelected && handleUnselectFont }
103103
footer={
104104
<Footer
105+
libraryFontSelected={ libraryFontSelected }
105106
shouldDisplayDeleteButton={ shouldDisplayDeleteButton }
106107
handleUninstallClick={ handleUninstallClick }
107108
/>
@@ -172,13 +173,23 @@ function InstalledFonts() {
172173
);
173174
}
174175

175-
function Footer( { shouldDisplayDeleteButton, handleUninstallClick } ) {
176+
function Footer( {
177+
shouldDisplayDeleteButton,
178+
handleUninstallClick,
179+
libraryFontSelected,
180+
} ) {
176181
const { saveFontFamilies, fontFamiliesHasChanges, isInstalling } =
177182
useContext( FontLibraryContext );
178183

184+
const customFontFamilyId =
185+
libraryFontSelected?.source === 'custom' && libraryFontSelected?.id;
186+
179187
const canUserDelete = useSelect( ( select ) => {
180188
const { canUser } = select( coreStore );
181-
return canUser( 'delete', 'font-families' );
189+
return (
190+
customFontFamilyId &&
191+
canUser( 'delete', 'font-families', customFontFamilyId )
192+
);
182193
} );
183194

184195
return (

0 commit comments

Comments
 (0)