Skip to content

Commit

Permalink
fix: move isOwner() check
Browse files Browse the repository at this point in the history
...and make sure it is only applied 
when !config.limitedPermissionManagement
  • Loading branch information
pieterlukasse committed May 31, 2024
1 parent ecc434f commit 8e8e4bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion js/pages/cohort-definitions/cohort-definition-manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<!-- ko if: (enablePermissionManagement() === true && userCanShare() === true) -->
<button class="btn btn-primary"
data-bind="title: ko.i18n('common.configureAccess', 'Configure access'), visible: isOwner() && !previewVersion(), click: () => isAccessModalShown(!isAccessModalShown())">
data-bind="title: ko.i18n('common.configureAccess', 'Configure access'), visible: !previewVersion(), click: () => isAccessModalShown(!isAccessModalShown())">
<i class="fa fa-lock"></i>
</button>
<!-- /ko -->
Expand Down
32 changes: 18 additions & 14 deletions js/pages/cohort-definitions/cohort-definition-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8e8e4bc

Please sign in to comment.