@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 the new Build Plan behavior "Restartable" work

Summary:
Ref T13258. Implements the "Restartable" behavior, to control whether a build may be restarted or not.

This is fairly straightforward because there are already other existing reasons that a build may not be able to be restarted.

Test Plan: Restarted a build. Marked it as not restartable, saw "Restart" action become disabled. Tried to restart it anyway, got a useful error message.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13258

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

+29 -6
+7 -3
src/applications/harbormaster/controller/HarbormasterBuildActionController.php
··· 64 64 'restart. Side effects of the build will occur again. Really '. 65 65 'restart build?'); 66 66 $submit = pht('Restart Build'); 67 + } else if (!$build->getBuildPlan()->canRestartBuildPlan()) { 68 + $title = pht('Not Restartable'); 69 + $body = pht( 70 + 'The build plan for this build is not restartable, so you '. 71 + 'can not restart the build.'); 67 72 } else { 68 73 $title = pht('Unable to Restart Build'); 69 74 if ($build->isRestarting()) { ··· 135 140 break; 136 141 } 137 142 138 - $dialog = id(new AphrontDialogView()) 139 - ->setUser($viewer) 143 + $dialog = $this->newDialog() 140 144 ->setTitle($title) 141 145 ->appendChild($body) 142 146 ->addCancelButton($return_uri); ··· 145 149 $dialog->addSubmitButton($submit); 146 150 } 147 151 148 - return id(new AphrontDialogResponse())->setDialog($dialog); 152 + return $dialog; 149 153 } 150 154 151 155 }
+7 -3
src/applications/harbormaster/plan/HarbormasterBuildPlanBehavior.php
··· 13 13 const RUNNABLE_IF_VIEWABLE = 'view'; 14 14 const RUNNABLE_IF_EDITABLE = 'edit'; 15 15 16 + const BEHAVIOR_RESTARTABLE = 'restartable'; 17 + const RESTARTABLE_ALWAYS = 'always'; 18 + const RESTARTABLE_NEVER = 'never'; 19 + 16 20 public function setKey($key) { 17 21 $this->key = $key; 18 22 return $this; ··· 225 229 226 230 $restart_options = array( 227 231 id(new HarbormasterBuildPlanBehaviorOption()) 228 - ->setKey('always') 232 + ->setKey(self::RESTARTABLE_ALWAYS) 229 233 ->setIcon('fa-repeat green') 230 234 ->setName(pht('Always')) 231 235 ->setIsDefault(true) 232 236 ->setDescription( 233 237 pht('The build may be restarted.')), 234 238 id(new HarbormasterBuildPlanBehaviorOption()) 235 - ->setKey('never') 239 + ->setKey(self::RESTARTABLE_NEVER) 236 240 ->setIcon('fa-times red') 237 241 ->setName(pht('Never')) 238 242 ->setDescription( ··· 317 321 ->setName(pht('Affects Buildable')) 318 322 ->setOptions($aggregate_options), 319 323 id(new self()) 320 - ->setKey('restartable') 324 + ->setKey(self::BEHAVIOR_RESTARTABLE) 321 325 ->setEditInstructions( 322 326 pht( 323 327 'Usually, builds may be restarted. This may be useful if you '.
+5
src/applications/harbormaster/storage/build/HarbormasterBuild.php
··· 215 215 return false; 216 216 } 217 217 218 + $plan = $this->getBuildPlan(); 219 + if (!$plan->canRestartBuildPlan()) { 220 + return false; 221 + } 222 + 218 223 return !$this->isRestarting(); 219 224 } 220 225
+10
src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php
··· 175 175 $capability); 176 176 } 177 177 178 + public function canRestartBuildPlan() { 179 + $restartable = HarbormasterBuildPlanBehavior::BEHAVIOR_RESTARTABLE; 180 + $is_restartable = HarbormasterBuildPlanBehavior::RESTARTABLE_ALWAYS; 181 + 182 + $option = HarbormasterBuildPlanBehavior::getBehavior($restartable) 183 + ->getPlanOption($this); 184 + 185 + return ($option->getKey() === $is_restartable); 186 + } 187 + 178 188 179 189 /* -( PhabricatorSubscribableInterface )----------------------------------- */ 180 190