1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-20 13:52:40 +01:00

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
This commit is contained in:
Anh Nhan Nguyen 2013-04-03 08:28:18 -07:00 committed by epriestley
parent 8270b0e92d
commit 4c6ab5060e
4 changed files with 23 additions and 16 deletions

View file

@ -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);
}
}

View file

@ -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;
}

View file

@ -144,7 +144,6 @@ final class ManiphestTask extends ManiphestDAO
return $this;
}
public function save() {
if (!$this->mailKey) {
$this->mailKey = Filesystem::readRandomCharacters(20);

View file

@ -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);
}
}