From 4c6ab5060e928349bfb1954878c3ac7ec84ae6fc Mon Sep 17 00:00:00 2001 From: Anh Nhan Nguyen Date: Wed, 3 Apr 2013 08:28:18 -0700 Subject: [PATCH] Streamline tag rendering for Differential and Maniphest Summary: Well, I'm just putting it into the DAO classes, or am I doing something wrong? Will be used by future event listeners Test Plan: Visited some tasks and revisions. Look fine. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5542 --- .../view/DifferentialRevisionDetailView.php | 17 +++++++++++------ .../ManiphestTaskDetailController.php | 10 +--------- .../maniphest/storage/ManiphestTask.php | 1 - .../maniphest/view/ManiphestView.php | 11 +++++++++++ 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/applications/differential/view/DifferentialRevisionDetailView.php b/src/applications/differential/view/DifferentialRevisionDetailView.php index 45f304d22d..364fe796a1 100644 --- a/src/applications/differential/view/DifferentialRevisionDetailView.php +++ b/src/applications/differential/view/DifferentialRevisionDetailView.php @@ -110,7 +110,15 @@ final class DifferentialRevisionDetailView extends AphrontView { private function renderHeader(DifferentialRevision $revision) { $view = id(new PhabricatorHeaderView()) - ->setHeader($revision->getTitle()); + ->setHeader($revision->getTitle($revision)); + + $view->addTag(self::renderTagForRevision($revision)); + + return $view; + } + + public static function renderTagForRevision( + DifferentialRevision $revision) { $status = $revision->getStatus(); $status_name = @@ -118,12 +126,9 @@ final class DifferentialRevisionDetailView extends AphrontView { $status_color = DifferentialRevisionStatus::getRevisionStatusTagColor($status); - $view->addTag( - id(new PhabricatorTagView()) + return id(new PhabricatorTagView()) ->setType(PhabricatorTagView::TYPE_STATE) ->setName($status_name) - ->setBackgroundColor($status_color)); - - return $view; + ->setBackgroundColor($status_color); } } diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php index 0e077497d3..ad01efbe19 100644 --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -374,15 +374,7 @@ final class ManiphestTaskDetailController extends ManiphestController { $view = id(new PhabricatorHeaderView()) ->setHeader($task->getTitle()); - $status = $task->getStatus(); - $status_name = ManiphestTaskStatus::getTaskStatusFullName($status); - $status_color = ManiphestTaskStatus::getTaskStatusTagColor($status); - - $view->addTag( - id(new PhabricatorTagView()) - ->setType(PhabricatorTagView::TYPE_STATE) - ->setName($status_name) - ->setBackgroundColor($status_color)); + $view->addTag(ManiphestView::renderTagForTask($task)); return $view; } diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php index c51f5bf546..c20172b268 100644 --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -144,7 +144,6 @@ final class ManiphestTask extends ManiphestDAO return $this; } - public function save() { if (!$this->mailKey) { $this->mailKey = Filesystem::readRandomCharacters(20); diff --git a/src/applications/maniphest/view/ManiphestView.php b/src/applications/maniphest/view/ManiphestView.php index d0b710b492..c6543eadc1 100644 --- a/src/applications/maniphest/view/ManiphestView.php +++ b/src/applications/maniphest/view/ManiphestView.php @@ -5,4 +5,15 @@ */ abstract class ManiphestView extends AphrontView { + public static function renderTagForTask(ManiphestTask $task) { + $status = $task->getStatus(); + $status_name = ManiphestTaskStatus::getTaskStatusFullName($status); + $status_color = ManiphestTaskStatus::getTaskStatusTagColor($status); + + return id(new PhabricatorTagView()) + ->setType(PhabricatorTagView::TYPE_STATE) + ->setName($status_name) + ->setBackgroundColor($status_color); + } + }