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

Diffusion + Herald - warn users if importing repository

Summary: 'cuz things fail a bunch until importing is done. Fixes T4094.

Test Plan: set isImporting to return true. Browsed Diffusion and saw helpful warnings everywhere. Browse Herald transcript and saw a helpful warning

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4094

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

+92 -13
+45 -9
src/applications/diffusion/controller/DiffusionController.php
··· 4 4 5 5 protected $diffusionRequest; 6 6 7 + public function setDiffusionRequest(DiffusionRequest $request) { 8 + $this->diffusionRequest = $request; 9 + return $this; 10 + } 11 + 12 + protected function getDiffusionRequest() { 13 + if (!$this->diffusionRequest) { 14 + throw new Exception("No Diffusion request object!"); 15 + } 16 + return $this->diffusionRequest; 17 + } 18 + 7 19 public function willBeginExecution() { 8 20 $request = $this->getRequest(); 9 21 ··· 24 36 $drequest = DiffusionRequest::newFromAphrontRequestDictionary( 25 37 $data, 26 38 $this->getRequest()); 27 - $this->diffusionRequest = $drequest; 39 + $this->setDiffusionRequest($drequest); 28 40 } 29 41 } 30 42 31 - public function setDiffusionRequest(DiffusionRequest $request) { 32 - $this->diffusionRequest = $request; 33 - return $this; 34 - } 43 + public function buildApplicationPage($view, array $options) { 44 + $drequest = $this->getDiffusionRequest(); 45 + $repository = $drequest->getRepository(); 46 + $error_view = $this->buildRepositoryWarning($repository); 35 47 36 - protected function getDiffusionRequest() { 37 - if (!$this->diffusionRequest) { 38 - throw new Exception("No Diffusion request object!"); 48 + $views = array(); 49 + $not_inserted = true; 50 + foreach ($view as $view_object_or_array) { 51 + $views[] = $view_object_or_array; 52 + if ($not_inserted && 53 + $view_object_or_array instanceof PhabricatorCrumbsView) { 54 + $views[] = $error_view; 55 + $not_inserted = false; 56 + } 39 57 } 40 - return $this->diffusionRequest; 58 + return parent::buildApplicationPage($views, $options); 41 59 } 42 60 43 61 public function buildCrumbs(array $spec = array()) { ··· 235 253 ->appendChild($body); 236 254 } 237 255 256 + private function buildRepositoryWarning(PhabricatorRepository $repository) { 257 + $error_view = null; 258 + if ($repository->isImporting()) { 259 + $title = pht('This repository is still importing.'); 260 + $body = pht('Things may not work properly until the import finishes.'); 261 + } else if (!$repository->isTracked()) { 262 + $title = pht('This repository is not tracked.'); 263 + $body = pht( 264 + 'Things may not work properly until tracking is enabled and '. 265 + 'importing finishes.'); 266 + } 267 + 268 + if ($title) { 269 + $error_view = $this->renderStatusMessage($title, $body); 270 + } 271 + 272 + return $error_view; 273 + } 238 274 }
+47 -4
src/applications/herald/controller/HeraldTranscriptController.php
··· 83 83 $nav->appendChild($notice); 84 84 } 85 85 86 + $warning_panel = $this->buildWarningPanel($xscript); 87 + $nav->appendChild($warning_panel); 88 + 86 89 $apply_xscript_panel = $this->buildApplyTranscriptPanel( 87 90 $xscript); 88 91 $nav->appendChild($apply_xscript_panel); ··· 287 290 $keep_rule_xscripts)); 288 291 } 289 292 290 - private function buildApplyTranscriptPanel($xscript) { 293 + private function buildWarningPanel(HeraldTranscript $xscript) { 294 + $request = $this->getRequest(); 295 + $panel = null; 296 + if ($xscript->getObjectTranscript()) { 297 + $handles = $this->handles; 298 + $object_xscript = $xscript->getObjectTranscript(); 299 + $handle = $handles[$object_xscript->getPHID()]; 300 + if ($handle->getType() == 301 + PhabricatorRepositoryPHIDTypeCommit::TYPECONST) { 302 + $commit = id(new DiffusionCommitQuery()) 303 + ->setViewer($request->getUser()) 304 + ->withPHIDs(array($handle->getPHID())) 305 + ->executeOne(); 306 + if ($commit) { 307 + $repository = $commit->getRepository(); 308 + if ($repository->isImporting()) { 309 + $title = pht( 310 + 'The %s repository is still importing.', 311 + $repository->getMonogram()); 312 + $body = pht( 313 + 'Herald rules will not trigger until import completes.'); 314 + } else if (!$repository->isTracked()) { 315 + $title = pht( 316 + 'The %s repository is not tracked.', 317 + $repository->getMonogram()); 318 + $body = pht( 319 + 'Herald rules will not trigger until tracking is enabled.'); 320 + } else { 321 + return $panel; 322 + } 323 + $panel = id(new AphrontErrorView()) 324 + ->setSeverity(AphrontErrorView::SEVERITY_WARNING) 325 + ->setTitle($title) 326 + ->appendChild($body); 327 + } 328 + } 329 + } 330 + return $panel; 331 + } 332 + 333 + private function buildApplyTranscriptPanel(HeraldTranscript $xscript) { 291 334 $handles = $this->handles; 292 335 $adapter = $this->getAdapter(); 293 336 ··· 350 393 return $box; 351 394 } 352 395 353 - private function buildActionTranscriptPanel($xscript) { 396 + private function buildActionTranscriptPanel(HeraldTranscript $xscript) { 354 397 $action_xscript = mgroup($xscript->getApplyTranscripts(), 'getRuleID'); 355 398 356 399 $adapter = $this->getAdapter(); ··· 442 485 return $box; 443 486 } 444 487 445 - private function buildObjectTranscriptPanel($xscript) { 488 + private function buildObjectTranscriptPanel(HeraldTranscript $xscript) { 446 489 447 490 $adapter = $this->getAdapter(); 448 491 $field_names = $adapter->getFieldNameMap(); ··· 452 495 $data = array(); 453 496 if ($object_xscript) { 454 497 $phid = $object_xscript->getPHID(); 455 - $handles = $this->loadViewerHandles(array($phid)); 498 + $handles = $this->handles; 456 499 457 500 $data += array( 458 501 pht('Object Name') => $object_xscript->getName(),