From fcebaa5097f326123254c912522cd18c71e32460 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Mon, 15 May 2017 09:02:39 -0700 Subject: [PATCH] (stable) Restrict watching and member project display better Summary: Fixes T12713. We don't need to show watching and member info on other views other than ApplicationSearch (for now) so add a few methods to restrict the calls. Test Plan: Visit project search, profile, project home, project home with subprojects Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T12713 Differential Revision: https://secure.phabricator.com/D17883 --- .../PhabricatorProjectProfileController.php | 2 -- ...habricatorProjectSubprojectsController.php | 4 --- .../query/PhabricatorProjectSearchEngine.php | 2 ++ .../view/PhabricatorProjectListView.php | 29 ++++++++++++++----- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/applications/project/controller/PhabricatorProjectProfileController.php b/src/applications/project/controller/PhabricatorProjectProfileController.php index 60254ddcca..4c726f5884 100644 --- a/src/applications/project/controller/PhabricatorProjectProfileController.php +++ b/src/applications/project/controller/PhabricatorProjectProfileController.php @@ -262,8 +262,6 @@ final class PhabricatorProjectProfileController ->setViewer($viewer) ->withParentProjectPHIDs(array($project->getPHID())) ->needImages(true) - ->needMembers(true) - ->needWatchers(true) ->withStatuses( array( PhabricatorProjectStatus::STATUS_ACTIVE, diff --git a/src/applications/project/controller/PhabricatorProjectSubprojectsController.php b/src/applications/project/controller/PhabricatorProjectSubprojectsController.php index a25a41fad0..4a89bb4cde 100644 --- a/src/applications/project/controller/PhabricatorProjectSubprojectsController.php +++ b/src/applications/project/controller/PhabricatorProjectSubprojectsController.php @@ -31,8 +31,6 @@ final class PhabricatorProjectSubprojectsController ->setViewer($viewer) ->withParentProjectPHIDs(array($project->getPHID())) ->needImages(true) - ->needMembers(true) - ->needWatchers(true) ->withIsMilestone(false) ->execute(); } else { @@ -44,8 +42,6 @@ final class PhabricatorProjectSubprojectsController ->setViewer($viewer) ->withParentProjectPHIDs(array($project->getPHID())) ->needImages(true) - ->needMembers(true) - ->needWatchers(true) ->withIsMilestone(true) ->setOrderVector(array('milestoneNumber', 'id')) ->execute(); diff --git a/src/applications/project/query/PhabricatorProjectSearchEngine.php b/src/applications/project/query/PhabricatorProjectSearchEngine.php index 70931a8b00..df13278812 100644 --- a/src/applications/project/query/PhabricatorProjectSearchEngine.php +++ b/src/applications/project/query/PhabricatorProjectSearchEngine.php @@ -229,6 +229,8 @@ final class PhabricatorProjectSearchEngine $list = id(new PhabricatorProjectListView()) ->setUser($viewer) ->setProjects($projects) + ->setShowWatching(true) + ->setShowMember(true) ->renderList(); return id(new PhabricatorApplicationSearchResultView()) diff --git a/src/applications/project/view/PhabricatorProjectListView.php b/src/applications/project/view/PhabricatorProjectListView.php index 38c845167c..994e78ce76 100644 --- a/src/applications/project/view/PhabricatorProjectListView.php +++ b/src/applications/project/view/PhabricatorProjectListView.php @@ -3,6 +3,8 @@ final class PhabricatorProjectListView extends AphrontView { private $projects; + private $showMember; + private $showWatching; public function setProjects(array $projects) { $this->projects = $projects; @@ -13,6 +15,16 @@ final class PhabricatorProjectListView extends AphrontView { return $this->projects; } + public function setShowWatching($watching) { + $this->showWatching = $watching; + return $this; + } + + public function setShowMember($member) { + $this->showMember = $member; + return $this; + } + public function renderList() { $viewer = $this->getUser(); $viewer_phid = $viewer->getPHID(); @@ -48,15 +60,18 @@ final class PhabricatorProjectListView extends AphrontView { $item->setDisabled(true); } - $is_member = $project->isUserMember($viewer_phid); - $is_watcher = $project->isUserWatcher($viewer_phid); - - if ($is_member) { - $item->addIcon('fa-user', pht('Member')); + if ($this->showMember) { + $is_member = $project->isUserMember($viewer_phid); + if ($is_member) { + $item->addIcon('fa-user', pht('Member')); + } } - if ($is_watcher) { - $item->addIcon('fa-eye', pht('Watching')); + if ($this->showWatching) { + $is_watcher = $project->isUserWatcher($viewer_phid); + if ($is_watcher) { + $item->addIcon('fa-eye', pht('Watching')); + } } $list->addItem($item);