mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
Give Drydock Resources more modern status treatment
Summary: Ref T13073. Depends on D19074. Update icons and UI for resource status. Test Plan: Viewed resources in detail view and list view, saw better status icons. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13073 Differential Revision: https://secure.phabricator.com/D19075
This commit is contained in:
parent
27c3793d40
commit
06bbf237fe
7 changed files with 124 additions and 72 deletions
|
@ -1041,7 +1041,6 @@ phutil_register_library_map(array(
|
||||||
'DrydockCommandInterface' => 'applications/drydock/interface/command/DrydockCommandInterface.php',
|
'DrydockCommandInterface' => 'applications/drydock/interface/command/DrydockCommandInterface.php',
|
||||||
'DrydockCommandQuery' => 'applications/drydock/query/DrydockCommandQuery.php',
|
'DrydockCommandQuery' => 'applications/drydock/query/DrydockCommandQuery.php',
|
||||||
'DrydockConsoleController' => 'applications/drydock/controller/DrydockConsoleController.php',
|
'DrydockConsoleController' => 'applications/drydock/controller/DrydockConsoleController.php',
|
||||||
'DrydockConstants' => 'applications/drydock/constants/DrydockConstants.php',
|
|
||||||
'DrydockController' => 'applications/drydock/controller/DrydockController.php',
|
'DrydockController' => 'applications/drydock/controller/DrydockController.php',
|
||||||
'DrydockCreateBlueprintsCapability' => 'applications/drydock/capability/DrydockCreateBlueprintsCapability.php',
|
'DrydockCreateBlueprintsCapability' => 'applications/drydock/capability/DrydockCreateBlueprintsCapability.php',
|
||||||
'DrydockDAO' => 'applications/drydock/storage/DrydockDAO.php',
|
'DrydockDAO' => 'applications/drydock/storage/DrydockDAO.php',
|
||||||
|
@ -6259,7 +6258,6 @@ phutil_register_library_map(array(
|
||||||
'DrydockCommandInterface' => 'DrydockInterface',
|
'DrydockCommandInterface' => 'DrydockInterface',
|
||||||
'DrydockCommandQuery' => 'DrydockQuery',
|
'DrydockCommandQuery' => 'DrydockQuery',
|
||||||
'DrydockConsoleController' => 'DrydockController',
|
'DrydockConsoleController' => 'DrydockController',
|
||||||
'DrydockConstants' => 'Phobject',
|
|
||||||
'DrydockController' => 'PhabricatorController',
|
'DrydockController' => 'PhabricatorController',
|
||||||
'DrydockCreateBlueprintsCapability' => 'PhabricatorPolicyCapability',
|
'DrydockCreateBlueprintsCapability' => 'PhabricatorPolicyCapability',
|
||||||
'DrydockDAO' => 'PhabricatorLiskDAO',
|
'DrydockDAO' => 'PhabricatorLiskDAO',
|
||||||
|
@ -6347,7 +6345,7 @@ phutil_register_library_map(array(
|
||||||
'DrydockResourceReclaimLogType' => 'DrydockLogType',
|
'DrydockResourceReclaimLogType' => 'DrydockLogType',
|
||||||
'DrydockResourceReleaseController' => 'DrydockResourceController',
|
'DrydockResourceReleaseController' => 'DrydockResourceController',
|
||||||
'DrydockResourceSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'DrydockResourceSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'DrydockResourceStatus' => 'DrydockConstants',
|
'DrydockResourceStatus' => 'PhabricatorObjectStatus',
|
||||||
'DrydockResourceUpdateWorker' => 'DrydockWorker',
|
'DrydockResourceUpdateWorker' => 'DrydockWorker',
|
||||||
'DrydockResourceViewController' => 'DrydockResourceController',
|
'DrydockResourceViewController' => 'DrydockResourceController',
|
||||||
'DrydockSFTPFilesystemInterface' => 'DrydockFilesystemInterface',
|
'DrydockSFTPFilesystemInterface' => 'DrydockFilesystemInterface',
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
abstract class DrydockConstants extends Phobject {}
|
|
|
@ -95,7 +95,7 @@ final class DrydockLeaseStatus
|
||||||
'key' => self::STATUS_DESTROYED,
|
'key' => self::STATUS_DESTROYED,
|
||||||
'name' => pht('Destroyed'),
|
'name' => pht('Destroyed'),
|
||||||
'icon' => 'fa-times',
|
'icon' => 'fa-times',
|
||||||
'color' => 'red',
|
'color' => 'grey',
|
||||||
'isReleasable' => false,
|
'isReleasable' => false,
|
||||||
'isCommandable' => false,
|
'isCommandable' => false,
|
||||||
'isActivating' => false,
|
'isActivating' => false,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class DrydockResourceStatus extends DrydockConstants {
|
final class DrydockResourceStatus
|
||||||
|
extends PhabricatorObjectStatus {
|
||||||
|
|
||||||
const STATUS_PENDING = 'pending';
|
const STATUS_PENDING = 'pending';
|
||||||
const STATUS_ACTIVE = 'active';
|
const STATUS_ACTIVE = 'active';
|
||||||
|
@ -8,23 +9,86 @@ final class DrydockResourceStatus extends DrydockConstants {
|
||||||
const STATUS_BROKEN = 'broken';
|
const STATUS_BROKEN = 'broken';
|
||||||
const STATUS_DESTROYED = 'destroyed';
|
const STATUS_DESTROYED = 'destroyed';
|
||||||
|
|
||||||
|
public static function newStatusObject($key) {
|
||||||
|
return new self($key, id(new self())->getStatusSpecification($key));
|
||||||
|
}
|
||||||
|
|
||||||
public static function getStatusMap() {
|
public static function getStatusMap() {
|
||||||
return array(
|
$map = id(new self())->getStatusSpecifications();
|
||||||
self::STATUS_PENDING => pht('Pending'),
|
return ipull($map, 'name', 'key');
|
||||||
self::STATUS_ACTIVE => pht('Active'),
|
|
||||||
self::STATUS_RELEASED => pht('Released'),
|
|
||||||
self::STATUS_BROKEN => pht('Broken'),
|
|
||||||
self::STATUS_DESTROYED => pht('Destroyed'),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getNameForStatus($status) {
|
public static function getNameForStatus($status) {
|
||||||
$map = self::getStatusMap();
|
$map = id(new self())->getStatusSpecification($status);
|
||||||
return idx($map, $status, pht('Unknown'));
|
return $map['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllStatuses() {
|
public static function getAllStatuses() {
|
||||||
return array_keys(self::getStatusMap());
|
return array_keys(id(new self())->getStatusSpecifications());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isActive() {
|
||||||
|
return ($this->getKey() === self::STATUS_ACTIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canRelease() {
|
||||||
|
return $this->getStatusProperty('isReleasable');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canReceiveCommands() {
|
||||||
|
return $this->getStatusProperty('isCommandable');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newStatusSpecifications() {
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'key' => self::STATUS_PENDING,
|
||||||
|
'name' => pht('Pending'),
|
||||||
|
'icon' => 'fa-clock-o',
|
||||||
|
'color' => 'blue',
|
||||||
|
'isReleasable' => true,
|
||||||
|
'isCommandable' => true,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'key' => self::STATUS_ACTIVE,
|
||||||
|
'name' => pht('Active'),
|
||||||
|
'icon' => 'fa-check',
|
||||||
|
'color' => 'green',
|
||||||
|
'isReleasable' => true,
|
||||||
|
'isCommandable' => true,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'key' => self::STATUS_RELEASED,
|
||||||
|
'name' => pht('Released'),
|
||||||
|
'icon' => 'fa-circle-o',
|
||||||
|
'color' => 'blue',
|
||||||
|
'isReleasable' => false,
|
||||||
|
'isCommandable' => false,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'key' => self::STATUS_BROKEN,
|
||||||
|
'name' => pht('Broken'),
|
||||||
|
'icon' => 'fa-times',
|
||||||
|
'color' => 'indigo',
|
||||||
|
'isReleasable' => true,
|
||||||
|
'isCommandable' => false,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'key' => self::STATUS_DESTROYED,
|
||||||
|
'name' => pht('Destroyed'),
|
||||||
|
'icon' => 'fa-times',
|
||||||
|
'color' => 'grey',
|
||||||
|
'isReleasable' => false,
|
||||||
|
'isCommandable' => false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newUnknownStatusSpecification($status) {
|
||||||
|
return array(
|
||||||
|
'isReleasable' => false,
|
||||||
|
'isCommandable' => false,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,19 @@ final class DrydockResourceViewController extends DrydockResourceController {
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setPolicyObject($resource)
|
->setPolicyObject($resource)
|
||||||
->setHeader($title)
|
->setHeader($title)
|
||||||
->setHeaderIcon('fa-map');
|
->setHeaderIcon('fa-map')
|
||||||
|
->setStatus(
|
||||||
|
$resource->getStatusIcon(),
|
||||||
|
$resource->getStatusColor(),
|
||||||
|
$resource->getStatusDisplayName());
|
||||||
|
|
||||||
if ($resource->isReleasing()) {
|
if ($resource->isReleasing()) {
|
||||||
$header->setStatus('fa-exclamation-triangle', 'red', pht('Releasing'));
|
$header->addTag(
|
||||||
|
id(new PHUITagView())
|
||||||
|
->setType(PHUITagView::TYPE_SHADE)
|
||||||
|
->setIcon('fa-exclamation-triangle')
|
||||||
|
->setColor('red')
|
||||||
|
->setName('Releasing'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$curtain = $this->buildCurtain($resource);
|
$curtain = $this->buildCurtain($resource);
|
||||||
|
@ -127,12 +136,6 @@ final class DrydockResourceViewController extends DrydockResourceController {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$view = new PHUIPropertyListView();
|
$view = new PHUIPropertyListView();
|
||||||
$status = $resource->getStatus();
|
|
||||||
$status = DrydockResourceStatus::getNameForStatus($status);
|
|
||||||
|
|
||||||
$view->addProperty(
|
|
||||||
pht('Status'),
|
|
||||||
$status);
|
|
||||||
|
|
||||||
$until = $resource->getUntil();
|
$until = $resource->getUntil();
|
||||||
if ($until) {
|
if ($until) {
|
||||||
|
|
|
@ -235,16 +235,6 @@ final class DrydockResource extends DrydockDAO
|
||||||
return $this->isActivated;
|
return $this->isActivated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canRelease() {
|
|
||||||
switch ($this->getStatus()) {
|
|
||||||
case DrydockResourceStatus::STATUS_RELEASED:
|
|
||||||
case DrydockResourceStatus::STATUS_DESTROYED:
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function scheduleUpdate($epoch = null) {
|
public function scheduleUpdate($epoch = null) {
|
||||||
PhabricatorWorker::scheduleTask(
|
PhabricatorWorker::scheduleTask(
|
||||||
'DrydockResourceUpdateWorker',
|
'DrydockResourceUpdateWorker',
|
||||||
|
@ -282,26 +272,6 @@ final class DrydockResource extends DrydockDAO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canReceiveCommands() {
|
|
||||||
switch ($this->getStatus()) {
|
|
||||||
case DrydockResourceStatus::STATUS_RELEASED:
|
|
||||||
case DrydockResourceStatus::STATUS_BROKEN:
|
|
||||||
case DrydockResourceStatus::STATUS_DESTROYED:
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isActive() {
|
|
||||||
switch ($this->getStatus()) {
|
|
||||||
case DrydockResourceStatus::STATUS_ACTIVE:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function logEvent($type, array $data = array()) {
|
public function logEvent($type, array $data = array()) {
|
||||||
$log = id(new DrydockLog())
|
$log = id(new DrydockLog())
|
||||||
->setEpoch(PhabricatorTime::getNow())
|
->setEpoch(PhabricatorTime::getNow())
|
||||||
|
@ -315,6 +285,38 @@ final class DrydockResource extends DrydockDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( Status )------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function getStatusObject() {
|
||||||
|
return DrydockResourceStatus::newStatusObject($this->getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatusIcon() {
|
||||||
|
return $this->getStatusObject()->getIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatusColor() {
|
||||||
|
return $this->getStatusObject()->getColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatusDisplayName() {
|
||||||
|
return $this->getStatusObject()->getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canRelease() {
|
||||||
|
return $this->getStatusObject()->canRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canReceiveCommands() {
|
||||||
|
return $this->getStatusObject()->canReceiveCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isActive() {
|
||||||
|
return $this->getStatusObject()->isActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,23 +23,11 @@ final class DrydockResourceListView extends AphrontView {
|
||||||
->setObjectName(pht('Resource %d', $id))
|
->setObjectName(pht('Resource %d', $id))
|
||||||
->setHeader($resource->getResourceName());
|
->setHeader($resource->getResourceName());
|
||||||
|
|
||||||
$status = DrydockResourceStatus::getNameForStatus($resource->getStatus());
|
$icon = $resource->getStatusIcon();
|
||||||
$item->addAttribute($status);
|
$color = $resource->getStatusColor();
|
||||||
|
$label = $resource->getStatusDisplayName();
|
||||||
|
|
||||||
switch ($resource->getStatus()) {
|
$item->setStatusIcon("{$icon} {$color}", $label);
|
||||||
case DrydockResourceStatus::STATUS_PENDING:
|
|
||||||
$item->setStatusIcon('fa-dot-circle-o yellow');
|
|
||||||
break;
|
|
||||||
case DrydockResourceStatus::STATUS_ACTIVE:
|
|
||||||
$item->setStatusIcon('fa-dot-circle-o green');
|
|
||||||
break;
|
|
||||||
case DrydockResourceStatus::STATUS_DESTROYED:
|
|
||||||
$item->setStatusIcon('fa-times-circle-o black');
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$item->setStatusIcon('fa-dot-circle-o red');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$view->addItem($item);
|
$view->addItem($item);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue