1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Fix create links when no repositories exist

Summary: Fixes T10925. Sends users to /new/ instead of /create/

Test Plan: Visit page, see links, clicky clicky.

Reviewers: epriestley, thoughtpolice

Reviewed By: thoughtpolice

Subscribers: thoughtpolice, Korvin

Maniphest Tasks: T10925

Differential Revision: https://secure.phabricator.com/D15849
This commit is contained in:
Chad Little 2016-05-04 21:06:56 -07:00
parent 95c284b95e
commit e422190eb5
4 changed files with 4 additions and 95 deletions

View file

@ -763,7 +763,6 @@ phutil_register_library_map(array(
'DiffusionRepositoryListController' => 'applications/diffusion/controller/DiffusionRepositoryListController.php', 'DiffusionRepositoryListController' => 'applications/diffusion/controller/DiffusionRepositoryListController.php',
'DiffusionRepositoryManageController' => 'applications/diffusion/controller/DiffusionRepositoryManageController.php', 'DiffusionRepositoryManageController' => 'applications/diffusion/controller/DiffusionRepositoryManageController.php',
'DiffusionRepositoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryManagementPanel.php', 'DiffusionRepositoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryManagementPanel.php',
'DiffusionRepositoryNewController' => 'applications/diffusion/controller/DiffusionRepositoryNewController.php',
'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php', 'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php',
'DiffusionRepositoryPoliciesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php', 'DiffusionRepositoryPoliciesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php',
'DiffusionRepositoryRef' => 'applications/diffusion/data/DiffusionRepositoryRef.php', 'DiffusionRepositoryRef' => 'applications/diffusion/data/DiffusionRepositoryRef.php',
@ -4979,7 +4978,6 @@ phutil_register_library_map(array(
'DiffusionRepositoryListController' => 'DiffusionController', 'DiffusionRepositoryListController' => 'DiffusionController',
'DiffusionRepositoryManageController' => 'DiffusionController', 'DiffusionRepositoryManageController' => 'DiffusionController',
'DiffusionRepositoryManagementPanel' => 'Phobject', 'DiffusionRepositoryManagementPanel' => 'Phobject',
'DiffusionRepositoryNewController' => 'DiffusionController',
'DiffusionRepositoryPath' => 'Phobject', 'DiffusionRepositoryPath' => 'Phobject',
'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositoryRef' => 'Phobject', 'DiffusionRepositoryRef' => 'Phobject',

View file

@ -59,9 +59,6 @@ final class PhabricatorDiffusionApplication extends PhabricatorApplication {
=> 'DiffusionRepositoryListController', => 'DiffusionRepositoryListController',
$this->getEditRoutePattern('edit/') => $this->getEditRoutePattern('edit/') =>
'DiffusionRepositoryEditproController', 'DiffusionRepositoryEditproController',
'new/' => 'DiffusionRepositoryNewController',
'(?P<edit>create)/' => 'DiffusionRepositoryCreateController',
'(?P<edit>import)/' => 'DiffusionRepositoryCreateController',
'pushlog/' => array( 'pushlog/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'DiffusionPushLogListController', '(?:query/(?P<queryKey>[^/]+)/)?' => 'DiffusionPushLogListController',
'view/(?P<id>\d+)/' => 'DiffusionPushEventViewController', 'view/(?P<id>\d+)/' => 'DiffusionPushEventViewController',

View file

@ -1,79 +0,0 @@
<?php
final class DiffusionRepositoryNewController extends DiffusionController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$this->requireApplicationCapability(
DiffusionCreateRepositoriesCapability::CAPABILITY);
if ($request->isFormPost()) {
if ($request->getStr('type')) {
switch ($request->getStr('type')) {
case 'create':
$uri = $this->getApplicationURI('create/');
break;
case 'import':
default:
$uri = $this->getApplicationURI('import/');
break;
}
return id(new AphrontRedirectResponse())->setURI($uri);
}
}
$doc_href = PhabricatorEnv::getDoclink(
'Diffusion User Guide: Repository Hosting');
$doc_link = phutil_tag(
'a',
array(
'href' => $doc_href,
'target' => '_blank',
),
pht('Diffusion User Guide: Repository Hosting'));
$form = id(new AphrontFormView())
->setUser($viewer)
->appendChild(
id(new AphrontFormRadioButtonControl())
->setName('type')
->addButton(
'create',
pht('Create a New Hosted Repository'),
array(
pht(
'Create a new, empty repository which Phabricator will host. '.
'For instructions on configuring repository hosting, see %s.',
$doc_link),
))
->addButton(
'import',
pht('Import an Existing External Repository'),
pht(
"Import a repository hosted somewhere else, like GitHub, ".
"Bitbucket, or your organization's existing servers. ".
"Phabricator will read changes from the repository but will ".
"not host or manage it. The authoritative master version of ".
"the repository will stay where it is now.")))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Continue'))
->addCancelButton($this->getApplicationURI()));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('New Repository'));
$form_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Create or Import Repository'))
->setForm($form);
return $this->newPage()
->setTitle(pht('New Repository'))
->setCrumbs($crumbs)
->appendChild($form_box);
}
}

View file

@ -242,16 +242,10 @@ final class PhabricatorRepositorySearchEngine
protected function getNewUserBody() { protected function getNewUserBody() {
$import_button = id(new PHUIButtonView()) $new_button = id(new PHUIButtonView())
->setTag('a') ->setTag('a')
->setText(pht('Import Repository')) ->setText(pht('New Repository'))
->setHref('/diffusion/import/') ->setHref('/diffusion/edit/')
->setColor(PHUIButtonView::GREEN);
$create_button = id(new PHUIButtonView())
->setTag('a')
->setText(pht('Create Repository'))
->setHref('/diffusion/create/')
->setColor(PHUIButtonView::GREEN); ->setColor(PHUIButtonView::GREEN);
$icon = $this->getApplication()->getIcon(); $icon = $this->getApplication()->getIcon();
@ -261,8 +255,7 @@ final class PhabricatorRepositorySearchEngine
->setTitle(pht('Welcome to %s', $app_name)) ->setTitle(pht('Welcome to %s', $app_name))
->setDescription( ->setDescription(
pht('Import, create, or just browse repositories in Diffusion.')) pht('Import, create, or just browse repositories in Diffusion.'))
->addAction($import_button) ->addAction($new_button);
->addAction($create_button);
return $view; return $view;
} }