Media: disable "Insert Gallery" button during uploads.

Ensure that the button to insert a gallery is disabled until all image uploads have completed on the Edit Gallery screen.  Prevents an issue where users could insert a gallery with some images missing.

Props: adamsilverstein, gonom9, rishavdutta.
Fixes: #39824.


Built from https://develop.svn.wordpress.org/trunk@60031


git-svn-id: http://core.svn.wordpress.org/trunk@59367 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Adam Silverstein
2025-03-17 17:48:26 +00:00
parent 2ffac21b44
commit f640e6c7a8
3 changed files with 8 additions and 4 deletions

View File

@@ -4970,7 +4970,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{
style: 'primary',
text: editing ? l10n.updateGallery : l10n.insertGallery,
priority: 80,
requires: { library: true },
requires: { library: true, uploadingComplete: true },
/**
* @fires wp.media.controller.State#update
@@ -5642,7 +5642,8 @@ Toolbar = View.extend(/** @lends wp.media.view.Toolbar.prototype */{
}
var requires = button.options.requires,
disabled = false;
disabled = false,
modelsUploading = ! _.isEmpty( library.findWhere( { 'uploading': true } ) );
// Prevent insertion of attachments if any of them are still uploading.
if ( selection && selection.models ) {
@@ -5650,6 +5651,9 @@ Toolbar = View.extend(/** @lends wp.media.view.Toolbar.prototype */{
return attachment.get('uploading') === true;
});
}
if ( requires.uploadingComplete && modelsUploading ) {
disabled = true;
}
if ( requires.selection && selection && ! selection.length ) {
disabled = true;

File diff suppressed because one or more lines are too long

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.8-beta2-60030';
$wp_version = '6.8-beta2-60031';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.