From 98b202042e936e09a9154ac88e5e6f53151c69d2 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 9 May 2016 15:36:13 -0700 Subject: [PATCH] Provide some more context hints for repository URIs Summary: Ref T10923. This provides a little guidance about hosted vs observed, and points at the `diffusion.ssh-*` options. Test Plan: Poked around in the web UI, saw useful guidance. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10923 Differential Revision: https://secure.phabricator.com/D15872 --- .../editor/DiffusionURIEditEngine.php | 19 +++++++++++++++++- ...RepositoryDocumentationManagementPanel.php | 2 +- ...DiffusionRepositoryURIsManagementPanel.php | 20 +++++++++++++++++++ .../editfield/PhabricatorEditField.php | 15 ++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/applications/diffusion/editor/DiffusionURIEditEngine.php b/src/applications/diffusion/editor/DiffusionURIEditEngine.php index 61e24e0997..639dd74400 100644 --- a/src/applications/diffusion/editor/DiffusionURIEditEngine.php +++ b/src/applications/diffusion/editor/DiffusionURIEditEngine.php @@ -83,9 +83,25 @@ final class DiffusionURIEditEngine protected function buildCustomEditFields($object) { $viewer = $this->getViewer(); + $uri_instructions = null; if ($object->isBuiltin()) { $is_builtin = true; $uri_value = (string)$object->getDisplayURI(); + + switch ($object->getBuiltinProtocol()) { + case PhabricatorRepositoryURI::BUILTIN_PROTOCOL_SSH: + $uri_instructions = pht( + " - Configure [[ %s | %s ]] to change the SSH username.\n". + " - Configure [[ %s | %s ]] to change the SSH host.\n". + " - Configure [[ %s | %s ]] to change the SSH port.", + '/config/edit/diffusion.ssh-user/', + 'diffusion.ssh-user', + '/config/edit/diffusion.ssh-host/', + 'diffusion.ssh-host', + '/config/edit/diffusion.ssh-port/', + 'diffusion.ssh-port'); + break; + } } else { $is_builtin = false; $uri_value = $object->getURI(); @@ -118,7 +134,8 @@ final class DiffusionURIEditEngine ->setConduitTypeDescription(pht('New repository URI.')) ->setIsRequired(!$is_builtin) ->setIsLocked($is_builtin) - ->setValue($uri_value), + ->setValue($uri_value) + ->setControlInstructions($uri_instructions), id(new PhabricatorSelectEditField()) ->setKey('io') ->setLabel(pht('I/O Type')) diff --git a/src/applications/diffusion/management/DiffusionRepositoryDocumentationManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryDocumentationManagementPanel.php index add9cfe054..ca2c577b38 100644 --- a/src/applications/diffusion/management/DiffusionRepositoryDocumentationManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositoryDocumentationManagementPanel.php @@ -14,7 +14,7 @@ final class DiffusionRepositoryDocumentationManagementPanel } public function getManagementPanelIcon() { - return 'fa-book bluegrey'; + return 'fa-book'; } public function buildManagementPanelContent() { diff --git a/src/applications/diffusion/management/DiffusionRepositoryURIsManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryURIsManagementPanel.php index 5422d15779..5a4e4de79f 100644 --- a/src/applications/diffusion/management/DiffusionRepositoryURIsManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositoryURIsManagementPanel.php @@ -113,8 +113,28 @@ final class DiffusionRepositoryURIsManagementPanel ->setTag('a') ->setText(pht('Documentation'))); + $messages = array(); + if ($repository->isHosted()) { + $messages[] = array( + id(new PHUIIconView())->setIcon('fa-folder'), + ' ', + pht('Phabricator is hosting this repository.'), + ); + } else { + $messages[] = array( + id(new PHUIIconView())->setIcon('fa-download'), + ' ', + pht('This repository is hosted remotely. Phabricator is observing it.'), + ); + } + + $info_view = id(new PHUIInfoView()) + ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) + ->setErrors($messages); + return id(new PHUIObjectBoxView()) ->setHeader($header) + ->setInfoView($info_view) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setTable($table); } diff --git a/src/applications/transactions/editfield/PhabricatorEditField.php b/src/applications/transactions/editfield/PhabricatorEditField.php index 3b4c4e264b..6ff84da870 100644 --- a/src/applications/transactions/editfield/PhabricatorEditField.php +++ b/src/applications/transactions/editfield/PhabricatorEditField.php @@ -16,6 +16,7 @@ abstract class PhabricatorEditField extends Phobject { private $isRequired; private $previewPanel; private $controlID; + private $controlInstructions; private $description; private $conduitDescription; @@ -272,6 +273,15 @@ abstract class PhabricatorEditField extends Phobject { return $this->previewPanel; } + public function setControlInstructions($control_instructions) { + $this->controlInstructions = $control_instructions; + return $this; + } + + public function getControlInstructions() { + return $this->controlInstructions; + } + protected function newControl() { throw new PhutilMethodNotImplementedException(); } @@ -358,6 +368,11 @@ abstract class PhabricatorEditField extends Phobject { } } + $instructions = $this->getControlInstructions(); + if (strlen($instructions)) { + $form->appendRemarkupInstructions($instructions); + } + $form->appendControl($control); } return $this;