Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/constants/HarbormasterBuildStatus.php
<?php | <?php | ||||
final class HarbormasterBuildStatus extends Phobject { | final class HarbormasterBuildStatus extends Phobject { | ||||
const STATUS_INACTIVE = 'inactive'; | const STATUS_INACTIVE = 'inactive'; | ||||
const STATUS_PENDING = 'pending'; | const STATUS_PENDING = 'pending'; | ||||
const STATUS_BUILDING = 'building'; | const STATUS_BUILDING = 'building'; | ||||
const STATUS_PASSED = 'passed'; | const STATUS_PASSED = 'passed'; | ||||
const STATUS_FAILED = 'failed'; | const STATUS_FAILED = 'failed'; | ||||
const STATUS_ABORTED = 'aborted'; | const STATUS_ABORTED = 'aborted'; | ||||
const STATUS_ERROR = 'error'; | const STATUS_ERROR = 'error'; | ||||
const STATUS_PAUSED = 'paused'; | const STATUS_PAUSED = 'paused'; | ||||
const STATUS_DEADLOCKED = 'deadlocked'; | const STATUS_DEADLOCKED = 'deadlocked'; | ||||
const PENDING_PAUSING = 'x-pausing'; | |||||
const PENDING_RESUMING = 'x-resuming'; | |||||
const PENDING_RESTARTING = 'x-restarting'; | |||||
const PENDING_ABORTING = 'x-aborting'; | |||||
private $key; | private $key; | ||||
private $properties; | private $properties; | ||||
public function __construct($key, array $properties) { | public function __construct($key, array $properties) { | ||||
$this->key = $key; | $this->key = $key; | ||||
$this->properties = $properties; | $this->properties = $properties; | ||||
} | } | ||||
Show All 20 Lines | final class HarbormasterBuildStatus extends Phobject { | ||||
public function isPaused() { | public function isPaused() { | ||||
return ($this->key === self::STATUS_PAUSED); | return ($this->key === self::STATUS_PAUSED); | ||||
} | } | ||||
public function isComplete() { | public function isComplete() { | ||||
return $this->getProperty('isComplete'); | return $this->getProperty('isComplete'); | ||||
} | } | ||||
public function isPending() { | |||||
return $this->getProperty('isPending'); | |||||
} | |||||
public function isPassed() { | public function isPassed() { | ||||
return ($this->key === self::STATUS_PASSED); | return ($this->key === self::STATUS_PASSED); | ||||
} | } | ||||
public function isFailed() { | public function isFailed() { | ||||
return ($this->key === self::STATUS_FAILED); | return ($this->key === self::STATUS_FAILED); | ||||
} | } | ||||
public function isAborting() { | |||||
return ($this->key === self::PENDING_ABORTING); | |||||
} | |||||
public function isRestarting() { | |||||
return ($this->key === self::PENDING_RESTARTING); | |||||
} | |||||
public function isResuming() { | |||||
return ($this->key === self::PENDING_RESUMING); | |||||
} | |||||
public function isPausing() { | |||||
return ($this->key === self::PENDING_PAUSING); | |||||
} | |||||
public function getIconIcon() { | |||||
return $this->getProperty('icon'); | |||||
} | |||||
public function getIconColor() { | |||||
return $this->getProperty('color'); | |||||
} | |||||
public function getName() { | |||||
return $this->getProperty('name'); | |||||
} | |||||
/** | /** | ||||
* Get a human readable name for a build status constant. | * Get a human readable name for a build status constant. | ||||
* | * | ||||
* @param const Build status constant. | * @param const Build status constant. | ||||
* @return string Human-readable name. | * @return string Human-readable name. | ||||
*/ | */ | ||||
public static function getBuildStatusName($status) { | public static function getBuildStatusName($status) { | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | private static function getBuildStatusSpecMap() { | ||||
return array( | return array( | ||||
self::STATUS_INACTIVE => array( | self::STATUS_INACTIVE => array( | ||||
'name' => pht('Inactive'), | 'name' => pht('Inactive'), | ||||
'icon' => 'fa-circle-o', | 'icon' => 'fa-circle-o', | ||||
'color' => 'dark', | 'color' => 'dark', | ||||
'color.ansi' => 'yellow', | 'color.ansi' => 'yellow', | ||||
'isBuilding' => false, | 'isBuilding' => false, | ||||
'isComplete' => false, | 'isComplete' => false, | ||||
'isPending' => false, | |||||
), | ), | ||||
self::STATUS_PENDING => array( | self::STATUS_PENDING => array( | ||||
'name' => pht('Pending'), | 'name' => pht('Pending'), | ||||
'icon' => 'fa-circle-o', | 'icon' => 'fa-circle-o', | ||||
'color' => 'blue', | 'color' => 'blue', | ||||
'color.ansi' => 'yellow', | 'color.ansi' => 'yellow', | ||||
'isBuilding' => true, | 'isBuilding' => true, | ||||
'isComplete' => false, | 'isComplete' => false, | ||||
'isPending' => false, | |||||
), | ), | ||||
self::STATUS_BUILDING => array( | self::STATUS_BUILDING => array( | ||||
'name' => pht('Building'), | 'name' => pht('Building'), | ||||
'icon' => 'fa-chevron-circle-right', | 'icon' => 'fa-chevron-circle-right', | ||||
'color' => 'blue', | 'color' => 'blue', | ||||
'color.ansi' => 'yellow', | 'color.ansi' => 'yellow', | ||||
'isBuilding' => true, | 'isBuilding' => true, | ||||
'isComplete' => false, | 'isComplete' => false, | ||||
'isPending' => false, | |||||
), | ), | ||||
self::STATUS_PASSED => array( | self::STATUS_PASSED => array( | ||||
'name' => pht('Passed'), | 'name' => pht('Passed'), | ||||
'icon' => 'fa-check-circle', | 'icon' => 'fa-check-circle', | ||||
'color' => 'green', | 'color' => 'green', | ||||
'color.ansi' => 'green', | 'color.ansi' => 'green', | ||||
'isBuilding' => false, | 'isBuilding' => false, | ||||
'isComplete' => true, | 'isComplete' => true, | ||||
'isPending' => false, | |||||
), | ), | ||||
self::STATUS_FAILED => array( | self::STATUS_FAILED => array( | ||||
'name' => pht('Failed'), | 'name' => pht('Failed'), | ||||
'icon' => 'fa-times-circle', | 'icon' => 'fa-times-circle', | ||||
'color' => 'red', | 'color' => 'red', | ||||
'color.ansi' => 'red', | 'color.ansi' => 'red', | ||||
'isBuilding' => false, | 'isBuilding' => false, | ||||
'isComplete' => true, | 'isComplete' => true, | ||||
'isPending' => false, | |||||
), | ), | ||||
self::STATUS_ABORTED => array( | self::STATUS_ABORTED => array( | ||||
'name' => pht('Aborted'), | 'name' => pht('Aborted'), | ||||
'icon' => 'fa-minus-circle', | 'icon' => 'fa-minus-circle', | ||||
'color' => 'red', | 'color' => 'red', | ||||
'color.ansi' => 'red', | 'color.ansi' => 'red', | ||||
'isBuilding' => false, | 'isBuilding' => false, | ||||
'isComplete' => true, | 'isComplete' => true, | ||||
'isPending' => false, | |||||
), | ), | ||||
self::STATUS_ERROR => array( | self::STATUS_ERROR => array( | ||||
'name' => pht('Unexpected Error'), | 'name' => pht('Unexpected Error'), | ||||
'icon' => 'fa-minus-circle', | 'icon' => 'fa-minus-circle', | ||||
'color' => 'red', | 'color' => 'red', | ||||
'color.ansi' => 'red', | 'color.ansi' => 'red', | ||||
'isBuilding' => false, | 'isBuilding' => false, | ||||
'isComplete' => true, | 'isComplete' => true, | ||||
'isPending' => false, | |||||
), | ), | ||||
self::STATUS_PAUSED => array( | self::STATUS_PAUSED => array( | ||||
'name' => pht('Paused'), | 'name' => pht('Paused'), | ||||
'icon' => 'fa-minus-circle', | 'icon' => 'fa-minus-circle', | ||||
'color' => 'dark', | 'color' => 'dark', | ||||
'color.ansi' => 'yellow', | 'color.ansi' => 'yellow', | ||||
'isBuilding' => false, | 'isBuilding' => false, | ||||
'isComplete' => false, | 'isComplete' => false, | ||||
'isPending' => false, | |||||
), | ), | ||||
self::STATUS_DEADLOCKED => array( | self::STATUS_DEADLOCKED => array( | ||||
'name' => pht('Deadlocked'), | 'name' => pht('Deadlocked'), | ||||
'icon' => 'fa-exclamation-circle', | 'icon' => 'fa-exclamation-circle', | ||||
'color' => 'red', | 'color' => 'red', | ||||
'color.ansi' => 'red', | 'color.ansi' => 'red', | ||||
'isBuilding' => false, | 'isBuilding' => false, | ||||
'isComplete' => true, | 'isComplete' => true, | ||||
'isPending' => false, | |||||
), | |||||
self::PENDING_PAUSING => array( | |||||
'name' => pht('Pausing'), | |||||
'icon' => 'fa-exclamation-triangle', | |||||
'color' => 'red', | |||||
'color.ansi' => 'red', | |||||
'isBuilding' => false, | |||||
'isComplete' => false, | |||||
'isPending' => true, | |||||
), | |||||
self::PENDING_RESUMING => array( | |||||
'name' => pht('Resuming'), | |||||
'icon' => 'fa-exclamation-triangle', | |||||
'color' => 'red', | |||||
'color.ansi' => 'red', | |||||
'isBuilding' => false, | |||||
'isComplete' => false, | |||||
'isPending' => true, | |||||
), | |||||
self::PENDING_RESTARTING => array( | |||||
'name' => pht('Restarting'), | |||||
'icon' => 'fa-exclamation-triangle', | |||||
'color' => 'red', | |||||
'color.ansi' => 'red', | |||||
'isBuilding' => false, | |||||
'isComplete' => false, | |||||
'isPending' => true, | |||||
), | |||||
self::PENDING_ABORTING => array( | |||||
'name' => pht('Aborting'), | |||||
'icon' => 'fa-exclamation-triangle', | |||||
'color' => 'red', | |||||
'color.ansi' => 'red', | |||||
'isBuilding' => false, | |||||
'isComplete' => false, | |||||
'isPending' => true, | |||||
), | ), | ||||
); | ); | ||||
} | } | ||||
private static function getBuildStatusSpec($status) { | private static function getBuildStatusSpec($status) { | ||||
$map = self::getBuildStatusSpecMap(); | $map = self::getBuildStatusSpecMap(); | ||||
if (isset($map[$status])) { | if (isset($map[$status])) { | ||||
return $map[$status]; | return $map[$status]; | ||||
Show All 13 Lines |