Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13963214
D15813.id38113.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D15813.id38113.diff
View Options
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditproController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditproController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditproController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditproController.php
@@ -4,9 +4,66 @@
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);
}
}
diff --git a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php
--- a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php
+++ b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php
@@ -5,6 +5,17 @@
const ENGINECONST = 'diffusion.repository';
+ private $versionControlSystem;
+
+ public function setVersionControlSystem($version_control_system) {
+ $this->versionControlSystem = $version_control_system;
+ return $this;
+ }
+
+ public function getVersionControlSystem() {
+ return $this->versionControlSystem;
+ }
+
public function isEngineConfigurable() {
return false;
}
@@ -27,7 +38,14 @@
protected function newEditableObject() {
$viewer = $this->getViewer();
- return PhabricatorRepository::initializeNewRepository($viewer);
+ $repository = PhabricatorRepository::initializeNewRepository($viewer);
+
+ $vcs = $this->getVersionControlSystem();
+ if ($vcs) {
+ $repository->setVersionControlSystem($vcs);
+ }
+
+ return $repository;
}
protected function newObjectQuery() {
diff --git a/src/applications/diffusion/management/DiffusionRepositoryStatusManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryStatusManagementPanel.php
--- a/src/applications/diffusion/management/DiffusionRepositoryStatusManagementPanel.php
+++ b/src/applications/diffusion/management/DiffusionRepositoryStatusManagementPanel.php
@@ -46,8 +46,12 @@
pht('Update Frequency'),
$this->buildRepositoryUpdateInterval($repository));
+ $messages = id(new PhabricatorRepositoryStatusMessage())
+ ->loadAllWhere('repositoryID = %d', $repository->getID());
+ $messages = mpull($messages, null, 'getStatusType');
- list($status, $raw_error) = $this->buildRepositoryStatus($repository);
+ $status = $this->buildRepositoryStatus($repository, $messages);
+ $raw_error = $this->buildRepositoryRawError($repository, $messages);
$view->addProperty(pht('Status'), $status);
if ($raw_error) {
@@ -80,17 +84,14 @@
}
private function buildRepositoryStatus(
- PhabricatorRepository $repository) {
+ PhabricatorRepository $repository,
+ array $messages) {
$viewer = $this->getViewer();
$is_cluster = $repository->getAlmanacServicePHID();
$view = new PHUIStatusListView();
- $messages = id(new PhabricatorRepositoryStatusMessage())
- ->loadAllWhere('repositoryID = %d', $repository->getID());
- $messages = mpull($messages, null, 'getStatusType');
-
if ($repository->isTracked()) {
$view->addItem(
id(new PHUIStatusItemView())
@@ -361,8 +362,6 @@
}
}
- $raw_error = null;
-
$message = idx($messages, PhabricatorRepositoryStatusMessage::TYPE_FETCH);
if ($message) {
switch ($message->getStatusCode()) {
@@ -377,8 +376,6 @@
'access the repository.');
}
- $raw_error = $message;
-
$view->addItem(
id(new PHUIStatusItemView())
->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')
@@ -432,11 +429,30 @@
->setNote(pht('This repository will be updated soon!')));
}
+ return $view;
+ }
+
+ private function buildRepositoryRawError(
+ PhabricatorRepository $repository,
+ array $messages) {
+ $viewer = $this->getViewer();
+
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$repository,
PhabricatorPolicyCapability::CAN_EDIT);
+ $raw_error = null;
+
+ $message = idx($messages, PhabricatorRepositoryStatusMessage::TYPE_FETCH);
+ if ($message) {
+ switch ($message->getStatusCode()) {
+ case PhabricatorRepositoryStatusMessage::CODE_ERROR:
+ $raw_error = $message->getParameter('message');
+ break;
+ }
+ }
+
if ($raw_error !== null) {
if (!$can_edit) {
$raw_message = pht(
@@ -450,7 +466,7 @@
$raw_message = null;
}
- return array($view, $raw_message);
+ return $raw_message;
}
diff --git a/src/applications/diffusion/management/DiffusionRepositoryURIsManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryURIsManagementPanel.php
--- a/src/applications/diffusion/management/DiffusionRepositoryURIsManagementPanel.php
+++ b/src/applications/diffusion/management/DiffusionRepositoryURIsManagementPanel.php
@@ -106,7 +106,7 @@
));
$doc_href = PhabricatorEnv::getDoclink(
- 'Diffusion User Guide: Repository URIs');
+ 'Diffusion User Guide: URIs');
$header = id(new PHUIHeaderView())
->setHeader(pht('Repository URIs'))
diff --git a/src/applications/repository/constants/PhabricatorRepositoryType.php b/src/applications/repository/constants/PhabricatorRepositoryType.php
--- a/src/applications/repository/constants/PhabricatorRepositoryType.php
+++ b/src/applications/repository/constants/PhabricatorRepositoryType.php
@@ -7,17 +7,41 @@
const REPOSITORY_TYPE_MERCURIAL = 'hg';
public static function getAllRepositoryTypes() {
- $map = array(
- self::REPOSITORY_TYPE_GIT => pht('Git'),
- self::REPOSITORY_TYPE_MERCURIAL => pht('Mercurial'),
- self::REPOSITORY_TYPE_SVN => pht('Subversion'),
- );
- return $map;
+ $map = self::getRepositoryTypeMap();
+ return ipull($map, 'name');
}
public static function getNameForRepositoryType($type) {
- $map = self::getAllRepositoryTypes();
- return idx($map, $type, pht('Unknown'));
+ $spec = self::getRepositoryTypeSpec($type);
+ return idx($spec, 'name', pht('Unknown ("%s")', $type));
+ }
+
+ public static function getRepositoryTypeSpec($type) {
+ $map = self::getRepositoryTypeMap();
+ return idx($map, $type, array());
+ }
+
+ public static function getRepositoryTypeMap() {
+ return array(
+ self::REPOSITORY_TYPE_GIT => array(
+ 'name' => pht('Git'),
+ 'icon' => 'fa-git',
+ 'create.header' => pht('Create Git Repository'),
+ 'create.subheader' => pht('Create a new Git repository.'),
+ ),
+ self::REPOSITORY_TYPE_MERCURIAL => array(
+ 'name' => pht('Mercurial'),
+ 'icon' => 'fa-code-fork',
+ 'create.header' => pht('Create Mercurial Repository'),
+ 'create.subheader' => pht('Create a new Mercurial repository.'),
+ ),
+ self::REPOSITORY_TYPE_SVN => array(
+ 'name' => pht('Subversion'),
+ 'icon' => 'fa-database',
+ 'create.header' => pht('Create Subversion Repository'),
+ 'create.subheader' => pht('Create a new Subversion repository.'),
+ ),
+ );
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 16, 2:35 PM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6717840
Default Alt Text
D15813.id38113.diff (8 KB)
Attached To
Mode
D15813: Give users a modal VCS choice when creating a new repository
Attached
Detach File
Event Timeline
Log In to Comment