From 8f71b104c52d2e6f9e759e14898c22c26c62c1ab Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Wed, 6 Jun 2018 16:59:13 +0100 Subject: [PATCH] Fix bug where unowned project would show archive quick action instead of leave If the user does not own the project, the project can only be left, not archived. Previously the quick action button was only showing the archive icon but clicking the button would correctly leave the project. This is confusing, so this commit corrects to show the leave icon for projects not owned by the current user --- services/web/app/views/project/list/item.pug | 12 ++++++++++-- .../coffee/main/project-list/project-list.coffee | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/services/web/app/views/project/list/item.pug b/services/web/app/views/project/list/item.pug index bc37683489..5a9cb2138d 100644 --- a/services/web/app/views/project/list/item.pug +++ b/services/web/app/views/project/list/item.pug @@ -64,13 +64,21 @@ if settings.overleaf ) i.icon.fa.fa-cloud-download button.btn.btn-link.action-btn( - ng-if="!project.archived" + ng-if="!project.archived && isOwner()" tooltip=translate('archive'), tooltip-placement="top", tooltip-append-to-body="true", - ng-click="archive($event)" + ng-click="archiveOrLeave($event)" ) i.icon.fa.fa-inbox + button.btn.btn-link.action-btn( + ng-if="!project.archived && !isOwner()" + tooltip=translate('leave'), + tooltip-placement="top", + tooltip-append-to-body="true", + ng-click="archiveOrLeave($event)" + ) + i.icon.fa.fa-sign-out button.btn.btn-link.action-btn( ng-if="project.archived" tooltip=translate('unarchive'), diff --git a/services/web/public/coffee/main/project-list/project-list.coffee b/services/web/public/coffee/main/project-list/project-list.coffee index 6696243905..841ccd6c2d 100644 --- a/services/web/public/coffee/main/project-list/project-list.coffee +++ b/services/web/public/coffee/main/project-list/project-list.coffee @@ -490,6 +490,9 @@ define [ else return "None" + $scope.isOwner = () -> + window.user_id == $scope.project.owner._id + $scope.$watch "project.selected", (value) -> if value? $scope.updateSelectedProjects() @@ -502,7 +505,7 @@ define [ e.stopPropagation() $scope.downloadProjectsById([$scope.project.id]) - $scope.archive = (e) -> + $scope.archiveOrLeave = (e) -> e.stopPropagation() $scope.archiveOrLeaveProjects([$scope.project])