mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 08:20:57 +01:00
Add names to Drydock blueprints
Summary: Ref T2015. Adds human-readable names to Drydock blueprints. Also the new patches stuff is so much nicer. Test Plan: Edited, created, and reviewed migrated blueprints. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2015 Differential Revision: https://secure.phabricator.com/D7918
This commit is contained in:
parent
68de639470
commit
962aca664f
7 changed files with 72 additions and 21 deletions
2
resources/sql/autopatches/20140108.ddbpname.1.sql
Normal file
2
resources/sql/autopatches/20140108.ddbpname.1.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_drydock.drydock_blueprint
|
||||
ADD blueprintName VARCHAR(255) NOT NULL AFTER className;
|
23
resources/sql/autopatches/20140108.ddbpname.2.php
Normal file
23
resources/sql/autopatches/20140108.ddbpname.2.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
echo "Adding names to Drydock blueprints.\n";
|
||||
|
||||
$table = new DrydockBlueprint();
|
||||
$conn_w = $table->establishConnection('w');
|
||||
$iterator = new LiskMigrationIterator($table);
|
||||
foreach ($iterator as $blueprint) {
|
||||
$id = $blueprint->getID();
|
||||
|
||||
echo "Populating blueprint {$id}...\n";
|
||||
|
||||
if (!strlen($blueprint->getBlueprintName())) {
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'UPDATE %T SET blueprintName = %s WHERE id = %d',
|
||||
$table->getTableName(),
|
||||
pht('Blueprint %s', $id),
|
||||
$id);
|
||||
}
|
||||
}
|
||||
|
||||
echo "Done.\n";
|
|
@ -8,7 +8,7 @@ final class DrydockPreallocatedHostBlueprintImplementation
|
|||
}
|
||||
|
||||
public function getBlueprintName() {
|
||||
return pht('Remote Host (Preallocated)');
|
||||
return pht('Preallocated Remote Hosts');
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
|
|
|
@ -36,26 +36,42 @@ final class DrydockBlueprintEditController extends DrydockBlueprintController {
|
|||
return new Aphront400Response();
|
||||
}
|
||||
|
||||
$blueprint = new DrydockBlueprint();
|
||||
$blueprint = DrydockBlueprint::initializeNewBlueprint($viewer);
|
||||
$blueprint->setClassName($class);
|
||||
$cancel_uri = $this->getApplicationURI('blueprint/');
|
||||
}
|
||||
|
||||
$v_name = $blueprint->getBlueprintName();
|
||||
$e_name = true;
|
||||
$errors = array();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$v_view_policy = $request->getStr('viewPolicy');
|
||||
$v_edit_policy = $request->getStr('editPolicy');
|
||||
$v_name = $request->getStr('name');
|
||||
if (!strlen($v_name)) {
|
||||
$e_name = pht('Required');
|
||||
$errors[] = pht('You must name this blueprint.');
|
||||
}
|
||||
|
||||
// TODO: Should we use transactions here?
|
||||
// TODO: We should use transactions here.
|
||||
$blueprint->setViewPolicy($v_view_policy);
|
||||
$blueprint->setEditPolicy($v_edit_policy);
|
||||
$blueprint->setBlueprintName($v_name);
|
||||
|
||||
$blueprint->save();
|
||||
if (!$errors) {
|
||||
$blueprint->save();
|
||||
|
||||
$id = $blueprint->getID();
|
||||
$save_uri = $this->getApplicationURI("blueprint/{$id}/");
|
||||
$id = $blueprint->getID();
|
||||
$save_uri = $this->getApplicationURI("blueprint/{$id}/");
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($save_uri);
|
||||
return id(new AphrontRedirectResponse())->setURI($save_uri);
|
||||
}
|
||||
}
|
||||
|
||||
$error_view = null;
|
||||
if ($errors) {
|
||||
$error_view = id(new AphrontErrorView())->setErrors($errors);
|
||||
}
|
||||
|
||||
$policies = id(new PhabricatorPolicyQuery())
|
||||
|
@ -66,6 +82,12 @@ final class DrydockBlueprintEditController extends DrydockBlueprintController {
|
|||
$form = id(new AphrontFormView())
|
||||
->setUser($viewer)
|
||||
->addHiddenInput('class', $request->getStr('class'))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel(pht('Name'))
|
||||
->setName('name')
|
||||
->setValue($v_name)
|
||||
->setError($e_name))
|
||||
->appendChild(
|
||||
id(new AphrontFormStaticControl())
|
||||
->setLabel(pht('Blueprint Type'))
|
||||
|
@ -105,6 +127,7 @@ final class DrydockBlueprintEditController extends DrydockBlueprintController {
|
|||
|
||||
$box = id(new PHUIObjectBoxView())
|
||||
->setHeaderText($header)
|
||||
->setFormError($error_view)
|
||||
->setForm($form);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
|
|
|
@ -33,19 +33,15 @@ final class DrydockBlueprintListController extends DrydockBlueprintController
|
|||
|
||||
foreach ($blueprints as $blueprint) {
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setHeader($blueprint->getClassName())
|
||||
->setHeader($blueprint->getBlueprintName())
|
||||
->setHref($this->getApplicationURI('/blueprint/'.$blueprint->getID()))
|
||||
->setObjectName(pht('Blueprint %d', $blueprint->getID()));
|
||||
|
||||
if ($blueprint->getImplementation()->isEnabled()) {
|
||||
$item->addAttribute(pht('Enabled'));
|
||||
$item->setBarColor('green');
|
||||
} else {
|
||||
$item->addAttribute(pht('Disabled'));
|
||||
$item->setBarColor('red');
|
||||
if (!$blueprint->getImplementation()->isEnabled()) {
|
||||
$item->setDisabled(true);
|
||||
}
|
||||
|
||||
$item->addAttribute($blueprint->getImplementation()->getDescription());
|
||||
$item->addAttribute($blueprint->getImplementation()->getBlueprintName());
|
||||
|
||||
$view->addItem($item);
|
||||
}
|
||||
|
|
|
@ -20,10 +20,12 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController {
|
|||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$title = 'Blueprint '.$blueprint->getID().' '.$blueprint->getClassName();
|
||||
$title = $blueprint->getBlueprintName();
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader($title);
|
||||
->setHeader($title)
|
||||
->setUser($viewer)
|
||||
->setPolicyObject($blueprint);
|
||||
|
||||
$actions = $this->buildActionListView($blueprint);
|
||||
$properties = $this->buildPropertyListView($blueprint, $actions);
|
||||
|
@ -99,8 +101,8 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController {
|
|||
$view->setActionList($actions);
|
||||
|
||||
$view->addProperty(
|
||||
pht('Implementation'),
|
||||
$blueprint->getClassName());
|
||||
pht('Type'),
|
||||
$blueprint->getImplementation()->getBlueprintName());
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
|
@ -3,14 +3,19 @@
|
|||
final class DrydockBlueprint extends DrydockDAO
|
||||
implements PhabricatorPolicyInterface {
|
||||
|
||||
protected $phid;
|
||||
protected $className;
|
||||
protected $blueprintName;
|
||||
protected $viewPolicy;
|
||||
protected $editPolicy;
|
||||
protected $details;
|
||||
protected $details = array();
|
||||
|
||||
private $implementation = self::ATTACHABLE;
|
||||
|
||||
public static function initializeNewBlueprint(PhabricatorUser $actor) {
|
||||
return id(new DrydockBlueprint())
|
||||
->setBlueprintName('');
|
||||
}
|
||||
|
||||
public function getConfiguration() {
|
||||
return array(
|
||||
self::CONFIG_AUX_PHID => true,
|
||||
|
|
Loading…
Reference in a new issue