Skip to content

Commit

Permalink
Include resource ID when checking delete permissions.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilsoncc committed Feb 16, 2024
1 parent 428ef1f commit d1933ab
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function InstalledFonts() {
handleBack={ !! libraryFontSelected && handleUnselectFont }
footer={
<Footer
libraryFontSelected={ libraryFontSelected }
shouldDisplayDeleteButton={ shouldDisplayDeleteButton }
handleUninstallClick={ handleUninstallClick }
/>
Expand Down Expand Up @@ -172,13 +173,23 @@ function InstalledFonts() {
);
}

function Footer( { shouldDisplayDeleteButton, handleUninstallClick } ) {
function Footer( {
shouldDisplayDeleteButton,
handleUninstallClick,
libraryFontSelected,
} ) {
const { saveFontFamilies, fontFamiliesHasChanges, isInstalling } =
useContext( FontLibraryContext );

const customFontFamilyId =
libraryFontSelected?.source === 'custom' && libraryFontSelected?.id;

const canUserDelete = useSelect( ( select ) => {
const { canUser } = select( coreStore );
return canUser( 'delete', 'font-families' );
return (
customFontFamilyId &&
canUser( 'delete', 'font-families', customFontFamilyId )
);
} );

return (
Expand Down

0 comments on commit d1933ab

Please sign in to comment.