From a5ad11d2d2f1d440b42681b8e65c71234c0b5e3c Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sun, 14 May 2017 17:32:24 -0700 Subject: [PATCH] Add Member/Watcher info to search results Summary: Fixes T12707 Adds additional information to search results for if user is a member or a watcher of a project. Also removed the icon colors, which I'll find a better way to denote in future. Test Plan: Join a project, watch a project, view results list in /projects/ Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T12707 Differential Revision: https://secure.phabricator.com/D17880 --- .../query/PhabricatorProjectSearchEngine.php | 4 +++- .../project/view/PhabricatorProjectListView.php | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/applications/project/query/PhabricatorProjectSearchEngine.php b/src/applications/project/query/PhabricatorProjectSearchEngine.php index 75c2045f50..70931a8b00 100644 --- a/src/applications/project/query/PhabricatorProjectSearchEngine.php +++ b/src/applications/project/query/PhabricatorProjectSearchEngine.php @@ -13,7 +13,9 @@ final class PhabricatorProjectSearchEngine public function newQuery() { return id(new PhabricatorProjectQuery()) - ->needImages(true); + ->needImages(true) + ->needMembers(true) + ->needWatchers(true); } protected function buildCustomSearchFields() { diff --git a/src/applications/project/view/PhabricatorProjectListView.php b/src/applications/project/view/PhabricatorProjectListView.php index 3d6044f2b1..38c845167c 100644 --- a/src/applications/project/view/PhabricatorProjectListView.php +++ b/src/applications/project/view/PhabricatorProjectListView.php @@ -15,6 +15,7 @@ final class PhabricatorProjectListView extends AphrontView { public function renderList() { $viewer = $this->getUser(); + $viewer_phid = $viewer->getPHID(); $projects = $this->getProjects(); $handles = $viewer->loadHandles(mpull($projects, 'getPHID')); @@ -26,10 +27,8 @@ final class PhabricatorProjectListView extends AphrontView { $id = $project->getID(); $icon = $project->getDisplayIconIcon(); - $color = $project->getColor(); - $icon_icon = id(new PHUIIconView()) - ->setIcon("{$icon} {$color}"); + ->setIcon($icon); $icon_name = $project->getDisplayIconName(); @@ -49,6 +48,17 @@ 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 ($is_watcher) { + $item->addIcon('fa-eye', pht('Watching')); + } + $list->addItem($item); }