From 197aa436488313403380529d50e3962a589e70c7 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 3 Jul 2013 08:52:53 -0700 Subject: [PATCH] Move flag icon inline with header in Differential revision list Summary: Ref T3485. Moves flag icon inline in the header. Test Plan: {F48654} Reviewers: chad Reviewed By: chad CC: aran Maniphest Tasks: T3485 Differential Revision: https://secure.phabricator.com/D6355 --- .../view/DifferentialRevisionListView.php | 20 +++++++++---------- .../flag/view/PhabricatorFlagListView.php | 4 ++-- src/view/layout/PhabricatorObjectItemView.php | 7 +++++++ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/applications/differential/view/DifferentialRevisionListView.php b/src/applications/differential/view/DifferentialRevisionListView.php index b74a7e9815..87b7006979 100644 --- a/src/applications/differential/view/DifferentialRevisionListView.php +++ b/src/applications/differential/view/DifferentialRevisionListView.php @@ -121,9 +121,14 @@ final class DifferentialRevisionListView extends AphrontView { $phid = $revision->getPHID(); if (isset($flagged[$phid])) { - $icons['flag'] = array( - 'icon' => 'flag-'.$flagged[$phid]->getColor(), - ); + $flag = $flagged[$phid]; + $flag_class = PhabricatorFlagColor::getCSSClass($flag->getColor()); + $icons['flag'] = phutil_tag( + 'div', + array( + 'class' => 'phabricator-flag-icon '.$flag_class, + ), + ''); } if (array_key_exists($revision->getID(), $this->drafts)) { $icons['draft'] = array( @@ -162,9 +167,8 @@ final class DifferentialRevisionListView extends AphrontView { $status_name = ArcanistDifferentialRevisionStatus::getNameForRevisionStatus($status); - $flag_icon = null; if (isset($icons['flag'])) { - $flag_icon = $icons['flag']['icon']; + $item->addHeadIcon($icons['flag']); } $item->setObjectName('D'.$revision->getID()); @@ -190,12 +194,6 @@ final class DifferentialRevisionListView extends AphrontView { $item->addStateIcon('none'); } - if ($flag_icon) { - $item->addStateIcon($flag_icon, pht('Flagged')); - } else { - $item->addStateIcon('none'); - } - $time_icon = 'none'; $time_attr = array(); if ($this->highlightAge) { diff --git a/src/applications/flag/view/PhabricatorFlagListView.php b/src/applications/flag/view/PhabricatorFlagListView.php index 1ee5b2ed48..2b31ddf887 100644 --- a/src/applications/flag/view/PhabricatorFlagListView.php +++ b/src/applications/flag/view/PhabricatorFlagListView.php @@ -57,8 +57,8 @@ final class PhabricatorFlagListView extends AphrontView { $item->addIcon('edit', $edit_link); $item->addIcon('delete', $remove_link); - $item->setHeader(hsprintf('%s %s', - $flag_icon, $flag->getHandle()->renderLink())); + $item->addHeadIcon($flag_icon); + $item->setHeader($flag->getHandle()->renderLink()); $item->addAttribute(phabricator_datetime($flag->getDateCreated(), $user)); diff --git a/src/view/layout/PhabricatorObjectItemView.php b/src/view/layout/PhabricatorObjectItemView.php index f78774e2b9..34cae3dad2 100644 --- a/src/view/layout/PhabricatorObjectItemView.php +++ b/src/view/layout/PhabricatorObjectItemView.php @@ -18,6 +18,7 @@ final class PhabricatorObjectItemView extends AphrontTagView { private $actions = array(); private $stateIconColumns = 0; private $stateIcons = array(); + private $headIcons = array(); public function setStateIconColumns($state_icon_columns) { $this->stateIconColumns = $state_icon_columns; @@ -36,6 +37,11 @@ final class PhabricatorObjectItemView extends AphrontTagView { return $this; } + public function addHeadIcon($icon) { + $this->headIcons[] = $icon; + return $this; + } + public function setObjectName($name) { $this->objectName = $name; return $this; @@ -244,6 +250,7 @@ final class PhabricatorObjectItemView extends AphrontTagView { 'sigil' => 'slippery', ), array( + $this->headIcons, $header_name, $header_link, ));