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

Give users a modal VCS choice when creating a new repository

Summary:
Ref T10748. Allow the new EditEngine workflow to create repositories by giving the user a modal repository type choice upfront.

(The rest of this flow is still confusing/weird, though.)

Test Plan:
- Created a new repository.

{F1249626}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10748

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

+139 -24
+60 -3
src/applications/diffusion/controller/DiffusionRepositoryEditproController.php
··· 4 4 extends DiffusionRepositoryEditController { 5 5 6 6 public function handleRequest(AphrontRequest $request) { 7 - return id(new DiffusionRepositoryEditEngine()) 8 - ->setController($this) 9 - ->buildResponse(); 7 + $engine = id(new DiffusionRepositoryEditEngine()) 8 + ->setController($this); 9 + 10 + $id = $request->getURIData('id'); 11 + if (!$id) { 12 + $this->requireApplicationCapability( 13 + DiffusionCreateRepositoriesCapability::CAPABILITY); 14 + 15 + $vcs = $request->getStr('vcs'); 16 + $vcs_types = PhabricatorRepositoryType::getRepositoryTypeMap(); 17 + if (empty($vcs_types[$vcs])) { 18 + return $this->buildVCSTypeResponse(); 19 + } 20 + 21 + $engine 22 + ->addContextParameter('vcs', $vcs) 23 + ->setVersionControlSystem($vcs); 24 + } 25 + 26 + return $engine->buildResponse(); 27 + } 28 + 29 + private function buildVCSTypeResponse() { 30 + $vcs_types = PhabricatorRepositoryType::getRepositoryTypeMap(); 31 + 32 + $request = $this->getRequest(); 33 + $viewer = $this->getViewer(); 34 + 35 + $crumbs = $this->buildApplicationCrumbs(); 36 + $crumbs->addTextCrumb(pht('Create Repository')); 37 + $crumbs->setBorder(true); 38 + 39 + $title = pht('Choose Repository Type'); 40 + $header = id(new PHUIHeaderView()) 41 + ->setHeader(pht('Create Repository')) 42 + ->setHeaderIcon('fa-plus-square'); 43 + 44 + $layout = id(new AphrontMultiColumnView()) 45 + ->setFluidLayout(true); 46 + 47 + $create_uri = $request->getRequestURI(); 48 + 49 + foreach ($vcs_types as $vcs_key => $vcs_type) { 50 + $action = id(new PHUIActionPanelView()) 51 + ->setIcon(idx($vcs_type, 'icon')) 52 + ->setHeader(idx($vcs_type, 'create.header')) 53 + ->setHref($create_uri->alter('vcs', $vcs_key)) 54 + ->setSubheader(idx($vcs_type, 'create.subheader')); 55 + 56 + $layout->addColumn($action); 57 + } 58 + 59 + $view = id(new PHUITwoColumnView()) 60 + ->setHeader($header) 61 + ->setFooter($layout); 62 + 63 + return $this->newPage() 64 + ->setTitle($title) 65 + ->setCrumbs($crumbs) 66 + ->appendChild($view); 10 67 } 11 68 12 69 }
+19 -1
src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php
··· 5 5 6 6 const ENGINECONST = 'diffusion.repository'; 7 7 8 + private $versionControlSystem; 9 + 10 + public function setVersionControlSystem($version_control_system) { 11 + $this->versionControlSystem = $version_control_system; 12 + return $this; 13 + } 14 + 15 + public function getVersionControlSystem() { 16 + return $this->versionControlSystem; 17 + } 18 + 8 19 public function isEngineConfigurable() { 9 20 return false; 10 21 } ··· 27 38 28 39 protected function newEditableObject() { 29 40 $viewer = $this->getViewer(); 30 - return PhabricatorRepository::initializeNewRepository($viewer); 41 + $repository = PhabricatorRepository::initializeNewRepository($viewer); 42 + 43 + $vcs = $this->getVersionControlSystem(); 44 + if ($vcs) { 45 + $repository->setVersionControlSystem($vcs); 46 + } 47 + 48 + return $repository; 31 49 } 32 50 33 51 protected function newObjectQuery() {
+27 -11
src/applications/diffusion/management/DiffusionRepositoryStatusManagementPanel.php
··· 46 46 pht('Update Frequency'), 47 47 $this->buildRepositoryUpdateInterval($repository)); 48 48 49 + $messages = id(new PhabricatorRepositoryStatusMessage()) 50 + ->loadAllWhere('repositoryID = %d', $repository->getID()); 51 + $messages = mpull($messages, null, 'getStatusType'); 49 52 50 - list($status, $raw_error) = $this->buildRepositoryStatus($repository); 53 + $status = $this->buildRepositoryStatus($repository, $messages); 54 + $raw_error = $this->buildRepositoryRawError($repository, $messages); 51 55 52 56 $view->addProperty(pht('Status'), $status); 53 57 if ($raw_error) { ··· 80 84 } 81 85 82 86 private function buildRepositoryStatus( 83 - PhabricatorRepository $repository) { 87 + PhabricatorRepository $repository, 88 + array $messages) { 84 89 85 90 $viewer = $this->getViewer(); 86 91 $is_cluster = $repository->getAlmanacServicePHID(); 87 92 88 93 $view = new PHUIStatusListView(); 89 - 90 - $messages = id(new PhabricatorRepositoryStatusMessage()) 91 - ->loadAllWhere('repositoryID = %d', $repository->getID()); 92 - $messages = mpull($messages, null, 'getStatusType'); 93 94 94 95 if ($repository->isTracked()) { 95 96 $view->addItem( ··· 361 362 } 362 363 } 363 364 364 - $raw_error = null; 365 - 366 365 $message = idx($messages, PhabricatorRepositoryStatusMessage::TYPE_FETCH); 367 366 if ($message) { 368 367 switch ($message->getStatusCode()) { ··· 376 375 'keypair you have configured does not have permission to '. 377 376 'access the repository.'); 378 377 } 379 - 380 - $raw_error = $message; 381 378 382 379 $view->addItem( 383 380 id(new PHUIStatusItemView()) ··· 432 429 ->setNote(pht('This repository will be updated soon!'))); 433 430 } 434 431 432 + return $view; 433 + } 434 + 435 + private function buildRepositoryRawError( 436 + PhabricatorRepository $repository, 437 + array $messages) { 438 + $viewer = $this->getViewer(); 439 + 435 440 $can_edit = PhabricatorPolicyFilter::hasCapability( 436 441 $viewer, 437 442 $repository, 438 443 PhabricatorPolicyCapability::CAN_EDIT); 439 444 445 + $raw_error = null; 446 + 447 + $message = idx($messages, PhabricatorRepositoryStatusMessage::TYPE_FETCH); 448 + if ($message) { 449 + switch ($message->getStatusCode()) { 450 + case PhabricatorRepositoryStatusMessage::CODE_ERROR: 451 + $raw_error = $message->getParameter('message'); 452 + break; 453 + } 454 + } 455 + 440 456 if ($raw_error !== null) { 441 457 if (!$can_edit) { 442 458 $raw_message = pht( ··· 450 466 $raw_message = null; 451 467 } 452 468 453 - return array($view, $raw_message); 469 + return $raw_message; 454 470 } 455 471 456 472
+1 -1
src/applications/diffusion/management/DiffusionRepositoryURIsManagementPanel.php
··· 106 106 )); 107 107 108 108 $doc_href = PhabricatorEnv::getDoclink( 109 - 'Diffusion User Guide: Repository URIs'); 109 + 'Diffusion User Guide: URIs'); 110 110 111 111 $header = id(new PHUIHeaderView()) 112 112 ->setHeader(pht('Repository URIs'))
+32 -8
src/applications/repository/constants/PhabricatorRepositoryType.php
··· 7 7 const REPOSITORY_TYPE_MERCURIAL = 'hg'; 8 8 9 9 public static function getAllRepositoryTypes() { 10 - $map = array( 11 - self::REPOSITORY_TYPE_GIT => pht('Git'), 12 - self::REPOSITORY_TYPE_MERCURIAL => pht('Mercurial'), 13 - self::REPOSITORY_TYPE_SVN => pht('Subversion'), 14 - ); 15 - return $map; 10 + $map = self::getRepositoryTypeMap(); 11 + return ipull($map, 'name'); 16 12 } 17 13 18 14 public static function getNameForRepositoryType($type) { 19 - $map = self::getAllRepositoryTypes(); 20 - return idx($map, $type, pht('Unknown')); 15 + $spec = self::getRepositoryTypeSpec($type); 16 + return idx($spec, 'name', pht('Unknown ("%s")', $type)); 17 + } 18 + 19 + public static function getRepositoryTypeSpec($type) { 20 + $map = self::getRepositoryTypeMap(); 21 + return idx($map, $type, array()); 22 + } 23 + 24 + public static function getRepositoryTypeMap() { 25 + return array( 26 + self::REPOSITORY_TYPE_GIT => array( 27 + 'name' => pht('Git'), 28 + 'icon' => 'fa-git', 29 + 'create.header' => pht('Create Git Repository'), 30 + 'create.subheader' => pht('Create a new Git repository.'), 31 + ), 32 + self::REPOSITORY_TYPE_MERCURIAL => array( 33 + 'name' => pht('Mercurial'), 34 + 'icon' => 'fa-code-fork', 35 + 'create.header' => pht('Create Mercurial Repository'), 36 + 'create.subheader' => pht('Create a new Mercurial repository.'), 37 + ), 38 + self::REPOSITORY_TYPE_SVN => array( 39 + 'name' => pht('Subversion'), 40 + 'icon' => 'fa-database', 41 + 'create.header' => pht('Create Subversion Repository'), 42 + 'create.subheader' => pht('Create a new Subversion repository.'), 43 + ), 44 + ); 21 45 } 22 46 23 47 }