1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Restore "Unbreak Now" and "Needs Triage" homepage boxes as cusomizable elements

Summary: Ref T3583. Fixes T3835. Dropbox and Disqus both want these things back, so restore them until we can do something about T3583.

Test Plan: Viewed homepage, clicked "View All X" buttons.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3583, T3835

Differential Revision: https://secure.phabricator.com/D7017
This commit is contained in:
epriestley 2013-09-17 11:31:32 -07:00
parent bab9a28ab9
commit 24e07df434
2 changed files with 123 additions and 0 deletions

View file

@ -32,8 +32,12 @@ final class PhabricatorDirectoryMainController
$maniphest = 'PhabricatorApplicationManiphest';
if (PhabricatorApplication::isClassInstalled($maniphest)) {
$unbreak_panel = $this->buildUnbreakNowPanel();
$triage_panel = $this->buildNeedsTriagePanel($projects);
$tasks_panel = $this->buildTasksPanel();
} else {
$unbreak_panel = null;
$triage_panel = null;
$tasks_panel = null;
}
@ -50,6 +54,8 @@ final class PhabricatorDirectoryMainController
$content = array(
$jump_panel,
$welcome_panel,
$unbreak_panel,
$triage_panel,
$revision_panel,
$tasks_panel,
$audit_panel,
@ -90,6 +96,102 @@ final class PhabricatorDirectoryMainController
}
}
private function buildUnbreakNowPanel() {
$unbreak_now = PhabricatorEnv::getEnvConfig(
'maniphest.priorities.unbreak-now');
if (!$unbreak_now) {
return null;
}
$user = $this->getRequest()->getUser();
$task_query = id(new ManiphestTaskQuery())
->setViewer($user)
->withStatuses(array(ManiphestTaskStatus::STATUS_OPEN))
->withPriorities(array($unbreak_now))
->setLimit(10);
$tasks = $task_query->execute();
if (!$tasks) {
return $this->renderMiniPanel(
'No "Unbreak Now!" Tasks',
'Nothing appears to be critically broken right now.');
}
$panel = new AphrontPanelView();
$panel->setHeader('Unbreak Now!');
$panel->setCaption('Open tasks with "Unbreak Now!" priority.');
$panel->addButton(
phutil_tag(
'a',
array(
'href' => '/maniphest/?statuses[]=0&priorities[]='.$unbreak_now.'#R',
'class' => 'grey button',
),
"View All Unbreak Now \xC2\xBB"));
$panel->appendChild($this->buildTaskListView($tasks));
$panel->setNoBackground();
return $panel;
}
private function buildNeedsTriagePanel(array $projects) {
assert_instances_of($projects, 'PhabricatorProject');
$needs_triage = PhabricatorEnv::getEnvConfig(
'maniphest.priorities.needs-triage');
if (!$needs_triage) {
return null;
}
$user = $this->getRequest()->getUser();
if (!$user->isLoggedIn()) {
return null;
}
if ($projects) {
$task_query = id(new ManiphestTaskQuery())
->setViewer($user)
->withStatuses(array(ManiphestTaskStatus::STATUS_OPEN))
->withPriorities(array($needs_triage))
->withAnyProjects(mpull($projects, 'getPHID'))
->setLimit(10);
$tasks = $task_query->execute();
} else {
$tasks = array();
}
if (!$tasks) {
return $this->renderMiniPanel(
'No "Needs Triage" Tasks',
hsprintf(
'No tasks in <a href="/project/">projects you are a member of</a> '.
'need triage.'));
}
$panel = new AphrontPanelView();
$panel->setHeader('Needs Triage');
$panel->setCaption(hsprintf(
'Open tasks with "Needs Triage" priority in '.
'<a href="/project/">projects you are a member of</a>.'));
$panel->addButton(
phutil_tag(
'a',
array(
'href' => '/maniphest/?statuses[]=0&priorities[]='.$needs_triage.
'&userProjects[]='.$user->getPHID().'#R',
'class' => 'grey button',
),
"View All Triage \xC2\xBB"));
$panel->appendChild($this->buildTaskListView($tasks));
$panel->setNoBackground();
return $panel;
}
private function buildRevisionPanel() {
$user = $this->getRequest()->getUser();
$user_phid = $user->getPHID();

View file

@ -165,6 +165,27 @@ final class PhabricatorManiphestConfigOptions
'create a task, even if the sender is not a system user. The '.
'original email address will be stored in an `From Email` field '.
'on the task.')),
$this->newOption(
'maniphest.priorities.unbreak-now',
'int',
100)
->setSummary(pht('Priority used to populate "Unbreak Now" on home.'))
->setDescription(
pht(
'Temporary setting. If set, this priority is used to populate the '.
'"Unbreak Now" panel on the home page. You should adjust this if '.
'you adjust priorities using `maniphest.priorities`.')),
$this->newOption(
'maniphest.priorities.needs-triage',
'int',
90)
->setSummary(pht('Priority used to populate "Needs Triage" on home.'))
->setDescription(
pht(
'Temporary setting. If set, this priority is used to populate the '.
'"Needs Triage" panel on the home page. You should adjust this if '.
'you adjust priorities using `maniphest.priorities`.')),
);
}