1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 07:50:57 +01:00

Allow users to specify names of build steps

Summary: Ref T1049.  This provides a user-configurable name field on build steps, which allows users to uniquely identify their steps.  The intention is that this field will be used in D9806 to better identify the dependencies (rather than showing an unhelpful PHID).

Test Plan: Set the name of some build steps, saw it appear in the correct places.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T1049

Differential Revision: https://secure.phabricator.com/D9816
This commit is contained in:
James Rhodes 2014-07-05 01:56:02 +10:00
parent e8d217b8bd
commit a3d50118e1
10 changed files with 60 additions and 9 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildstep
ADD name VARCHAR(255) COLLATE utf8_bin;

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildtarget
ADD name VARCHAR(255) COLLATE utf8_bin;

View file

@ -72,7 +72,7 @@ final class HarbormasterBuildViewController
->setHeader(pht(
'Build Target %d (%s)',
$build_target->getID(),
$build_target->getImplementation()->getName()))
$build_target->getName()))
->setUser($viewer);
$properties = new PHUIPropertyListView();

View file

@ -282,12 +282,7 @@ final class HarbormasterBuildableViewController
break;
}
try {
$impl = $target->getImplementation();
$name = $impl->getName();
} catch (Exception $ex) {
$name = $target->getClassName();
}
$name = $target->getName();
$target_list->addItem(
id(new PHUIStatusItemView())

View file

@ -129,7 +129,7 @@ final class HarbormasterPlanViewController
}
$item = id(new PHUIObjectItemView())
->setObjectName('Step '.$i++)
->setHeader($implementation->getName());
->setHeader($step->getName());
$item->addAttribute($implementation->getDescription());

View file

@ -64,9 +64,15 @@ final class HarbormasterStepEditController
->setViewer($viewer)
->readFieldsFromStorage($step);
$e_name = true;
$v_name = $step->getName();
$errors = array();
$validation_exception = null;
if ($request->isFormPost()) {
$e_name = null;
$v_name = $request->getStr('name');
$xactions = $field_list->buildFieldTransactionsFromRequest(
new HarbormasterBuildStepTransaction(),
$request);
@ -76,6 +82,11 @@ final class HarbormasterStepEditController
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request);
$name_xaction = id(new HarbormasterBuildStepTransaction())
->setTransactionType(HarbormasterBuildStepTransaction::TYPE_NAME)
->setNewValue($v_name);
array_unshift($xactions, $name_xaction);
if ($is_new) {
// This is okay, but a little iffy. We should move it inside the editor
// if we create plans elsewhere.
@ -99,7 +110,13 @@ final class HarbormasterStepEditController
}
$form = id(new AphrontFormView())
->setUser($viewer);
->setUser($viewer)
->appendChild(
id(new AphrontFormTextControl())
->setName('name')
->setLabel(pht('Name'))
->setError($e_name)
->setValue($v_name));
$field_list->appendFieldsToForm($form);

View file

@ -7,6 +7,7 @@ final class HarbormasterBuildStepEditor
$types = parent::getTransactionTypes();
$types[] = HarbormasterBuildStepTransaction::TYPE_CREATE;
$types[] = HarbormasterBuildStepTransaction::TYPE_NAME;
return $types;
}
@ -18,6 +19,11 @@ final class HarbormasterBuildStepEditor
switch ($xaction->getTransactionType()) {
case HarbormasterBuildStepTransaction::TYPE_CREATE:
return null;
case HarbormasterBuildStepTransaction::TYPE_NAME:
if ($this->getIsNewObject()) {
return null;
}
return $object->getName();
}
return parent::getCustomTransactionOldValue($object, $xaction);
@ -30,6 +36,8 @@ final class HarbormasterBuildStepEditor
switch ($xaction->getTransactionType()) {
case HarbormasterBuildStepTransaction::TYPE_CREATE:
return true;
case HarbormasterBuildStepTransaction::TYPE_NAME:
return $xaction->getNewValue();
}
return parent::getCustomTransactionNewValue($object, $xaction);
@ -42,6 +50,8 @@ final class HarbormasterBuildStepEditor
switch ($xaction->getTransactionType()) {
case HarbormasterBuildStepTransaction::TYPE_CREATE:
return;
case HarbormasterBuildStepTransaction::TYPE_NAME:
return $object->setName($xaction->getNewValue());
}
return parent::applyCustomInternalTransaction($object, $xaction);
@ -53,6 +63,7 @@ final class HarbormasterBuildStepEditor
switch ($xaction->getTransactionType()) {
case HarbormasterBuildStepTransaction::TYPE_CREATE:
case HarbormasterBuildStepTransaction::TYPE_NAME:
return;
}

View file

@ -3,6 +3,7 @@
final class HarbormasterBuildTarget extends HarbormasterDAO
implements PhabricatorPolicyInterface {
protected $name;
protected $buildPHID;
protected $buildStepPHID;
protected $className;
@ -25,6 +26,7 @@ final class HarbormasterBuildTarget extends HarbormasterDAO
HarbormasterBuildStep $build_step,
array $variables) {
return id(new HarbormasterBuildTarget())
->setName($build_step->getName())
->setBuildPHID($build->getPHID())
->setBuildStepPHID($build_step->getPHID())
->setClassName($build_step->getClassName())
@ -99,6 +101,18 @@ final class HarbormasterBuildTarget extends HarbormasterDAO
return $this->implementation;
}
public function getName() {
if (strlen($this->name)) {
return $this->name;
}
try {
return $this->getImplementation()->getName();
} catch (Exception $e) {
return $this->getClassName();
}
}
private function getBuildTargetVariables() {
return array(
'target.phid' => $this->getPHID(),

View file

@ -5,6 +5,7 @@ final class HarbormasterBuildStep extends HarbormasterDAO
PhabricatorPolicyInterface,
PhabricatorCustomFieldInterface {
protected $name;
protected $buildPlanPHID;
protected $className;
protected $details = array();
@ -50,6 +51,14 @@ final class HarbormasterBuildStep extends HarbormasterDAO
return $this;
}
public function getName() {
if (strlen($this->name)) {
return $this->name;
}
return $this->getStepImplementation()->getName();
}
public function getStepImplementation() {
if ($this->implementation === null) {
$obj = HarbormasterBuildStepImplementation::requireImplementation(

View file

@ -4,6 +4,7 @@ final class HarbormasterBuildStepTransaction
extends PhabricatorApplicationTransaction {
const TYPE_CREATE = 'harbormaster:step:create';
const TYPE_NAME = 'harbormaster:step:name';
public function getApplicationName() {
return 'harbormaster';