2012-11-07 00:28:33 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DrydockLeaseViewController extends DrydockController {
|
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = $data['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$lease = id(new DrydockLease())->load($this->id);
|
|
|
|
if (!$lease) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2012-12-17 23:47:21 +01:00
|
|
|
$lease_uri = $this->getApplicationURI('lease/'.$lease->getID().'/');
|
|
|
|
|
|
|
|
$title = pht('Lease %d', $lease->getID());
|
2012-11-07 00:28:33 +01:00
|
|
|
|
2013-09-17 18:12:37 +02:00
|
|
|
$header = id(new PHUIHeaderView())
|
2012-11-07 00:28:33 +01:00
|
|
|
->setHeader($title);
|
|
|
|
|
|
|
|
$actions = $this->buildActionListView($lease);
|
|
|
|
$properties = $this->buildPropertyListView($lease);
|
|
|
|
|
|
|
|
$pager = new AphrontPagerView();
|
2012-12-17 23:47:21 +01:00
|
|
|
$pager->setURI(new PhutilURI($lease_uri), 'offset');
|
2012-11-07 00:28:33 +01:00
|
|
|
$pager->setOffset($request->getInt('offset'));
|
|
|
|
|
|
|
|
$logs = id(new DrydockLogQuery())
|
|
|
|
->withLeaseIDs(array($lease->getID()))
|
|
|
|
->executeWithOffsetPager($pager);
|
|
|
|
|
|
|
|
$log_table = $this->buildLogTableView($logs);
|
|
|
|
$log_table->appendChild($pager);
|
|
|
|
|
2012-12-17 23:47:21 +01:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
2013-04-10 22:08:36 +02:00
|
|
|
$crumbs->setActionList($actions);
|
2012-12-17 23:47:21 +01:00
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setName($title)
|
|
|
|
->setHref($lease_uri));
|
|
|
|
|
2013-09-29 00:55:38 +02:00
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
Provide more structure to PHUIObjectBoxView
Summary:
Three changes here.
- Add `setActionList()`, and use that to set the action list.
- Add `setPropertyList()`, and use that to set the property list.
These will let us add some apropriate CSS so we can fix the border issue, and get rid of a bunch of goofy `.x + .y` selectors.
- Replace `addContent()` with `appendChild()`.
This is just a consistency thing; `AphrontView` already provides `appendChild()`, and `addContent()` did the same thing.
Test Plan:
- Viewed "All Config".
- Viewed a countdown.
- Viewed a revision (add comment, change list, table of contents, comment, local commits, open revisions affecting these files, update history).
- Viewed Diffusion (browse, change, history, repository, lint).
- Viewed Drydock (resource, lease).
- Viewed Files.
- Viewed Herald.
- Viewed Legalpad.
- Viewed macro (edit, edit audio, view).
- Viewed Maniphest.
- Viewed Applications.
- Viewed Paste.
- Viewed People.
- Viewed Phulux.
- Viewed Pholio.
- Viewed Phame (blog, post).
- Viewed Phortune (account, product).
- Viewed Ponder (questions, answers, comments).
- Viewed Releeph.
- Viewed Projects.
- Viewed Slowvote.
NOTE: Images in Files aren't on a black background anymore -- I assume that's on purpose?
NOTE: Some jankiness in Phortune, I'll clean that up when I get back to it. Not related to this diff.
Reviewers: chad
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D7174
2013-09-30 18:36:04 +02:00
|
|
|
->setActionList($actions)
|
|
|
|
->setPropertyList($properties);
|
2013-09-29 00:55:38 +02:00
|
|
|
|
2012-12-17 23:47:21 +01:00
|
|
|
return $this->buildApplicationPage(
|
2012-11-07 00:28:33 +01:00
|
|
|
array(
|
2012-12-17 23:47:21 +01:00
|
|
|
$crumbs,
|
2013-09-29 00:55:38 +02:00
|
|
|
$object_box,
|
2012-11-07 00:28:33 +01:00
|
|
|
$log_table,
|
2012-12-17 23:47:21 +01:00
|
|
|
),
|
2012-11-07 00:28:33 +01:00
|
|
|
array(
|
|
|
|
'device' => true,
|
|
|
|
'title' => $title,
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildActionListView(DrydockLease $lease) {
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setUser($this->getRequest()->getUser())
|
2013-07-12 20:39:47 +02:00
|
|
|
->setObjectURI($this->getRequest()->getRequestURI())
|
2012-11-07 00:28:33 +01:00
|
|
|
->setObject($lease);
|
|
|
|
|
2012-12-15 00:42:58 +01:00
|
|
|
$id = $lease->getID();
|
|
|
|
|
|
|
|
$can_release = ($lease->getStatus() == DrydockLeaseStatus::STATUS_ACTIVE);
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Release Lease'))
|
|
|
|
->setIcon('delete')
|
|
|
|
->setHref($this->getApplicationURI("/lease/{$id}/release/"))
|
|
|
|
->setWorkflow(true)
|
|
|
|
->setDisabled(!$can_release));
|
|
|
|
|
2012-11-07 00:28:33 +01:00
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPropertyListView(DrydockLease $lease) {
|
|
|
|
$view = new PhabricatorPropertyListView();
|
|
|
|
|
|
|
|
switch ($lease->getStatus()) {
|
|
|
|
case DrydockLeaseStatus::STATUS_ACTIVE:
|
|
|
|
$status = pht('Active');
|
|
|
|
break;
|
|
|
|
case DrydockLeaseStatus::STATUS_RELEASED:
|
|
|
|
$status = pht('Released');
|
|
|
|
break;
|
|
|
|
case DrydockLeaseStatus::STATUS_EXPIRED:
|
|
|
|
$status = pht('Expired');
|
|
|
|
break;
|
|
|
|
case DrydockLeaseStatus::STATUS_PENDING:
|
|
|
|
$status = pht('Pending');
|
|
|
|
break;
|
|
|
|
case DrydockLeaseStatus::STATUS_BROKEN:
|
|
|
|
$status = pht('Broken');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$status = pht('Unknown');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Status'),
|
|
|
|
$status);
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Resource Type'),
|
2013-01-29 20:01:47 +01:00
|
|
|
$lease->getResourceType());
|
2012-11-07 00:28:33 +01:00
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Resource'),
|
2013-01-29 20:01:47 +01:00
|
|
|
$lease->getResourceID());
|
2012-11-07 00:28:33 +01:00
|
|
|
|
2012-12-12 16:36:53 +01:00
|
|
|
$attributes = $lease->getAttributes();
|
|
|
|
if ($attributes) {
|
|
|
|
$view->addSectionHeader(pht('Attributes'));
|
|
|
|
foreach ($attributes as $key => $value) {
|
2013-01-29 20:01:47 +01:00
|
|
|
$view->addProperty($key, $value);
|
2012-12-12 16:36:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-07 00:28:33 +01:00
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|