From ca91a022fe482753bcdae4bb4425c507b62f7748 Mon Sep 17 00:00:00 2001 From: Alan Huang Date: Wed, 1 Aug 2012 14:33:30 -0700 Subject: [PATCH] Add a flag column to Differential revision lists Summary: Put a flag icon to the left of each flagged revision in the Differential summary tables. Flag is colored correctly and when hovered reveals the note in a tooltip. As epriestley specifically notes that the Flagged Revisions table should only be shown when a user is looking at their own revisions, maybe this ought to be limited by what controller is using this view, or something. Test Plan: View Differential main page. Check that flags appear correctly if some revisions are flagged. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, avivey Maniphest Tasks: T1557 Differential Revision: https://secure.phabricator.com/D3125 --- .../view/DifferentialRevisionListView.php | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/applications/differential/view/DifferentialRevisionListView.php b/src/applications/differential/view/DifferentialRevisionListView.php index 1a0c5d77fd..f1c39ed0b2 100644 --- a/src/applications/differential/view/DifferentialRevisionListView.php +++ b/src/applications/differential/view/DifferentialRevisionListView.php @@ -67,6 +67,11 @@ final class DifferentialRevisionListView extends AphrontView { throw new Exception("Call setUser() before render()!"); } + $flags = id(new PhabricatorFlagQuery()) + ->withObjectPHIDs(mpull($this->revisions, 'getPHID')) + ->execute(); + $flagged = mpull($flags, null, 'getObjectPHID'); + foreach ($this->fields as $field) { $field->setUser($this->user); $field->setHandles($this->handles); @@ -74,15 +79,28 @@ final class DifferentialRevisionListView extends AphrontView { $rows = array(); foreach ($this->revisions as $revision) { - $row = array(); + $phid = $revision->getPHID(); + $flag = ''; + if (isset($flagged[$phid])) { + $class = PhabricatorFlagColor::getCSSClass($flagged[$phid]->getColor()); + $note = $flagged[$phid]->getNote(); + $flag = phutil_render_tag( + 'div', + array( + 'class' => 'phabricator-flag-icon '.$class, + 'title' => $note, + ), + ''); + } + $row = array($flag); foreach ($this->fields as $field) { $row[] = $field->renderValueForRevisionList($revision); } $rows[] = $row; } - $headers = array(); - $classes = array(); + $headers = array(''); + $classes = array(''); foreach ($this->fields as $field) { $headers[] = $field->renderHeaderForRevisionList(); $classes[] = $field->getColumnClassForRevisionList();