1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-13 10:22:42 +01:00
phorge-phorge/src/applications/drydock/controller/DrydockLeaseReleaseController.php
epriestley 5fdd800bb6 Provide a Drydock "Console" controller
Summary:
Ref T2015. After introducing ApplicationSearch, the left nav turned into a soupy mess. Split the major sections into four separate areas, and unify them with a simple console.

This also reverts all the prefix stuff, since the results were awful and I don't anticipate it ever being the best solution to any UX problem.

Test Plan:
Browsed blueprints, resources, leases and logs.

Here's the new console:

{F93279}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2015

Differential Revision: https://secure.phabricator.com/D7833
2013-12-26 12:30:36 -08:00

58 lines
1.7 KiB
PHP

<?php
final class DrydockLeaseReleaseController extends DrydockLeaseController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$lease = id(new DrydockLeaseQuery())
->setViewer($user)
->withIDs(array($this->id))
->executeOne();
if (!$lease) {
return new Aphront404Response();
}
$lease_uri = '/lease/'.$lease->getID().'/';
$lease_uri = $this->getApplicationURI($lease_uri);
if ($lease->getStatus() != DrydockLeaseStatus::STATUS_ACTIVE) {
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle(pht('Lease Not Active'))
->appendChild(phutil_tag('p', array(), pht(
'You can only release "active" leases.')))
->addCancelButton($lease_uri);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
if (!$request->isDialogFormPost()) {
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle(pht('Really release lease?'))
->appendChild(phutil_tag('p', array(), pht(
'Releasing a lease may cause trouble for the lease holder and '.
'trigger cleanup of the underlying resource. It can not be '.
'undone. Continue?')))
->addSubmitButton(pht('Release Lease'))
->addCancelButton($lease_uri);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$resource = $lease->getResource();
$blueprint = $resource->getBlueprint();
$blueprint->releaseLease($resource, $lease);
return id(new AphrontReloadResponse())->setURI($lease_uri);
}
}