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

Font Library: Show error message when no fonts found to install #58914

Merged
merged 1 commit into from
Feb 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ function FontLibraryProvider( { children } ) {
setRefreshKey( Date.now() );
};

// Reset notice on dismiss.
useEffect( () => {
if ( notice ) {
notice.onRemove = () => {
setNotice( null );
};
}
}, [ notice, setNotice ] );

const {
records: libraryPosts = [],
isResolving: isResolvingLibrary,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import { useContext } from '@wordpress/element';
import {
__experimentalText as Text,
__experimentalHeading as Heading,
Expand All @@ -14,6 +15,11 @@ import {
import { chevronLeft } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { FontLibraryContext } from './context';

function TabPanelLayout( {
title,
description,
Expand All @@ -22,6 +28,8 @@ function TabPanelLayout( {
children,
footer,
} ) {
const { setNotice } = useContext( FontLibraryContext );

return (
<div className="font-library-modal__tabpanel-layout">
<Spacer margin={ 4 } />
Expand Down Expand Up @@ -53,7 +61,7 @@ function TabPanelLayout( {
<Spacer margin={ 1 } />
<Notice
status={ notice.type }
onRemove={ notice.onRemove }
onRemove={ () => setNotice( null ) }
>
{ notice.message }
</Notice>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ function UploadFonts() {
} );
if ( allowedFiles.length > 0 ) {
loadFiles( allowedFiles );
} else {
setNotice( {
type: 'error',
message: __( 'No fonts found to install.' ),
} );
setIsUploading( false );
}
};

Expand Down
Loading