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

Move Clone Repository to Dialog

Summary: This moves the clone details on the Repository Home to a button / dialog. Functionally this is to pull content on the page way up, while giving full space to all the clone options. I think we can build this into some FancyJS if needed, but this seems to clean ui the UI dramatically with little overhead. I don't want to attempt the JS dropdown unless we're sure that's the best path (it exposes the most common URI by default, saving a click).

Test Plan: Tested hg, svn, git repositories and the raw URL page. Test close button.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

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

+152 -128
+2
src/__phutil_library_map__.php
··· 619 619 'DiffusionCachedResolveRefsQuery' => 'applications/diffusion/query/DiffusionCachedResolveRefsQuery.php', 620 620 'DiffusionChangeController' => 'applications/diffusion/controller/DiffusionChangeController.php', 621 621 'DiffusionChangeHeraldFieldGroup' => 'applications/diffusion/herald/DiffusionChangeHeraldFieldGroup.php', 622 + 'DiffusionCloneController' => 'applications/diffusion/controller/DiffusionCloneController.php', 622 623 'DiffusionCloneURIView' => 'applications/diffusion/view/DiffusionCloneURIView.php', 623 624 'DiffusionCommandEngine' => 'applications/diffusion/protocol/DiffusionCommandEngine.php', 624 625 'DiffusionCommandEngineTestCase' => 'applications/diffusion/protocol/__tests__/DiffusionCommandEngineTestCase.php', ··· 5610 5611 'DiffusionCachedResolveRefsQuery' => 'DiffusionLowLevelQuery', 5611 5612 'DiffusionChangeController' => 'DiffusionController', 5612 5613 'DiffusionChangeHeraldFieldGroup' => 'HeraldFieldGroup', 5614 + 'DiffusionCloneController' => 'DiffusionController', 5613 5615 'DiffusionCloneURIView' => 'AphrontView', 5614 5616 'DiffusionCommandEngine' => 'Phobject', 5615 5617 'DiffusionCommandEngineTestCase' => 'PhabricatorTestCase',
+1
src/applications/diffusion/application/PhabricatorDiffusionApplication.php
··· 55 55 '' => 'DiffusionRepositoryController', 56 56 'repository/(?P<dblob>.*)' => 'DiffusionRepositoryController', 57 57 'change/(?P<dblob>.*)' => 'DiffusionChangeController', 58 + 'clone/' => 'DiffusionCloneController', 58 59 'history/(?P<dblob>.*)' => 'DiffusionHistoryController', 59 60 'graph/(?P<dblob>.*)' => 'DiffusionGraphController', 60 61 'browse/(?P<dblob>.*)' => 'DiffusionBrowseController',
+122
src/applications/diffusion/controller/DiffusionCloneController.php
··· 1 + <?php 2 + 3 + final class DiffusionCloneController extends DiffusionController { 4 + 5 + public function shouldAllowPublic() { 6 + return true; 7 + } 8 + 9 + public function handleRequest(AphrontRequest $request) { 10 + $viewer = $request->getViewer(); 11 + $response = $this->loadDiffusionContext(); 12 + if ($response) { 13 + return $response; 14 + } 15 + 16 + $drequest = $this->getDiffusionRequest(); 17 + $repository = $drequest->getRepository(); 18 + 19 + $view = id(new PHUIPropertyListView()) 20 + ->setUser($viewer); 21 + 22 + $display_never = PhabricatorRepositoryURI::DISPLAY_NEVER; 23 + $warning = null; 24 + 25 + $uris = $repository->getURIs(); 26 + foreach ($uris as $uri) { 27 + if ($uri->getIsDisabled()) { 28 + continue; 29 + } 30 + 31 + if ($uri->getEffectiveDisplayType() == $display_never) { 32 + continue; 33 + } 34 + 35 + if ($repository->isSVN()) { 36 + $label = phutil_tag_div('diffusion-clone-label', pht('Checkout')); 37 + } else { 38 + $label = phutil_tag_div('diffusion-clone-label', pht('Clone')); 39 + } 40 + 41 + $view->addProperty( 42 + $label, 43 + $this->renderCloneURI($repository, $uri)); 44 + } 45 + 46 + if (!$view->hasAnyProperties()) { 47 + $view = id(new PHUIInfoView()) 48 + ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) 49 + ->appendChild(pht('Repository has no URIs set.')); 50 + } 51 + 52 + $info = null; 53 + 54 + // Try to load alternatives. This may fail for repositories which have not 55 + // cloned yet. If it does, just ignore it and continue. 56 + try { 57 + $alternatives = $drequest->getRefAlternatives(); 58 + } catch (ConduitClientException $ex) { 59 + $alternatives = array(); 60 + } 61 + 62 + if ($alternatives) { 63 + $message = array( 64 + pht( 65 + 'The ref "%s" is ambiguous in this repository.', 66 + $drequest->getBranch()), 67 + ' ', 68 + phutil_tag( 69 + 'a', 70 + array( 71 + 'href' => $drequest->generateURI( 72 + array( 73 + 'action' => 'refs', 74 + )), 75 + ), 76 + pht('View Alternatives')), 77 + ); 78 + 79 + $messages = array($message); 80 + 81 + $warning = id(new PHUIInfoView()) 82 + ->setSeverity(PHUIInfoView::SEVERITY_WARNING) 83 + ->setErrors(array($message)); 84 + } 85 + 86 + $cancel_uri = $drequest->generateURI( 87 + array( 88 + 'action' => 'branch', 89 + 'path' => '/', 90 + )); 91 + 92 + return $this->newDialog() 93 + ->setTitle(pht('Clone Repository')) 94 + ->setWidth(AphrontDialogView::WIDTH_FORM) 95 + ->addCancelButton($cancel_uri, pht('Close')) 96 + ->appendChild(array($view, $warning)); 97 + } 98 + 99 + private function renderCloneURI( 100 + PhabricatorRepository $repository, 101 + PhabricatorRepositoryURI $uri) { 102 + 103 + if ($repository->isSVN()) { 104 + $display = csprintf( 105 + 'svn checkout %R %R', 106 + (string)$uri->getDisplayURI(), 107 + $repository->getCloneName()); 108 + } else { 109 + $display = csprintf('%R', (string)$uri->getDisplayURI()); 110 + } 111 + 112 + $display = (string)$display; 113 + $viewer = $this->getViewer(); 114 + 115 + return id(new DiffusionCloneURIView()) 116 + ->setViewer($viewer) 117 + ->setRepository($repository) 118 + ->setRepositoryURI($uri) 119 + ->setDisplayURI($display); 120 + } 121 + 122 + }
+23 -128
src/applications/diffusion/controller/DiffusionRepositoryController.php
··· 27 27 $crumbs->setBorder(true); 28 28 29 29 $header = $this->buildHeaderView($repository); 30 - $property_table = $this->buildPropertiesTable($repository); 31 30 $actions = $this->buildActionList($repository); 32 31 $description = $this->buildDescriptionView($repository); 33 32 $locate_file = $this->buildLocateFile(); ··· 90 89 91 90 $tabs = $this->buildTabsView('home'); 92 91 92 + $clone_uri = $drequest->generateURI( 93 + array( 94 + 'action' => 'clone', 95 + )); 96 + 97 + $clone_button = id(new PHUIButtonView()) 98 + ->setTag('a') 99 + ->setText('Clone') 100 + ->setColor(PHUIButtonView::GREEN) 101 + ->setIcon('fa-download') 102 + ->setWorkflow(true) 103 + ->setHref($clone_uri); 104 + 105 + $bar = id(new PHUILeftRightView()) 106 + ->setLeft($locate_file) 107 + ->setRight($clone_button); 108 + 93 109 $view = id(new PHUITwoColumnView()) 94 110 ->setHeader($header) 95 111 ->setTabs($tabs) 96 112 ->setFooter(array( 97 - $locate_file, 98 - $property_table, 113 + $bar, 99 114 $description, 100 115 $content, 101 116 )); ··· 302 317 return null; 303 318 } 304 319 305 - private function buildPropertiesTable(PhabricatorRepository $repository) { 306 - $viewer = $this->getViewer(); 307 - 308 - $view = id(new PHUIPropertyListView()) 309 - ->setUser($viewer); 310 - 311 - $display_never = PhabricatorRepositoryURI::DISPLAY_NEVER; 312 - 313 - $uris = $repository->getURIs(); 314 - foreach ($uris as $uri) { 315 - if ($uri->getIsDisabled()) { 316 - continue; 317 - } 318 - 319 - if ($uri->getEffectiveDisplayType() == $display_never) { 320 - continue; 321 - } 322 - 323 - if ($repository->isSVN()) { 324 - $label = phutil_tag_div('diffusion-clone-label', pht('Checkout')); 325 - } else { 326 - $label = phutil_tag_div('diffusion-clone-label', pht('Clone')); 327 - } 328 - 329 - $view->addProperty( 330 - $label, 331 - $this->renderCloneURI($repository, $uri)); 332 - } 333 - 334 - if (!$view->hasAnyProperties()) { 335 - $view = id(new PHUIInfoView()) 336 - ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) 337 - ->appendChild(pht('Repository has no URIs set.')); 338 - } 339 - 340 - $box = id(new PHUIObjectBoxView()) 341 - ->setHeaderText(pht('Details')) 342 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 343 - ->appendChild($view); 344 - 345 - $info = null; 346 - $drequest = $this->getDiffusionRequest(); 347 - 348 - // Try to load alternatives. This may fail for repositories which have not 349 - // cloned yet. If it does, just ignore it and continue. 350 - try { 351 - $alternatives = $drequest->getRefAlternatives(); 352 - } catch (ConduitClientException $ex) { 353 - $alternatives = array(); 354 - } 355 - 356 - if ($alternatives) { 357 - $message = array( 358 - pht( 359 - 'The ref "%s" is ambiguous in this repository.', 360 - $drequest->getBranch()), 361 - ' ', 362 - phutil_tag( 363 - 'a', 364 - array( 365 - 'href' => $drequest->generateURI( 366 - array( 367 - 'action' => 'refs', 368 - )), 369 - ), 370 - pht('View Alternatives')), 371 - ); 372 - 373 - $messages = array($message); 374 - 375 - $info = id(new PHUIInfoView()) 376 - ->setSeverity(PHUIInfoView::SEVERITY_WARNING) 377 - ->setErrors(array($message)); 378 - 379 - $box->setInfoView($info); 380 - } 381 - 382 - 383 - return $box; 384 - } 385 - 386 320 private function buildHistoryTable( 387 321 $history_results, 388 322 $history, ··· 504 438 } 505 439 506 440 $browse_uri = $drequest->generateURI(array('action' => 'browse')); 507 - 508 - $browse_panel = id(new PHUIObjectBoxView()) 509 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY); 510 - $header = id(new PHUIHeaderView()) 511 - ->setHeader($repository->getName()); 512 - 513 - $button = id(new PHUIButtonView()) 514 - ->setText(pht('Browse')) 515 - ->setTag('a') 516 - ->setIcon('fa-code') 517 - ->setHref($browse_uri); 518 - 519 - $header->addActionLink($button); 520 - $browse_panel->setHeader($header); 521 - $browse_panel->setTable($browse_table); 522 - 523 441 $pager->setURI($browse_uri, 'offset'); 524 442 525 - if ($pager->willShowPagingControls()) { 526 - $browse_panel->setPager($pager); 527 - } 528 - 529 - return $browse_panel; 530 - } 531 - 532 - private function renderCloneURI( 533 - PhabricatorRepository $repository, 534 - PhabricatorRepositoryURI $uri) { 535 - 536 - if ($repository->isSVN()) { 537 - $display = csprintf( 538 - 'svn checkout %R %R', 539 - (string)$uri->getDisplayURI(), 540 - $repository->getCloneName()); 541 - } else { 542 - $display = csprintf('%R', (string)$uri->getDisplayURI()); 543 - } 544 - 545 - $display = (string)$display; 546 - $viewer = $this->getViewer(); 547 - 548 - return id(new DiffusionCloneURIView()) 549 - ->setViewer($viewer) 550 - ->setRepository($repository) 551 - ->setRepositoryURI($uri) 552 - ->setDisplayURI($display); 443 + return id(new PHUIObjectBoxView()) 444 + ->setHeaderText($repository->getName()) 445 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 446 + ->setTable($browse_table) 447 + ->setPager($pager); 553 448 } 554 449 555 450 private function getTagLimit() {
+4
src/applications/repository/storage/PhabricatorRepository.php
··· 700 700 switch ($action) { 701 701 case 'history': 702 702 case 'graph': 703 + case 'clone': 703 704 case 'browse': 704 705 case 'change': 705 706 case 'lastmodified': ··· 818 819 // it came from a URI. 819 820 $uri = rawurldecode("{$path}{$commit}"); 820 821 break; 822 + case 'clone': 823 + $uri = $this->getPathURI("/{$action}/"); 824 + break; 821 825 } 822 826 823 827 if ($action == 'rendering-ref') {