Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13980736
D15825.id38125.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D15825.id38125.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -789,6 +789,7 @@
'DiffusionRepositorySymbolsManagementPanel' => 'applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php',
'DiffusionRepositoryTag' => 'applications/diffusion/data/DiffusionRepositoryTag.php',
'DiffusionRepositoryTestAutomationController' => 'applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php',
+ 'DiffusionRepositoryURIDisableController' => 'applications/diffusion/controller/DiffusionRepositoryURIDisableController.php',
'DiffusionRepositoryURIEditController' => 'applications/diffusion/controller/DiffusionRepositoryURIEditController.php',
'DiffusionRepositoryURIViewController' => 'applications/diffusion/controller/DiffusionRepositoryURIViewController.php',
'DiffusionRepositoryURIsIndexEngineExtension' => 'applications/diffusion/engineextension/DiffusionRepositoryURIsIndexEngineExtension.php',
@@ -5019,7 +5020,8 @@
'DiffusionRepositorySymbolsManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositoryTag' => 'Phobject',
'DiffusionRepositoryTestAutomationController' => 'DiffusionRepositoryEditController',
- 'DiffusionRepositoryURIEditController' => 'DiffusionRepositoryEditController',
+ 'DiffusionRepositoryURIDisableController' => 'DiffusionController',
+ 'DiffusionRepositoryURIEditController' => 'DiffusionController',
'DiffusionRepositoryURIViewController' => 'DiffusionController',
'DiffusionRepositoryURIsIndexEngineExtension' => 'PhabricatorIndexEngineExtension',
'DiffusionRepositoryURIsManagementPanel' => 'DiffusionRepositoryManagementPanel',
diff --git a/src/applications/diffusion/application/PhabricatorDiffusionApplication.php b/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
--- a/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
+++ b/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
@@ -93,6 +93,8 @@
=> 'DiffusionRepositoryManageController',
'uri/' => array(
'view/(?P<id>[0-9]\d*)/' => 'DiffusionRepositoryURIViewController',
+ 'disable/(?P<id>[0-9]\d*)/'
+ => 'DiffusionRepositoryURIDisableController',
$this->getEditRoutePattern('edit/')
=> 'DiffusionRepositoryURIEditController',
),
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryURIDisableController.php b/src/applications/diffusion/controller/DiffusionRepositoryURIDisableController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diffusion/controller/DiffusionRepositoryURIDisableController.php
@@ -0,0 +1,72 @@
+<?php
+
+final class DiffusionRepositoryURIDisableController
+ extends DiffusionController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContextForEdit();
+ if ($response) {
+ return $response;
+ }
+
+ $viewer = $this->getViewer();
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
+ $id = $request->getURIData('id');
+ $uri = id(new PhabricatorRepositoryURIQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->withRepositories(array($repository))
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->executeOne();
+ if (!$uri) {
+ return new Aphront404Response();
+ }
+
+ $is_disabled = $uri->getIsDisabled();
+ $view_uri = $uri->getViewURI();
+
+ if ($request->isFormPost()) {
+ $xactions = array();
+
+ $xactions[] = id(new PhabricatorRepositoryURITransaction())
+ ->setTransactionType(PhabricatorRepositoryURITransaction::TYPE_DISABLE)
+ ->setNewValue(!$is_disabled);
+
+ $editor = id(new DiffusionURIEditor())
+ ->setActor($viewer)
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true)
+ ->setContentSourceFromRequest($request)
+ ->applyTransactions($uri, $xactions);
+
+ return id(new AphrontRedirectResponse())->setURI($view_uri);
+ }
+
+ if ($is_disabled) {
+ $title = pht('Enable URI');
+ $body = pht(
+ 'Enable this URI? Any configured behaviors will begin working '.
+ 'again.');
+ $button = pht('Enable URI');
+ } else {
+ $title = pht('Disable URI');
+ $body = pht(
+ 'Disable this URI? It will no longer be observed, fetched, mirrored, '.
+ 'served or shown to users.');
+ $button = pht('Disable URI');
+ }
+
+ return $this->newDialog()
+ ->setTitle($title)
+ ->appendParagraph($body)
+ ->addCancelButton($view_uri)
+ ->addSubmitButton($button);
+ }
+
+}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryURIEditController.php b/src/applications/diffusion/controller/DiffusionRepositoryURIEditController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryURIEditController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryURIEditController.php
@@ -1,7 +1,7 @@
<?php
final class DiffusionRepositoryURIEditController
- extends DiffusionRepositoryEditController {
+ extends DiffusionController {
public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContextForEdit();
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php b/src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php
@@ -82,16 +82,18 @@
private function buildCurtain(PhabricatorRepositoryURI $uri) {
$viewer = $this->getViewer();
+ $id = $uri->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$uri,
PhabricatorPolicyCapability::CAN_EDIT);
- $edit_uri = $uri->getEditURI();
$curtain = $this->newCurtainView($uri);
+ $edit_uri = $uri->getEditURI();
+
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-pencil')
@@ -100,6 +102,24 @@
->setWorkflow(!$can_edit)
->setDisabled(!$can_edit));
+ if ($uri->getIsDisabled()) {
+ $disable_name = pht('Enable URI');
+ $disable_icon = 'fa-check';
+ } else {
+ $disable_name = pht('Disable URI');
+ $disable_icon = 'fa-ban';
+ }
+
+ $disable_uri = $uri->getRepository()->getPathURI("uri/disable/{$id}/");
+
+ $curtain->addAction(
+ id(new PhabricatorActionView())
+ ->setIcon($disable_icon)
+ ->setName($disable_name)
+ ->setHref($disable_uri)
+ ->setWorkflow(true)
+ ->setDisabled(!$can_edit));
+
return $curtain;
}
diff --git a/src/applications/diffusion/editor/DiffusionURIEditor.php b/src/applications/diffusion/editor/DiffusionURIEditor.php
--- a/src/applications/diffusion/editor/DiffusionURIEditor.php
+++ b/src/applications/diffusion/editor/DiffusionURIEditor.php
@@ -217,6 +217,25 @@
$errors[] = $error;
break;
}
+
+ foreach ($xactions as $xaction) {
+ $new_uri = $xaction->getNewValue();
+ if ($new_uri == $object->getURI()) {
+ continue;
+ }
+
+ try {
+ PhabricatorRepository::assertValidRemoteURI($new_uri);
+ } catch (Exception $ex) {
+ $errors[] = new PhabricatorApplicationTransactionValidationError(
+ $type,
+ pht('Invalid'),
+ $ex->getMessage(),
+ $xaction);
+ continue;
+ }
+ }
+
break;
case PhabricatorRepositoryURITransaction::TYPE_IO:
$available = $object->getAvailableIOTypeOptions();
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
@@ -91,13 +91,19 @@
null,
));
- $doc_href = PhabricatorEnv::getDoclink(
- 'Diffusion User Guide: URIs');
+ $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: URIs');
+ $add_href = $repository->getPathURI('uri/edit/');
$header = id(new PHUIHeaderView())
->setHeader(pht('Repository URIs'))
->addActionLink(
id(new PHUIButtonView())
+ ->setIcon('fa-plus')
+ ->setHref($add_href)
+ ->setTag('a')
+ ->setText(pht('Add New URI')))
+ ->addActionLink(
+ id(new PHUIButtonView())
->setIcon('fa-book')
->setHref($doc_href)
->setTag('a')
diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php
--- a/src/applications/repository/storage/PhabricatorRepository.php
+++ b/src/applications/repository/storage/PhabricatorRepository.php
@@ -1829,8 +1829,8 @@
throw new Exception(
pht(
- "The URI protocol is unrecognized. It should begin ".
- "'%s', '%s', '%s', '%s', '%s', '%s', or be in the form '%s'.",
+ 'The URI protocol is unrecognized. It should begin with '.
+ '"%s", "%s", "%s", "%s", "%s", "%s", or be in the form "%s".',
'ssh://',
'http://',
'https://',
diff --git a/src/applications/repository/storage/PhabricatorRepositoryURITransaction.php b/src/applications/repository/storage/PhabricatorRepositoryURITransaction.php
--- a/src/applications/repository/storage/PhabricatorRepositoryURITransaction.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryURITransaction.php
@@ -51,6 +51,16 @@
$this->renderHandleLink($author_phid),
$old_label,
$new_label);
+ case self::TYPE_DISABLE:
+ if ($new) {
+ return pht(
+ '%s disabled this URI.',
+ $this->renderHandleLink($author_phid));
+ } else {
+ return pht(
+ '%s enabled this URI.',
+ $this->renderHandleLink($author_phid));
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 20, 12:25 PM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6735178
Default Alt Text
D15825.id38125.diff (10 KB)
Attached To
Mode
D15825: Flesh out more web UI actions for new URI interface
Attached
Detach File
Event Timeline
Log In to Comment