From d583c02e663055592c74e1b535c6489aa5b0b052 Mon Sep 17 00:00:00 2001 From: helbashandy Date: Tue, 17 Oct 2023 11:05:36 -0700 Subject: [PATCH] Adds enablePublishOnAllNonPublic configuration closes #2202 --- src/js/models/AppModel.js | 9 +++++++++ src/js/views/MetadataView.js | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/js/models/AppModel.js b/src/js/models/AppModel.js index c8d6c914e1..0cd9d1f237 100644 --- a/src/js/models/AppModel.js +++ b/src/js/models/AppModel.js @@ -1079,6 +1079,15 @@ define(['jquery', 'underscore', 'backbone'], */ isJSONLDEnabled: true, + /** + * If true, users can see a "Publish" button in the MetadataView on all non-public datasets regardless if + * a DOI is assigned to the dataset + * If false, the default behavior would take place based on the {@link AppConfig#enablePublishDOI} config. + * @type {boolean} + * @default false + */ + enablePublishOnAllNonPublic: false, + /** * If true, users can see a "Publish" button in the MetadataView, which makes the metadata * document public and gives it a DOI identifier. diff --git a/src/js/views/MetadataView.js b/src/js/views/MetadataView.js index 94c9f93437..997d00d923 100644 --- a/src/js/views/MetadataView.js +++ b/src/js/views/MetadataView.js @@ -1234,7 +1234,12 @@ define(['jquery', //Determine if this metadata can be published. // The Publish feature has to be enabled in the app. // The model cannot already have a DOI - var canBePublished = MetacatUI.appModel.get("enablePublishDOI") && !view.model.isDOI(); + var canBePublished; + if (MetacatUI.appModel.get("enablePublishOnAllNonPublic") && view.model.get("isPublic") === false){ + canBePublished = true; + } else { + canBePublished = MetacatUI.appModel.get("enablePublishDOI") && !view.model.isDOI(); + } //If publishing is enabled, check if only certain users and groups can publish metadata if (canBePublished) { @@ -1243,7 +1248,9 @@ define(['jquery', //If the logged-in user is one of the subjects in the list or is in a group that is // in the list, then this metadata can be published. Otherwise, it cannot. if (Array.isArray(authorizedPublishers) && authorizedPublishers.length) { - if (MetacatUI.appUserModel.hasIdentityOverlap(authorizedPublishers)) { + if (MetacatUI.appUserModel.hasIdentityOverlap(authorizedPublishers) && + !(MetacatUI.appModel.get("enablePublishOnAllNonPublic") && view.model.get("isPublic") === false) + ) { canBePublished = true; } else {