@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+72 -21
+2
resources/sql/autopatches/20140108.ddbpname.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_drydock.drydock_blueprint 2 + ADD blueprintName VARCHAR(255) NOT NULL AFTER className;
+23
resources/sql/autopatches/20140108.ddbpname.2.php
··· 1 + <?php 2 + 3 + echo "Adding names to Drydock blueprints.\n"; 4 + 5 + $table = new DrydockBlueprint(); 6 + $conn_w = $table->establishConnection('w'); 7 + $iterator = new LiskMigrationIterator($table); 8 + foreach ($iterator as $blueprint) { 9 + $id = $blueprint->getID(); 10 + 11 + echo "Populating blueprint {$id}...\n"; 12 + 13 + if (!strlen($blueprint->getBlueprintName())) { 14 + queryfx( 15 + $conn_w, 16 + 'UPDATE %T SET blueprintName = %s WHERE id = %d', 17 + $table->getTableName(), 18 + pht('Blueprint %s', $id), 19 + $id); 20 + } 21 + } 22 + 23 + echo "Done.\n";
+1 -1
src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
··· 8 8 } 9 9 10 10 public function getBlueprintName() { 11 - return pht('Remote Host (Preallocated)'); 11 + return pht('Preallocated Remote Hosts'); 12 12 } 13 13 14 14 public function getDescription() {
+29 -6
src/applications/drydock/controller/DrydockBlueprintEditController.php
··· 36 36 return new Aphront400Response(); 37 37 } 38 38 39 - $blueprint = new DrydockBlueprint(); 39 + $blueprint = DrydockBlueprint::initializeNewBlueprint($viewer); 40 40 $blueprint->setClassName($class); 41 41 $cancel_uri = $this->getApplicationURI('blueprint/'); 42 42 } 43 43 44 + $v_name = $blueprint->getBlueprintName(); 45 + $e_name = true; 46 + $errors = array(); 44 47 45 48 if ($request->isFormPost()) { 46 49 $v_view_policy = $request->getStr('viewPolicy'); 47 50 $v_edit_policy = $request->getStr('editPolicy'); 51 + $v_name = $request->getStr('name'); 52 + if (!strlen($v_name)) { 53 + $e_name = pht('Required'); 54 + $errors[] = pht('You must name this blueprint.'); 55 + } 48 56 49 - // TODO: Should we use transactions here? 57 + // TODO: We should use transactions here. 50 58 $blueprint->setViewPolicy($v_view_policy); 51 59 $blueprint->setEditPolicy($v_edit_policy); 60 + $blueprint->setBlueprintName($v_name); 52 61 53 - $blueprint->save(); 62 + if (!$errors) { 63 + $blueprint->save(); 64 + 65 + $id = $blueprint->getID(); 66 + $save_uri = $this->getApplicationURI("blueprint/{$id}/"); 54 67 55 - $id = $blueprint->getID(); 56 - $save_uri = $this->getApplicationURI("blueprint/{$id}/"); 68 + return id(new AphrontRedirectResponse())->setURI($save_uri); 69 + } 70 + } 57 71 58 - return id(new AphrontRedirectResponse())->setURI($save_uri); 72 + $error_view = null; 73 + if ($errors) { 74 + $error_view = id(new AphrontErrorView())->setErrors($errors); 59 75 } 60 76 61 77 $policies = id(new PhabricatorPolicyQuery()) ··· 66 82 $form = id(new AphrontFormView()) 67 83 ->setUser($viewer) 68 84 ->addHiddenInput('class', $request->getStr('class')) 85 + ->appendChild( 86 + id(new AphrontFormTextControl()) 87 + ->setLabel(pht('Name')) 88 + ->setName('name') 89 + ->setValue($v_name) 90 + ->setError($e_name)) 69 91 ->appendChild( 70 92 id(new AphrontFormStaticControl()) 71 93 ->setLabel(pht('Blueprint Type')) ··· 105 127 106 128 $box = id(new PHUIObjectBoxView()) 107 129 ->setHeaderText($header) 130 + ->setFormError($error_view) 108 131 ->setForm($form); 109 132 110 133 return $this->buildApplicationPage(
+4 -8
src/applications/drydock/controller/DrydockBlueprintListController.php
··· 33 33 34 34 foreach ($blueprints as $blueprint) { 35 35 $item = id(new PHUIObjectItemView()) 36 - ->setHeader($blueprint->getClassName()) 36 + ->setHeader($blueprint->getBlueprintName()) 37 37 ->setHref($this->getApplicationURI('/blueprint/'.$blueprint->getID())) 38 38 ->setObjectName(pht('Blueprint %d', $blueprint->getID())); 39 39 40 - if ($blueprint->getImplementation()->isEnabled()) { 41 - $item->addAttribute(pht('Enabled')); 42 - $item->setBarColor('green'); 43 - } else { 44 - $item->addAttribute(pht('Disabled')); 45 - $item->setBarColor('red'); 40 + if (!$blueprint->getImplementation()->isEnabled()) { 41 + $item->setDisabled(true); 46 42 } 47 43 48 - $item->addAttribute($blueprint->getImplementation()->getDescription()); 44 + $item->addAttribute($blueprint->getImplementation()->getBlueprintName()); 49 45 50 46 $view->addItem($item); 51 47 }
+6 -4
src/applications/drydock/controller/DrydockBlueprintViewController.php
··· 20 20 return new Aphront404Response(); 21 21 } 22 22 23 - $title = 'Blueprint '.$blueprint->getID().' '.$blueprint->getClassName(); 23 + $title = $blueprint->getBlueprintName(); 24 24 25 25 $header = id(new PHUIHeaderView()) 26 - ->setHeader($title); 26 + ->setHeader($title) 27 + ->setUser($viewer) 28 + ->setPolicyObject($blueprint); 27 29 28 30 $actions = $this->buildActionListView($blueprint); 29 31 $properties = $this->buildPropertyListView($blueprint, $actions); ··· 99 101 $view->setActionList($actions); 100 102 101 103 $view->addProperty( 102 - pht('Implementation'), 103 - $blueprint->getClassName()); 104 + pht('Type'), 105 + $blueprint->getImplementation()->getBlueprintName()); 104 106 105 107 return $view; 106 108 }
+7 -2
src/applications/drydock/storage/DrydockBlueprint.php
··· 3 3 final class DrydockBlueprint extends DrydockDAO 4 4 implements PhabricatorPolicyInterface { 5 5 6 - protected $phid; 7 6 protected $className; 7 + protected $blueprintName; 8 8 protected $viewPolicy; 9 9 protected $editPolicy; 10 - protected $details; 10 + protected $details = array(); 11 11 12 12 private $implementation = self::ATTACHABLE; 13 + 14 + public static function initializeNewBlueprint(PhabricatorUser $actor) { 15 + return id(new DrydockBlueprint()) 16 + ->setBlueprintName(''); 17 + } 13 18 14 19 public function getConfiguration() { 15 20 return array(