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
This commit is contained in:
@@ -4,9 +4,66 @@ final class DiffusionRepositoryEditproController
|
||||
extends DiffusionRepositoryEditController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
return id(new DiffusionRepositoryEditEngine())
|
||||
->setController($this)
|
||||
->buildResponse();
|
||||
$engine = id(new DiffusionRepositoryEditEngine())
|
||||
->setController($this);
|
||||
|
||||
$id = $request->getURIData('id');
|
||||
if (!$id) {
|
||||
$this->requireApplicationCapability(
|
||||
DiffusionCreateRepositoriesCapability::CAPABILITY);
|
||||
|
||||
$vcs = $request->getStr('vcs');
|
||||
$vcs_types = PhabricatorRepositoryType::getRepositoryTypeMap();
|
||||
if (empty($vcs_types[$vcs])) {
|
||||
return $this->buildVCSTypeResponse();
|
||||
}
|
||||
|
||||
$engine
|
||||
->addContextParameter('vcs', $vcs)
|
||||
->setVersionControlSystem($vcs);
|
||||
}
|
||||
|
||||
return $engine->buildResponse();
|
||||
}
|
||||
|
||||
private function buildVCSTypeResponse() {
|
||||
$vcs_types = PhabricatorRepositoryType::getRepositoryTypeMap();
|
||||
|
||||
$request = $this->getRequest();
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(pht('Create Repository'));
|
||||
$crumbs->setBorder(true);
|
||||
|
||||
$title = pht('Choose Repository Type');
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader(pht('Create Repository'))
|
||||
->setHeaderIcon('fa-plus-square');
|
||||
|
||||
$layout = id(new AphrontMultiColumnView())
|
||||
->setFluidLayout(true);
|
||||
|
||||
$create_uri = $request->getRequestURI();
|
||||
|
||||
foreach ($vcs_types as $vcs_key => $vcs_type) {
|
||||
$action = id(new PHUIActionPanelView())
|
||||
->setIcon(idx($vcs_type, 'icon'))
|
||||
->setHeader(idx($vcs_type, 'create.header'))
|
||||
->setHref($create_uri->alter('vcs', $vcs_key))
|
||||
->setSubheader(idx($vcs_type, 'create.subheader'));
|
||||
|
||||
$layout->addColumn($action);
|
||||
}
|
||||
|
||||
$view = id(new PHUITwoColumnView())
|
||||
->setHeader($header)
|
||||
->setFooter($layout);
|
||||
|
||||
return $this->newPage()
|
||||
->setTitle($title)
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild($view);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user