2011-03-26 22:55:18 -07:00
|
|
|
<?php
|
|
|
|
|
2012-03-09 15:46:25 -08:00
|
|
|
final class PhabricatorWorkerTaskDetailController
|
2011-03-26 22:55:18 -07:00
|
|
|
extends PhabricatorDaemonController {
|
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = $data['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
2012-10-31 15:22:16 -07:00
|
|
|
$task = id(new PhabricatorWorkerActiveTask())->load($this->id);
|
2011-03-26 22:55:18 -07:00
|
|
|
if (!$task) {
|
2012-10-31 15:22:32 -07:00
|
|
|
$task = id(new PhabricatorWorkerArchiveTask())->load($this->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$task) {
|
|
|
|
$title = pht('Task Does Not Exist');
|
|
|
|
|
2011-03-26 22:55:18 -07:00
|
|
|
$error_view = new AphrontErrorView();
|
|
|
|
$error_view->setTitle('No Such Task');
|
|
|
|
$error_view->appendChild(
|
2012-10-31 15:22:32 -07:00
|
|
|
'<p>This task may have recently been garbage collected.</p>');
|
|
|
|
$error_view->setSeverity(AphrontErrorView::SEVERITY_NODATA);
|
2011-03-26 22:55:18 -07:00
|
|
|
|
2012-10-31 15:22:32 -07:00
|
|
|
$content = $error_view;
|
|
|
|
} else {
|
|
|
|
$title = 'Task '.$task->getID();
|
Improve several Diffusion UI error states
Summary:
Give users better errors and UI:
- For subpath SVN repositories, default the path to the subdirectory, not to
"/". This makes the home screen useful and things generally less confusing.
- For unparsed commits, show a more descriptive error message without the
"blah blah" silliness.
- For paths outside of the subpath parse tree, short circuit into an
appropriate error message.
- For foreign SVN stub commits (see D892), show an explicit message.
Test Plan: Looked at unparsed commits, subpath repositories, foreign stub
commits, and paths outside of the subpath parse tree. Received sensible error
messages.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 894
2011-09-04 14:39:52 -07:00
|
|
|
|
2012-10-31 15:22:32 -07:00
|
|
|
$header = id(new PhabricatorHeaderView())
|
|
|
|
->setHeader('Task '.$task->getID().' ('.$task->getTaskClass().')');
|
2011-03-26 22:55:18 -07:00
|
|
|
|
2012-10-31 15:22:32 -07:00
|
|
|
$actions = $this->buildActionListView($task);
|
|
|
|
$properties = $this->buildPropertyListView($task);
|
Improve several Diffusion UI error states
Summary:
Give users better errors and UI:
- For subpath SVN repositories, default the path to the subdirectory, not to
"/". This makes the home screen useful and things generally less confusing.
- For unparsed commits, show a more descriptive error message without the
"blah blah" silliness.
- For paths outside of the subpath parse tree, short circuit into an
appropriate error message.
- For foreign SVN stub commits (see D892), show an explicit message.
Test Plan: Looked at unparsed commits, subpath repositories, foreign stub
commits, and paths outside of the subpath parse tree. Received sensible error
messages.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 894
2011-09-04 14:39:52 -07:00
|
|
|
|
2012-10-31 15:22:32 -07:00
|
|
|
$content = array(
|
|
|
|
$header,
|
|
|
|
$actions,
|
|
|
|
$properties,
|
|
|
|
);
|
|
|
|
}
|
2012-01-23 16:36:32 -08:00
|
|
|
|
2012-08-13 15:27:45 -07:00
|
|
|
$nav = $this->buildSideNavView();
|
|
|
|
$nav->selectFilter('');
|
2012-10-31 15:22:32 -07:00
|
|
|
$nav->appendChild($content);
|
2012-08-13 15:27:45 -07:00
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
$nav,
|
2011-03-26 22:55:18 -07:00
|
|
|
array(
|
2012-10-31 15:22:32 -07:00
|
|
|
'title' => $title,
|
2011-03-26 22:55:18 -07:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2012-10-31 15:22:32 -07:00
|
|
|
private function buildActionListView(PhabricatorWorkerTask $task) {
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = new PhabricatorActionListView();
|
|
|
|
$view->setUser($user);
|
|
|
|
|
|
|
|
$id = $task->getID();
|
|
|
|
|
|
|
|
if ($task->isArchived()) {
|
|
|
|
$result_success = PhabricatorWorkerArchiveTask::RESULT_SUCCESS;
|
|
|
|
$can_retry = ($task->getResult() != $result_success);
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Retry Task'))
|
|
|
|
->setHref($this->getApplicationURI('/task/'.$id.'/retry/'))
|
|
|
|
->setIcon('undo')
|
|
|
|
->setWorkflow(true)
|
|
|
|
->setDisabled(!$can_retry));
|
|
|
|
} else {
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Cancel Task'))
|
|
|
|
->setHref($this->getApplicationURI('/task/'.$id.'/cancel/'))
|
|
|
|
->setIcon('delete')
|
|
|
|
->setWorkflow(true));
|
|
|
|
}
|
|
|
|
|
|
|
|
$can_release = (!$task->isArchived()) &&
|
|
|
|
($task->getLeaseOwner());
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Free Lease'))
|
|
|
|
->setHref($this->getApplicationURI('/task/'.$id.'/release/'))
|
|
|
|
->setIcon('unlock')
|
|
|
|
->setWorkflow(true)
|
|
|
|
->setDisabled(!$can_release));
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPropertyListView(PhabricatorWorkerTask $task) {
|
|
|
|
$view = new PhabricatorPropertyListView();
|
|
|
|
|
|
|
|
if ($task->isArchived()) {
|
|
|
|
switch ($task->getResult()) {
|
|
|
|
case PhabricatorWorkerArchiveTask::RESULT_SUCCESS:
|
|
|
|
$status = pht('Complete');
|
|
|
|
break;
|
|
|
|
case PhabricatorWorkerArchiveTask::RESULT_FAILURE:
|
|
|
|
$status = pht('Failed');
|
|
|
|
break;
|
|
|
|
case PhabricatorWorkerArchiveTask::RESULT_CANCELLED:
|
|
|
|
$status = pht('Cancelled');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw new Exception("Unknown task status!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$status = pht('Queued');
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Task Status'),
|
|
|
|
$status);
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Task Class'),
|
|
|
|
phutil_escape_html($task->getTaskClass()));
|
|
|
|
|
|
|
|
if ($task->getLeaseExpires()) {
|
|
|
|
if ($task->getLeaseExpires() > time()) {
|
|
|
|
$lease_status = pht('Leased');
|
|
|
|
} else {
|
|
|
|
$lease_status = pht('Lease Expired');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$lease_status = '<em>'.pht('Not Leased').'</em>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Lease Status'),
|
|
|
|
$lease_status);
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Lease Owner'),
|
|
|
|
$task->getLeaseOwner()
|
|
|
|
? phutil_escape_html($task->getLeaseOwner())
|
|
|
|
: '<em>'.pht('None').'</em>');
|
|
|
|
|
|
|
|
if ($task->getLeaseExpires() && $task->getLeaseOwner()) {
|
|
|
|
$expires = ($task->getLeaseExpires() - time());
|
|
|
|
$expires = phabricator_format_relative_time_detailed($expires);
|
|
|
|
} else {
|
|
|
|
$expires = '<em>'.pht('None').'</em>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Lease Expires'),
|
|
|
|
$expires);
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Failure Count'),
|
|
|
|
phutil_escape_html($task->getFailureCount()));
|
|
|
|
|
|
|
|
if ($task->isArchived()) {
|
|
|
|
$duration = phutil_escape_html(number_format($task->getDuration()).' us');
|
|
|
|
} else {
|
|
|
|
$duration = '<em>'.pht('Not Completed').'</em>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Duration'),
|
|
|
|
$duration);
|
|
|
|
|
2012-12-17 17:12:55 -08:00
|
|
|
$data = id(new PhabricatorWorkerTaskData())->load($task->getDataID());
|
|
|
|
$task->setData($data->getData());
|
|
|
|
$worker = $task->getWorkerInstance();
|
|
|
|
$data = $worker->renderForDisplay();
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Data'),
|
|
|
|
$data);
|
|
|
|
|
2012-10-31 15:22:32 -07:00
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2011-03-26 22:55:18 -07:00
|
|
|
}
|