From 97c103fa00cc19e9cda1a08de691987790c785fa Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 10 May 2016 17:13:11 -0700 Subject: [PATCH] Restore edit UI for "Import Only" in Subversion Summary: Ref T10923. Although I'd ideally like to get rid of this eventually, keep it around for now. Test Plan: - Edited value for an SVN repository. - Observed no panel present for a Git repository. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10923 Differential Revision: https://secure.phabricator.com/D15883 --- src/__phutil_library_map__.php | 2 + .../editor/DiffusionRepositoryEditEngine.php | 16 ++++ ...ionRepositorySubversionManagementPanel.php | 77 +++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 src/applications/diffusion/management/DiffusionRepositorySubversionManagementPanel.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 937dec6c4a..8b6406f3b8 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -775,6 +775,7 @@ phutil_register_library_map(array( 'DiffusionRepositoryStagingManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryStagingManagementPanel.php', 'DiffusionRepositoryStatusManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryStatusManagementPanel.php', 'DiffusionRepositoryStorageManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryStorageManagementPanel.php', + 'DiffusionRepositorySubversionManagementPanel' => 'applications/diffusion/management/DiffusionRepositorySubversionManagementPanel.php', 'DiffusionRepositorySymbolsManagementPanel' => 'applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php', 'DiffusionRepositoryTag' => 'applications/diffusion/data/DiffusionRepositoryTag.php', 'DiffusionRepositoryTestAutomationController' => 'applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php', @@ -4995,6 +4996,7 @@ phutil_register_library_map(array( 'DiffusionRepositoryStagingManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryStatusManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryStorageManagementPanel' => 'DiffusionRepositoryManagementPanel', + 'DiffusionRepositorySubversionManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositorySymbolsManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryTag' => 'Phobject', 'DiffusionRepositoryTestAutomationController' => 'DiffusionRepositoryManageController', diff --git a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php index 7d3d5640ff..933cdbb597 100644 --- a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php +++ b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php @@ -226,6 +226,11 @@ final class DiffusionRepositoryEditEngine "IMPORTANT: This feature is new, experimental, and not supported. ". "Use it at your own risk."); + $subpath_instructions = pht( + 'If you want to import only part of a repository, like `trunk/`, '. + 'you can set a path in **Import Only**. Phabricator will ignore '. + 'commits which do not affect this path.'); + return array( id(new PhabricatorSelectEditField()) ->setKey('vcs') @@ -338,6 +343,17 @@ final class DiffusionRepositoryEditEngine ->setConduitDescription(pht('Set the autoclose branches.')) ->setConduitTypeDescription(pht('New default tracked branchs.')) ->setValue($autoclose_value), + id(new PhabricatorTextEditField()) + ->setKey('importOnly') + ->setLabel(pht('Import Only')) + ->setTransactionType( + PhabricatorRepositoryTransaction::TYPE_SVN_SUBPATH) + ->setIsCopyable(true) + ->setDescription(pht('Subpath to selectively import.')) + ->setConduitDescription(pht('Set the subpath to import.')) + ->setConduitTypeDescription(pht('New subpath to import.')) + ->setValue($object->getDetail('svn-subpath')) + ->setControlInstructions($subpath_instructions), id(new PhabricatorTextEditField()) ->setKey('stagingAreaURI') ->setLabel(pht('Staging Area URI')) diff --git a/src/applications/diffusion/management/DiffusionRepositorySubversionManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositorySubversionManagementPanel.php new file mode 100644 index 0000000000..c6b236d5b9 --- /dev/null +++ b/src/applications/diffusion/management/DiffusionRepositorySubversionManagementPanel.php @@ -0,0 +1,77 @@ +isSVN(); + } + + public function getManagementPanelIcon() { + $repository = $this->getRepository(); + + $has_any = (bool)$repository->getDetail('svn-subpath'); + + if ($has_any) { + return 'fa-database'; + } else { + return 'fa-database grey'; + } + } + + protected function getEditEngineFieldKeys() { + return array( + 'importOnly', + ); + } + + protected function buildManagementPanelActions() { + $repository = $this->getRepository(); + $viewer = $this->getViewer(); + + $can_edit = PhabricatorPolicyFilter::hasCapability( + $viewer, + $repository, + PhabricatorPolicyCapability::CAN_EDIT); + + $subversion_uri = $this->getEditPageURI(); + + return array( + id(new PhabricatorActionView()) + ->setIcon('fa-pencil') + ->setName(pht('Edit Properties')) + ->setHref($subversion_uri) + ->setDisabled(!$can_edit) + ->setWorkflow(!$can_edit), + ); + } + + public function buildManagementPanelContent() { + $repository = $this->getRepository(); + $viewer = $this->getViewer(); + + $view = id(new PHUIPropertyListView()) + ->setViewer($viewer) + ->setActionList($this->newActions()); + + $default_branch = nonempty( + $repository->getHumanReadableDetail('svn-subpath'), + phutil_tag('em', array(), pht('Import Entire Repository'))); + $view->addProperty(pht('Import Only'), $default_branch); + + + return $this->newBox(pht('Subversion'), $view); + } + +}