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

Post publish upload media dialog: handle upload errors #64823

Merged
merged 5 commits into from
Aug 28, 2024
Merged
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,6 +61,7 @@ function Image( block ) {
export default function PostFormatPanel() {
const [ isUploading, setIsUploading ] = useState( false );
const [ isAnimating, setIsAnimating ] = useState( false );
const [ hadUploadError, setHadUploadError ] = useState( false );
const { editorBlocks, mediaUpload } = useSelect(
( select ) => ( {
editorBlocks: select( blockEditorStore ).getBlocks(),
Expand Down Expand Up @@ -89,6 +90,7 @@ export default function PostFormatPanel() {

function uploadImages() {
setIsUploading( true );
setHadUploadError( false );
Promise.all(
externalImages.map( ( image ) =>
window
Expand Down Expand Up @@ -119,6 +121,9 @@ export default function PostFormatPanel() {
} );
} ).then( () => setIsAnimating( true ) )
)
.catch( () => {
setHadUploadError( true );
} )
)
).finally( () => {
setIsUploading( false );
Expand Down Expand Up @@ -154,6 +159,7 @@ export default function PostFormatPanel() {
</Button>
) }
</div>
{ hadUploadError && <p>{ __( 'Upload failed, try again.' ) }</p> }
</PanelBody>
);
}
Loading