From 5a850ab23525616ebd6e9c96d7d812ac243c605b Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sat, 11 Feb 2017 19:47:21 -0800 Subject: [PATCH] Add more information to Dashboard ApplicationSearch list Summary: Fixes T4984. This is about as fancy as I want to get this pass. Adds in the list of panel titles and the author. This does give me a rough idea what's on each dashboard. Test Plan: Visit a list of dashboards and see various authors and panels. {F2810876} Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T4984 Differential Revision: https://secure.phabricator.com/D17340 --- .../PhabricatorDashboardSearchEngine.php | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php b/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php index 56f766c089..6061a0ab8a 100644 --- a/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php +++ b/src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php @@ -13,7 +13,7 @@ final class PhabricatorDashboardSearchEngine public function newQuery() { return id(new PhabricatorDashboardQuery()) - ->needProjects(true); + ->needPanels(true); } protected function buildCustomSearchFields() { @@ -98,25 +98,22 @@ final class PhabricatorDashboardSearchEngine PhabricatorSavedQuery $query, array $handles) { - $dashboards = mpull($dashboards, null, 'getPHID'); $viewer = $this->requireViewer(); - $proj_phids = array(); + $phids = array(); foreach ($dashboards as $dashboard) { - foreach ($dashboard->getProjectPHIDs() as $project_phid) { - $proj_phids[] = $project_phid; + $author_phid = $dashboard->getAuthorPHID(); + if ($author_phid) { + $phids[] = $author_phid; } } - $proj_handles = id(new PhabricatorHandleQuery()) - ->setViewer($viewer) - ->withPHIDs($proj_phids) - ->execute(); + $handles = $viewer->loadHandles($phids); $list = id(new PHUIObjectItemListView()) ->setUser($viewer); - foreach ($dashboards as $dashboard_phid => $dashboard) { + foreach ($dashboards as $dashboard) { $id = $dashboard->getID(); $item = id(new PHUIObjectItemView()) @@ -125,27 +122,30 @@ final class PhabricatorDashboardSearchEngine ->setHref($this->getApplicationURI("view/{$id}/")) ->setObject($dashboard); - $project_handles = array_select_keys( - $proj_handles, - $dashboard->getProjectPHIDs()); - - $item->addAttribute( - id(new PHUIHandleTagListView()) - ->setLimit(4) - ->setNoDataString(pht('No Projects')) - ->setSlim(true) - ->setHandles($project_handles)); - if ($dashboard->isArchived()) { $item->setDisabled(true); } + $panels = $dashboard->getPanels(); + foreach ($panels as $panel) { + $item->addAttribute($panel->getName()); + } + + if (empty($panels)) { + $empty = phutil_tag('em', array(), pht('No panels.')); + $item->addAttribute($empty); + } + $icon = id(new PHUIIconView()) ->setIcon($dashboard->getIcon()) ->setBackground('bg-dark'); $item->setImageIcon($icon); $item->setEpoch($dashboard->getDateModified()); + $author_phid = $dashboard->getAuthorPHID(); + $author_name = $handles[$author_phid]->renderLink(); + $item->addByline(pht('Author: %s', $author_name)); + $list->addItem($item); }