diff --git a/src/applications/diffusion/controller/DiffusionRepositoryURIDisableController.php b/src/applications/diffusion/controller/DiffusionRepositoryURIDisableController.php index b846b3f4e2..466a0fd388 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryURIDisableController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryURIDisableController.php @@ -31,6 +31,16 @@ final class DiffusionRepositoryURIDisableController $is_disabled = $uri->getIsDisabled(); $view_uri = $uri->getViewURI(); + if ($uri->isBuiltin()) { + return $this->newDialog() + ->setTitle(pht('Builtin URI')) + ->appendParagraph( + pht( + 'You can not manually disable builtin URIs. To hide a builtin '. + 'URI, configure its "Display" behavior instead.')) + ->addCancelButton($view_uri); + } + if ($request->isFormPost()) { $xactions = array(); diff --git a/src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php b/src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php index 61a8cba0a1..61335d20d0 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php @@ -147,6 +147,8 @@ final class DiffusionRepositoryURIViewController $disable_icon = 'fa-ban'; } + $can_disable = ($can_edit && !$uri->isBuiltin()); + $disable_uri = $repository->getPathURI("uri/disable/{$id}/"); $curtain->addAction( @@ -155,7 +157,7 @@ final class DiffusionRepositoryURIViewController ->setName($disable_name) ->setHref($disable_uri) ->setWorkflow(true) - ->setDisabled(!$can_edit)); + ->setDisabled(!$can_disable)); return $curtain; } diff --git a/src/applications/diffusion/editor/DiffusionURIEditor.php b/src/applications/diffusion/editor/DiffusionURIEditor.php index 9115b00083..020275a367 100644 --- a/src/applications/diffusion/editor/DiffusionURIEditor.php +++ b/src/applications/diffusion/editor/DiffusionURIEditor.php @@ -415,6 +415,26 @@ final class DiffusionURIEditor } } break; + + case PhabricatorRepositoryURITransaction::TYPE_DISABLE: + $old = $object->getIsDisabled(); + foreach ($xactions as $xaction) { + $new = $xaction->getNewValue(); + + if ($old == $new) { + continue; + } + + if (!$object->isBuiltin()) { + continue; + } + + $errors[] = new PhabricatorApplicationTransactionValidationError( + $type, + pht('Invalid'), + pht('You can not manually disable builtin URIs.')); + } + break; } return $errors;