mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
Prevent users from disabling repository builtin URIs
Summary: Ref T10923. Currently, users can disable or enable builtin URIs, but this doesn't actually do anything. The behavior of "disable" has changed a bit over time and might need some further refinement, but it's currently meaningless for builtin URIs. Prevent adjustment of it. If users want to hide a URI, they should set "Display: Hidden" instead. Test Plan: - Disabled/enabled a non-builtin URI. - Tried to disable a builtin URI, saw greyed out UI and got a helpful error message. Reviewers: chad Reviewed By: chad Subscribers: eadler Maniphest Tasks: T10923 Differential Revision: https://secure.phabricator.com/D15899
This commit is contained in:
parent
5162f81095
commit
9d196648f5
3 changed files with 33 additions and 1 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue