mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-18 18:51:12 +01:00
Add a "Create build step" transaction to Harbormaster
Summary: Without this, build steps that have no options (like "wait for previous commits") don't actually save, since the transaction array is empty. This also generally nice and consistent. Test Plan: Created a new "wait" step, viewed transaction log. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D8791
This commit is contained in:
parent
78bf266bde
commit
afd04731ab
3 changed files with 109 additions and 0 deletions
|
@ -81,6 +81,13 @@ final class HarbormasterStepEditController
|
|||
// if we create plans elsewhere.
|
||||
$steps = $plan->loadOrderedBuildSteps();
|
||||
$step->setSequence(count($steps) + 1);
|
||||
|
||||
// When creating a new step, make sure we have a create transaction
|
||||
// so we'll apply the transactions even if the step has no
|
||||
// configurable options.
|
||||
$create_xaction = id(new HarbormasterBuildStepTransaction())
|
||||
->setTransactionType(HarbormasterBuildStepTransaction::TYPE_CREATE);
|
||||
array_unshift($xactions, $create_xaction);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -3,4 +3,60 @@
|
|||
final class HarbormasterBuildStepEditor
|
||||
extends PhabricatorApplicationTransactionEditor {
|
||||
|
||||
public function getTransactionTypes() {
|
||||
$types = parent::getTransactionTypes();
|
||||
|
||||
$types[] = HarbormasterBuildStepTransaction::TYPE_CREATE;
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
protected function getCustomTransactionOldValue(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case HarbormasterBuildStepTransaction::TYPE_CREATE:
|
||||
return null;
|
||||
}
|
||||
|
||||
return parent::getCustomTransactionOldValue($object, $xaction);
|
||||
}
|
||||
|
||||
protected function getCustomTransactionNewValue(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case HarbormasterBuildStepTransaction::TYPE_CREATE:
|
||||
return true;
|
||||
}
|
||||
|
||||
return parent::getCustomTransactionNewValue($object, $xaction);
|
||||
}
|
||||
|
||||
protected function applyCustomInternalTransaction(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case HarbormasterBuildStepTransaction::TYPE_CREATE:
|
||||
return;
|
||||
}
|
||||
|
||||
return parent::applyCustomInternalTransaction($object, $xaction);
|
||||
}
|
||||
|
||||
protected function applyCustomExternalTransaction(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case HarbormasterBuildStepTransaction::TYPE_CREATE:
|
||||
return;
|
||||
}
|
||||
|
||||
return parent::applyCustomExternalTransaction($object, $xaction);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
final class HarbormasterBuildStepTransaction
|
||||
extends PhabricatorApplicationTransaction {
|
||||
|
||||
const TYPE_CREATE = 'harbormaster:step:create';
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'harbormaster';
|
||||
}
|
||||
|
@ -11,4 +13,48 @@ final class HarbormasterBuildStepTransaction
|
|||
return HarbormasterPHIDTypeBuildStep::TYPECONST;
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
$author_phid = $this->getAuthorPHID();
|
||||
|
||||
$old = $this->getOldValue();
|
||||
$new = $this->getNewValue();
|
||||
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_CREATE:
|
||||
return pht(
|
||||
'%s created this build step.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
|
||||
return parent::getTitle();
|
||||
}
|
||||
|
||||
public function getIcon() {
|
||||
$author_phid = $this->getAuthorPHID();
|
||||
|
||||
$old = $this->getOldValue();
|
||||
$new = $this->getNewValue();
|
||||
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_CREATE:
|
||||
return 'create';
|
||||
}
|
||||
|
||||
return parent::getIcon();
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
$author_phid = $this->getAuthorPHID();
|
||||
|
||||
$old = $this->getOldValue();
|
||||
$new = $this->getNewValue();
|
||||
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_CREATE:
|
||||
return 'green';
|
||||
}
|
||||
|
||||
return parent::getColor();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue