diff --git a/.gitignore b/.gitignore index 1b7433f87b..12e73aa5ce 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,7 @@ Pipfile.lock # pip wheel pip-wheel-metadata/ + +# node modules +**/*/node_modules +node_modules \ No newline at end of file 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 6e88f0a312..9e09f257b4 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 @@ -1,6 +1,7 @@ // This file is part of Invenio-RDM-Records // Copyright (C) 2020-2023 CERN. // Copyright (C) 2020-2022 Northwestern University. +// Copyright (C) 2023 KTH Royal Institute of Technology. // // Invenio-RDM-Records is free software; you can redistribute it and/or modify it // under the terms of the MIT License; see LICENSE file for more details. @@ -40,10 +41,13 @@ class PublishButtonComponent extends Component { this.closeConfirmModal(); }; - isDisabled = (values, isSubmitting, numberOfFiles) => { + isDisabled = (values, isSubmitting, numberOfFiles, permissions) => { + const canPublish = permissions?.can_publish ?? false; + const publishWithCommunity = permissions?.can_publish_with_community_only ?? false; + const hasNoPermission = !canPublish && publishWithCommunity; const filesEnabled = _get(values, "files.enabled", false); const filesMissing = filesEnabled && !numberOfFiles; - return isSubmitting || filesMissing; + return isSubmitting || filesMissing || hasNoPermission; }; render() { @@ -54,6 +58,7 @@ class PublishButtonComponent extends Component { publishWithoutCommunity, formik, publishModalExtraContent, + permissions, ...ui } = this.props; const { isConfirmModalOpen } = this.state; @@ -64,7 +69,7 @@ class PublishButtonComponent extends Component { return ( <>