Skip to content

Commit

Permalink
Hide Share button from My Projects Page
Browse files Browse the repository at this point in the history
Remove consol.log()

Add additional business logic to header buttons

refactor rename twig header variable param. remove console.log debug files
  • Loading branch information
palmtreefrb authored and megahirt committed Mar 10, 2022
1 parent fcc0c75 commit 2d40d0a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<breadcrumbs id="top" class="breadcrumbs d-none d-md-block"></breadcrumbs>
</div>
<ul class="nav navbar-nav">
<li class="nav-item" ng-if="$ctrl.project" id="settings-dropdown-button" uib-dropdown data-ng-class="{'app-settings-available': $ctrl.header.settings.length > 0 && $ctrl.currentUserIsProjectManager}">
<li class="nav-item" ng-if="$ctrl.isLexiconProject" id="settings-dropdown-button" uib-dropdown data-ng-class="{'app-settings-available': $ctrl.header.settings.length > 0 && $ctrl.currentUserIsProjectManager}">
<a id="settingsBtn" class="btn btn-primary my-auto" uib-dropdown-toggle title="Settings" href="#">
<i class="fa fa-cog iconPadding"></i><span>Settings</span>
</a>
Expand All @@ -95,7 +95,7 @@
{% endverbatim %}
</div>
</li>
<li class='nav-item' ng-if="$ctrl.project && $ctrl.displayShareButton">
<li class='nav-item' ng-if="$ctrl.isLexiconProject">
<a id="shareBtn" class="btn btn-primary my-auto" title="Share" href="#"
ng-click="$ctrl.openShareWithOthersModal()">
<i class="fa fa-share-alt iconPadding"></i><span>Share</span>
Expand Down
26 changes: 20 additions & 6 deletions src/angular-app/bellows/core/navbar.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,24 @@ export class NavbarController implements angular.IController {
project: Project;
interfaceConfig: InterfaceConfig;
currentUserIsProjectManager: boolean;
displayShareButton: boolean;
displayHeaderButtons: boolean;
projectTypeNames: ProjectTypeNames;
siteName: string;
isLexiconProject: boolean = false;

static $inject = ['$uibModal',
'projectService', 'sessionService',
static $inject = [
'$scope',
'$uibModal',
'projectService',
'sessionService',
'offlineCacheUtils',
'applicationHeaderService'];
constructor(private readonly $modal: ModalService,
constructor(private readonly $scope: angular.IScope,
private readonly $modal: ModalService,
private readonly projectService: ProjectService, private readonly sessionService: SessionService,
private readonly offlineCacheUtils: OfflineCacheUtilsService,
private readonly applicationHeaderService: ApplicationHeaderService) { }
private readonly applicationHeaderService: ApplicationHeaderService,
) { }

$onInit(): void {
this.projectTypeNames = this.projectService.data.projectTypeNames;
Expand Down Expand Up @@ -69,13 +75,21 @@ export class NavbarController implements angular.IController {
this.currentUserIsProjectManager =
(session.data.userProjectRole === ProjectRoles.MANAGER.key) ||
(session.data.userProjectRole === ProjectRoles.TECH_SUPPORT.key);
this.displayShareButton =
this.displayHeaderButtons =
(this.currentUserIsProjectManager || (this.project.allowSharing && this.session.data.userIsProjectMember));
}

this.rights.canCreateProject =
session.hasSiteRight(this.sessionService.domain.PROJECTS, this.sessionService.operation.CREATE);
this.siteName = session.baseSite();
});
this.$scope.$on('$locationChangeStart', (event, next, current) => {
if (current.includes('/lexicon') && !current.includes('/new-project') && this.displayHeaderButtons) {
this.isLexiconProject = true;
}else{
this.isLexiconProject = false;
}
});
}

onUpdate = ($event: { interfaceConfig: InterfaceConfig}): void => {
Expand Down

0 comments on commit 2d40d0a

Please sign in to comment.