diff --git a/resources/sql/autopatches/20140704.harbormasterstep.1.sql b/resources/sql/autopatches/20140704.harbormasterstep.1.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20140704.harbormasterstep.1.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildstep + ADD name VARCHAR(255) COLLATE utf8_bin; diff --git a/resources/sql/autopatches/20140704.harbormasterstep.2.sql b/resources/sql/autopatches/20140704.harbormasterstep.2.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20140704.harbormasterstep.2.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildtarget + ADD name VARCHAR(255) COLLATE utf8_bin; diff --git a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php --- a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php @@ -72,7 +72,7 @@ ->setHeader(pht( 'Build Target %d (%s)', $build_target->getID(), - $build_target->getImplementation()->getName())) + $build_target->getName())) ->setUser($viewer); $properties = new PHUIPropertyListView(); diff --git a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php --- a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php @@ -282,12 +282,7 @@ break; } - try { - $impl = $target->getImplementation(); - $name = $impl->getName(); - } catch (Exception $ex) { - $name = $target->getClassName(); - } + $name = $target->getName(); $target_list->addItem( id(new PHUIStatusItemView()) diff --git a/src/applications/harbormaster/controller/HarbormasterPlanViewController.php b/src/applications/harbormaster/controller/HarbormasterPlanViewController.php --- a/src/applications/harbormaster/controller/HarbormasterPlanViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterPlanViewController.php @@ -129,7 +129,7 @@ } $item = id(new PHUIObjectItemView()) ->setObjectName('Step '.$i++) - ->setHeader($implementation->getName()); + ->setHeader($step->getName()); $item->addAttribute($implementation->getDescription()); diff --git a/src/applications/harbormaster/controller/HarbormasterStepEditController.php b/src/applications/harbormaster/controller/HarbormasterStepEditController.php --- a/src/applications/harbormaster/controller/HarbormasterStepEditController.php +++ b/src/applications/harbormaster/controller/HarbormasterStepEditController.php @@ -64,9 +64,15 @@ ->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 @@ ->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 @@ } $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); diff --git a/src/applications/harbormaster/editor/HarbormasterBuildStepEditor.php b/src/applications/harbormaster/editor/HarbormasterBuildStepEditor.php --- a/src/applications/harbormaster/editor/HarbormasterBuildStepEditor.php +++ b/src/applications/harbormaster/editor/HarbormasterBuildStepEditor.php @@ -7,6 +7,7 @@ $types = parent::getTransactionTypes(); $types[] = HarbormasterBuildStepTransaction::TYPE_CREATE; + $types[] = HarbormasterBuildStepTransaction::TYPE_NAME; return $types; } @@ -18,6 +19,11 @@ 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 @@ 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 @@ 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 @@ switch ($xaction->getTransactionType()) { case HarbormasterBuildStepTransaction::TYPE_CREATE: + case HarbormasterBuildStepTransaction::TYPE_NAME: return; } diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php b/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php --- a/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php @@ -3,6 +3,7 @@ final class HarbormasterBuildTarget extends HarbormasterDAO implements PhabricatorPolicyInterface { + protected $name; protected $buildPHID; protected $buildStepPHID; protected $className; @@ -25,6 +26,7 @@ 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 @@ 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(), diff --git a/src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php b/src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php --- a/src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php +++ b/src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php @@ -5,6 +5,7 @@ PhabricatorPolicyInterface, PhabricatorCustomFieldInterface { + protected $name; protected $buildPlanPHID; protected $className; protected $details = array(); @@ -50,6 +51,14 @@ 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( diff --git a/src/applications/harbormaster/storage/configuration/HarbormasterBuildStepTransaction.php b/src/applications/harbormaster/storage/configuration/HarbormasterBuildStepTransaction.php --- a/src/applications/harbormaster/storage/configuration/HarbormasterBuildStepTransaction.php +++ b/src/applications/harbormaster/storage/configuration/HarbormasterBuildStepTransaction.php @@ -4,6 +4,7 @@ extends PhabricatorApplicationTransaction { const TYPE_CREATE = 'harbormaster:step:create'; + const TYPE_NAME = 'harbormaster:step:name'; public function getApplicationName() { return 'harbormaster';