From 8e8e4bc8f425f63d030f411c6ac250604f095ed1 Mon Sep 17 00:00:00 2001 From: pieterlukasse Date: Wed, 22 May 2024 22:10:02 +0200 Subject: [PATCH] fix: move isOwner() check ...and make sure it is only applied when !config.limitedPermissionManagement --- .../cohort-definition-manager.html | 2 +- .../cohort-definition-manager.js | 32 +++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/js/pages/cohort-definitions/cohort-definition-manager.html b/js/pages/cohort-definitions/cohort-definition-manager.html index 9ea780951..dc868e11f 100644 --- a/js/pages/cohort-definitions/cohort-definition-manager.html +++ b/js/pages/cohort-definitions/cohort-definition-manager.html @@ -35,7 +35,7 @@ diff --git a/js/pages/cohort-definitions/cohort-definition-manager.js b/js/pages/cohort-definitions/cohort-definition-manager.js index 895a3b80b..c74889b16 100644 --- a/js/pages/cohort-definitions/cohort-definition-manager.js +++ b/js/pages/cohort-definitions/cohort-definition-manager.js @@ -58,7 +58,7 @@ define(['jquery', 'knockout', 'text!./cohort-definition-manager.html', 'utilities/sql', 'components/conceptset/conceptset-list', 'components/name-validation', - 'components/versions/versions', + 'components/versions/versions' ], function ( $, ko, @@ -198,20 +198,30 @@ define(['jquery', 'knockout', 'text!./cohort-definition-manager.html', this.pollTimeoutId = null; this.authApi = authApi; this.config = config; + this.relatedSourcecodesOptions = globalConstants.relatedSourcecodesOptions; + this.commonUtils = commonUtils; + this.isLoading = ko.observable(false); + this.currentCohortDefinition = sharedState.CohortDefinition.current; + + PermissionService.decorateComponent(this, { + entityTypeGetter: () => entityType.COHORT_DEFINITION, + entityIdGetter: () => this.currentCohortDefinition().id(), + createdByUsernameGetter: () => this.currentCohortDefinition() && this.currentCohortDefinition().createdBy() + && this.currentCohortDefinition().createdBy().login + }); this.enablePermissionManagement = ko.observable(config.enablePermissionManagement); if (config.enablePermissionManagement) { this.userCanShare = ko.observable( - !config.limitedPermissionManagement || - authApi.isPermittedGlobalShareArtifact()); + (config.limitedPermissionManagement && + authApi.isPermittedGlobalShareArtifact()) || + (!config.limitedPermissionManagement && + this.isOwner()) + ); } else { this.userCanShare = ko.observable(false); } - - this.relatedSourcecodesOptions = globalConstants.relatedSourcecodesOptions; - this.commonUtils = commonUtils; - this.isLoading = ko.observable(false); - this.currentCohortDefinition = sharedState.CohortDefinition.current; + this.currentCohortDefinitionMode = sharedState.CohortDefinition.mode; this.currentCohortDefinitionInfo = sharedState.CohortDefinition.info; this.cohortDefinitionSourceInfo = sharedState.CohortDefinition.sourceInfo; @@ -858,12 +868,6 @@ define(['jquery', 'knockout', 'text!./cohort-definition-manager.html', } - PermissionService.decorateComponent(this, { - entityTypeGetter: () => entityType.COHORT_DEFINITION, - entityIdGetter: () => this.currentCohortDefinition().id(), - createdByUsernameGetter: () => this.currentCohortDefinition() && this.currentCohortDefinition().createdBy() - && this.currentCohortDefinition().createdBy().login - }); TagsService.decorateComponent(this, { assetTypeGetter: () => TagsService.ASSET_TYPE.COHORT_DEFINITION,