Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15410883
D7918.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D7918.diff
View Options
Index: resources/sql/autopatches/20140108.ddbpname.1.sql
===================================================================
--- /dev/null
+++ resources/sql/autopatches/20140108.ddbpname.1.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_drydock.drydock_blueprint
+ ADD blueprintName VARCHAR(255) NOT NULL AFTER className;
Index: resources/sql/autopatches/20140108.ddbpname.2.php
===================================================================
--- /dev/null
+++ resources/sql/autopatches/20140108.ddbpname.2.php
@@ -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";
Index: src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
===================================================================
--- src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
+++ src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
@@ -8,7 +8,7 @@
}
public function getBlueprintName() {
- return pht('Remote Host (Preallocated)');
+ return pht('Preallocated Remote Hosts');
}
public function getDescription() {
Index: src/applications/drydock/controller/DrydockBlueprintEditController.php
===================================================================
--- src/applications/drydock/controller/DrydockBlueprintEditController.php
+++ src/applications/drydock/controller/DrydockBlueprintEditController.php
@@ -36,26 +36,42 @@
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())
@@ -67,6 +83,12 @@
->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'))
->setValue($impl->getBlueprintName()))
@@ -105,6 +127,7 @@
$box = id(new PHUIObjectBoxView())
->setHeaderText($header)
+ ->setFormError($error_view)
->setForm($form);
return $this->buildApplicationPage(
Index: src/applications/drydock/controller/DrydockBlueprintListController.php
===================================================================
--- src/applications/drydock/controller/DrydockBlueprintListController.php
+++ src/applications/drydock/controller/DrydockBlueprintListController.php
@@ -33,19 +33,15 @@
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);
}
Index: src/applications/drydock/controller/DrydockBlueprintViewController.php
===================================================================
--- src/applications/drydock/controller/DrydockBlueprintViewController.php
+++ src/applications/drydock/controller/DrydockBlueprintViewController.php
@@ -20,10 +20,12 @@
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 @@
$view->setActionList($actions);
$view->addProperty(
- pht('Implementation'),
- $blueprint->getClassName());
+ pht('Type'),
+ $blueprint->getImplementation()->getBlueprintName());
return $view;
}
Index: src/applications/drydock/storage/DrydockBlueprint.php
===================================================================
--- src/applications/drydock/storage/DrydockBlueprint.php
+++ src/applications/drydock/storage/DrydockBlueprint.php
@@ -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,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 20, 8:38 AM (3 d, 23 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7712835
Default Alt Text
D7918.diff (7 KB)
Attached To
Mode
D7918: Add names to Drydock blueprints
Attached
Detach File
Event Timeline
Log In to Comment