mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-20 10:48:40 +01:00
Improve subproject/milestone error handling for users who can't create projects
Summary: Fixes T10357. - Show a better (more descriptive) error message when a user who can't create projects tries to create a subproject or milestone. - Disable the subproject actions if you don't have create permission. All this stuff was already enforced properly: this diff doesn't make any actual policy changes, just improves the UI for users who lack permission. Test Plan: - As an unprivileged user (no "Can Create Projects"), tried to create a subproject or milestone. - After patch, got a disabled action, with more specific and helpful error than before. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10357 Differential Revision: https://secure.phabricator.com/D15274
This commit is contained in:
parent
76ea67819f
commit
f1f8ee8e6a
2 changed files with 10 additions and 2 deletions
|
@ -24,6 +24,11 @@ final class PhabricatorProjectEditController
|
|||
|
||||
$id = $request->getURIData('id');
|
||||
if (!$id) {
|
||||
// This capability is checked again later, but checking it here
|
||||
// explicitly gives us a better error message.
|
||||
$this->requireApplicationCapability(
|
||||
ProjectCreateProjectsCapability::CAPABILITY);
|
||||
|
||||
$parent_id = head($request->getArr('parent'));
|
||||
if (!$parent_id) {
|
||||
$parent_id = $request->getStr('parent');
|
||||
|
|
|
@ -181,6 +181,9 @@ final class PhabricatorProjectSubprojectsController
|
|||
$viewer = $this->getViewer();
|
||||
$id = $project->getID();
|
||||
|
||||
$can_create = $this->hasApplicationCapability(
|
||||
ProjectCreateProjectsCapability::CAPABILITY);
|
||||
|
||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||
$viewer,
|
||||
$project,
|
||||
|
@ -198,7 +201,7 @@ final class PhabricatorProjectSubprojectsController
|
|||
$milestone_text = pht('Create Milestone');
|
||||
}
|
||||
|
||||
$can_milestone = ($can_edit && $allows_milestones);
|
||||
$can_milestone = ($can_create && $can_edit && $allows_milestones);
|
||||
$milestone_href = "/project/edit/?milestone={$id}";
|
||||
|
||||
$view->addAction(
|
||||
|
@ -209,7 +212,7 @@ final class PhabricatorProjectSubprojectsController
|
|||
->setDisabled(!$can_milestone)
|
||||
->setWorkflow(!$can_milestone));
|
||||
|
||||
$can_subproject = ($can_edit && $allows_subprojects);
|
||||
$can_subproject = ($can_create && $can_edit && $allows_subprojects);
|
||||
|
||||
// If we're offering to create the first subproject, we're going to warn
|
||||
// the user about the effects before moving forward.
|
||||
|
|
Loading…
Add table
Reference in a new issue