diff --git a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/controls/PublishButton/PublishButton.js b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/controls/PublishButton/PublishButton.js index 6e88f0a31..71dafb704 100644 --- a/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/controls/PublishButton/PublishButton.js +++ b/invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/controls/PublishButton/PublishButton.js @@ -40,16 +40,29 @@ class PublishButtonComponent extends Component { this.closeConfirmModal(); }; - isDisabled = (values, isSubmitting, numberOfFiles) => { + isDisabled = (values, isSubmitting, filesState) => { + if (isSubmitting) { + return true; + } + const filesEnabled = _get(values, "files.enabled", false); - const filesMissing = filesEnabled && !numberOfFiles; - return isSubmitting || filesMissing; + const filesArray = Object.values(filesState.entries ?? {}); + const filesMissing = filesEnabled && filesArray.length === 0; + + if (filesMissing) { + return true; + } + + // All files must be finished uploading + const allCompleted = filesArray.every((file) => file.status === "finished"); + + return !allCompleted; }; render() { const { actionState, - numberOfFiles, + filesState, buttonLabel, publishWithoutCommunity, formik, @@ -64,7 +77,7 @@ class PublishButtonComponent extends Component { return ( <>