@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.

Make Drydock blueprint create workflow somewhat more standard

Summary: Ref T2015. This workflow is a little weird (runs in a dialog, no edit-before-create step, lots of internal classnames). Make it a little more standard.

Test Plan: See screenshots.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2015

Differential Revision: https://secure.phabricator.com/D7908

+126 -79
+1 -1
src/applications/drydock/application/PhabricatorApplicationDrydock.php
··· 38 38 '(?:query/(?P<queryKey>[^/]+)/)?' => 'DrydockBlueprintListController', 39 39 '(?P<id>[1-9]\d*)/' => 'DrydockBlueprintViewController', 40 40 'create/' => 'DrydockBlueprintCreateController', 41 - 'edit/(?P<id>[1-9]\d*)/' => 'DrydockBlueprintEditController', 41 + 'edit/(?:(?P<id>[1-9]\d*)/)?' => 'DrydockBlueprintEditController', 42 42 ), 43 43 'resource/' => array( 44 44 '(?:query/(?P<queryKey>[^/]+)/)?' => 'DrydockResourceListController',
+5
src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
··· 19 19 20 20 abstract public function isEnabled(); 21 21 22 + abstract public function getBlueprintName(); 22 23 abstract public function getDescription(); 23 24 24 25 public function getBlueprintClass() { ··· 386 387 $groups = mgroup(self::getAllBlueprintImplementations(), 'getType'); 387 388 } 388 389 return idx($groups, $type, array()); 390 + } 391 + 392 + public static function getNamedImplementation($class) { 393 + return idx(self::getAllBlueprintImplementations(), $class); 389 394 } 390 395 391 396 protected function newResourceTemplate($name) {
+6 -1
src/applications/drydock/blueprint/DrydockLocalHostBlueprintImplementation.php
··· 7 7 return false; 8 8 } 9 9 10 + public function getBlueprintName() { 11 + return pht('Local Host'); 12 + } 13 + 10 14 public function getDescription() { 11 - return pht('Allocates storage on the local host.'); 15 + return pht( 16 + 'Allows Drydock to run on the local host.'); 12 17 } 13 18 14 19 public function canAllocateMoreResources(array $pool) {
+5 -1
src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
··· 7 7 return true; 8 8 } 9 9 10 + public function getBlueprintName() { 11 + return pht('Remote Host (Preallocated)'); 12 + } 13 + 10 14 public function getDescription() { 11 - return pht('Leases out preallocated, remote hosts.'); 15 + return pht('Allows Drydock to run on specific remote hosts you configure.'); 12 16 } 13 17 14 18 public function canAllocateMoreResources(array $pool) {
+5 -1
src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php
··· 7 7 return true; 8 8 } 9 9 10 + public function getBlueprintName() { 11 + return pht('Working Copy'); 12 + } 13 + 10 14 public function getDescription() { 11 - return pht('Allocates out working copies of repositories.'); 15 + return pht('Allows Drydock to check out working copies of repositories.'); 12 16 } 13 17 14 18 protected function canAllocateLease(
+56 -37
src/applications/drydock/controller/DrydockBlueprintCreateController.php
··· 10 10 $implementations = 11 11 DrydockBlueprintImplementation::getAllBlueprintImplementations(); 12 12 13 + $errors = array(); 14 + $e_blueprint = null; 15 + 13 16 if ($request->isFormPost()) { 14 17 $class = $request->getStr('blueprint-type'); 15 18 if (!isset($implementations[$class])) { 16 - return $this->createDialog($implementations); 19 + $e_blueprint = pht('Required'); 20 + $errors[] = pht('You must choose a blueprint type.'); 17 21 } 18 22 19 - $blueprint = id(new DrydockBlueprint()) 20 - ->setClassName($class) 21 - ->setDetails(array()) 22 - ->setViewPolicy(PhabricatorPolicies::POLICY_ADMIN) 23 - ->setEditPolicy(PhabricatorPolicies::POLICY_ADMIN) 24 - ->save(); 25 - 26 - $edit_uri = $this->getApplicationURI( 27 - "blueprint/edit/".$blueprint->getID()."/"); 23 + if (!$errors) { 24 + $edit_uri = $this->getApplicationURI('blueprint/edit/?class='.$class); 25 + return id(new AphrontRedirectResponse())->setURI($edit_uri); 26 + } 27 + } 28 28 29 - return id(new AphrontRedirectResponse())->setURI($edit_uri); 29 + $error_view = null; 30 + if ($errors) { 31 + $error_view = id(new AphrontErrorView()) 32 + ->setErrors($errors); 30 33 } 31 34 32 - return $this->createDialog($implementations); 33 - } 34 - 35 - function createDialog(array $implementations) { 36 - $request = $this->getRequest(); 37 - $viewer = $request->getUser(); 38 - 39 35 $control = id(new AphrontFormRadioButtonControl()) 40 - ->setName('blueprint-type'); 36 + ->setName('blueprint-type') 37 + ->setLabel(pht('Blueprint Type')) 38 + ->setError($e_blueprint); 41 39 42 40 foreach ($implementations as $implementation_name => $implementation) { 43 - $control 44 - ->addButton( 45 - $implementation_name, 46 - $implementation->getBlueprintClass(), 47 - $implementation->getDescription()); 41 + $disabled = !$implementation->isEnabled(); 42 + 43 + $control->addButton( 44 + $implementation_name, 45 + $implementation->getBlueprintName(), 46 + array( 47 + pht('Provides: %s', $implementation->getType()), 48 + phutil_tag('br'), 49 + phutil_tag('br'), 50 + $implementation->getDescription(), 51 + ), 52 + $disabled ? 'disabled' : null, 53 + $disabled); 48 54 } 49 55 50 - $dialog = new AphrontDialogView(); 51 - $dialog->setTitle(pht('Create New Blueprint')) 52 - ->setUser($viewer) 53 - ->addSubmitButton(pht('Create Blueprint')) 54 - ->addCancelButton($this->getApplicationURI('blueprint/')); 55 - $dialog->appendChild( 56 - phutil_tag( 57 - 'p', 58 - array(), 59 - pht( 60 - 'Select what type of blueprint you want to create: '))); 61 - $dialog->appendChild($control); 62 - return id(new AphrontDialogResponse())->setDialog($dialog); 56 + $title = pht('Create New Blueprint'); 57 + $crumbs = $this->buildApplicationCrumbs(); 58 + $crumbs->addTextCrumb(pht('New Blueprint')); 59 + 60 + $form = id(new AphrontFormView()) 61 + ->setUser($viewer) 62 + ->appendChild($control) 63 + ->appendChild( 64 + id(new AphrontFormSubmitControl()) 65 + ->addCancelButton($this->getApplicationURI('blueprint/')) 66 + ->setValue(pht('Continue'))); 67 + 68 + $box = id(new PHUIObjectBoxView()) 69 + ->setFormError($error_view) 70 + ->setHeaderText($title) 71 + ->setForm($form); 72 + 73 + return $this->buildApplicationPage( 74 + array( 75 + $crumbs, 76 + $box, 77 + ), 78 + array( 79 + 'title' => $title, 80 + 'device' => true, 81 + )); 63 82 } 64 83 65 84 }
+36 -33
src/applications/drydock/controller/DrydockBlueprintEditController.php
··· 25 25 if (!$blueprint) { 26 26 return new Aphront404Response(); 27 27 } 28 + 29 + $impl = $blueprint->getImplementation(); 30 + $cancel_uri = $this->getApplicationURI('blueprint/'.$this->id.'/'); 28 31 } else { 32 + $class = $request->getStr('class'); 33 + 34 + $impl = DrydockBlueprintImplementation::getNamedImplementation($class); 35 + if (!$impl || !$impl->isEnabled()) { 36 + return new Aphront400Response(); 37 + } 38 + 29 39 $blueprint = new DrydockBlueprint(); 40 + $blueprint->setClassName($class); 41 + $cancel_uri = $this->getApplicationURI('blueprint/'); 30 42 } 43 + 31 44 32 45 if ($request->isFormPost()) { 33 46 $v_view_policy = $request->getStr('viewPolicy'); ··· 39 52 40 53 $blueprint->save(); 41 54 42 - return id(new AphrontRedirectResponse()) 43 - ->setURI('/drydock/blueprint/'); 55 + $id = $blueprint->getID(); 56 + $save_uri = $this->getApplicationURI("blueprint/{$id}/"); 57 + 58 + return id(new AphrontRedirectResponse())->setURI($save_uri); 44 59 } 45 60 46 61 $policies = id(new PhabricatorPolicyQuery()) ··· 48 63 ->setObject($blueprint) 49 64 ->execute(); 50 65 51 - if ($request->isAjax()) { 52 - $form = id(new PHUIFormLayoutView()) 53 - ->setUser($viewer); 54 - } else { 55 - $form = id(new AphrontFormView()) 56 - ->setUser($viewer); 57 - } 58 - 59 - $form 66 + $form = id(new AphrontFormView()) 67 + ->setUser($viewer) 68 + ->addHiddenInput('class', $request->getStr('class')) 60 69 ->appendChild( 61 - id(new AphrontFormTextControl()) 62 - ->setName('className') 63 - ->setLabel(pht('Implementation')) 64 - ->setValue($blueprint->getClassName()) 65 - ->setDisabled(true)) 70 + id(new AphrontFormStaticControl()) 71 + ->setLabel(pht('Blueprint Type')) 72 + ->setValue($impl->getBlueprintName())) 66 73 ->appendChild( 67 74 id(new AphrontFormPolicyControl()) 68 75 ->setName('viewPolicy') ··· 78 85 79 86 $crumbs = $this->buildApplicationCrumbs(); 80 87 81 - $title = pht('Edit Blueprint'); 82 - $header = pht('Edit Blueprint %d', $blueprint->getID()); 83 - $crumbs->addTextCrumb(pht('Blueprint %d', $blueprint->getID())); 84 - $crumbs->addTextCrumb(pht('Edit')); 85 - 86 - if ($request->isAjax()) { 87 - $dialog = id(new AphrontDialogView()) 88 - ->setUser($viewer) 89 - ->setWidth(AphrontDialogView::WIDTH_FORM) 90 - ->setTitle($title) 91 - ->appendChild($form) 92 - ->addSubmitButton(pht('Edit Blueprint')) 93 - ->addCancelButton($this->getApplicationURI()); 94 - 95 - return id(new AphrontDialogResponse())->setDialog($dialog); 88 + if ($blueprint->getID()) { 89 + $title = pht('Edit Blueprint'); 90 + $header = pht('Edit Blueprint %d', $blueprint->getID()); 91 + $crumbs->addTextCrumb(pht('Blueprint %d', $blueprint->getID())); 92 + $crumbs->addTextCrumb(pht('Edit')); 93 + $submit = pht('Save Blueprint'); 94 + } else { 95 + $title = pht('New Blueprint'); 96 + $header = pht('New Blueprint'); 97 + $crumbs->addTextCrumb(pht('New Blueprint')); 98 + $submit = pht('Create Blueprint'); 96 99 } 97 100 98 101 $form->appendChild( 99 102 id(new AphrontFormSubmitControl()) 100 - ->setValue(pht('Save')) 101 - ->addCancelButton($this->getApplicationURI())); 103 + ->setValue($submit) 104 + ->addCancelButton($cancel_uri)); 102 105 103 106 $box = id(new PHUIObjectBoxView()) 104 107 ->setHeaderText($header)
+11 -4
src/applications/drydock/controller/DrydockBlueprintViewController.php
··· 65 65 } 66 66 67 67 private function buildActionListView(DrydockBlueprint $blueprint) { 68 + $viewer = $this->getRequest()->getUser(); 69 + 68 70 $view = id(new PhabricatorActionListView()) 69 - ->setUser($this->getRequest()->getUser()) 71 + ->setUser($viewer) 70 72 ->setObjectURI($this->getRequest()->getRequestURI()) 71 73 ->setObject($blueprint); 72 74 73 75 $uri = '/blueprint/edit/'.$blueprint->getID().'/'; 74 76 $uri = $this->getApplicationURI($uri); 75 77 78 + $can_edit = PhabricatorPolicyFilter::hasCapability( 79 + $viewer, 80 + $blueprint, 81 + PhabricatorPolicyCapability::CAN_EDIT); 82 + 76 83 $view->addAction( 77 84 id(new PhabricatorActionView()) 78 85 ->setHref($uri) 79 - ->setName(pht('Edit Blueprint Policies')) 86 + ->setName(pht('Edit Blueprint')) 80 87 ->setIcon('edit') 81 - ->setWorkflow(true) 82 - ->setDisabled(false)); 88 + ->setWorkflow(!$can_edit) 89 + ->setDisabled(!$can_edit)); 83 90 84 91 return $view; 85 92 }
+1 -1
src/applications/harbormaster/controller/HarbormasterStepAddController.php
··· 33 33 if ($request->isDialogFormPost()) { 34 34 $class = $request->getStr('step-type'); 35 35 if (!in_array($class, $implementations)) { 36 - return $this->createDialog($implementations); 36 + return $this->createDialog($implementations, $cancel_uri); 37 37 } 38 38 39 39 $steps = $plan->loadOrderedBuildSteps();