Skip to content

Commit

Permalink
Adds enablePublishOnAllNonPublic configuration
Browse files Browse the repository at this point in the history
closes #2202
  • Loading branch information
helbashandy committed Oct 17, 2023
1 parent e967576 commit bca1b3f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/js/models/AppModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 9 additions & 3 deletions src/js/views/MetadataView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1234,16 +1234,22 @@ 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) {
//Get the list of authorized publishers from the AppModel
var authorizedPublishers = MetacatUI.appModel.get("enablePublishDOIForSubjects");
//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 (Array.isArray(authorizedPublishers) && (authorizedPublishers.length ||
!view.model.get("isPublic") === false)){
if (MetacatUI.appUserModel.hasIdentityOverlap(authorizedPublishers)){
canBePublished = true;
}
else {
Expand Down

0 comments on commit bca1b3f

Please sign in to comment.