mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Check if user can create project before showing shortcut
Summary: In Maniphest, we provide an additional caption shortcut if you can create projects, which has no use if you cant. Fixes T6969 Test Plan: Check page with and without a user's capability. Reviewers: btrahan, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6969 Differential Revision: https://secure.phabricator.com/D11390
This commit is contained in:
parent
39406bd1f3
commit
498ce937e7
1 changed files with 16 additions and 9 deletions
|
@ -25,6 +25,10 @@ final class ManiphestTaskEditController extends ManiphestController {
|
|||
ManiphestEditProjectsCapability::CAPABILITY);
|
||||
$can_edit_status = $this->hasApplicationCapability(
|
||||
ManiphestEditStatusCapability::CAPABILITY);
|
||||
$can_create_projects = PhabricatorPolicyFilter::hasCapability(
|
||||
$user,
|
||||
PhabricatorApplication::getByClass('PhabricatorProjectApplication'),
|
||||
ProjectCreateProjectsCapability::CAPABILITY);
|
||||
|
||||
$parent_task = null;
|
||||
$template_id = null;
|
||||
|
@ -664,6 +668,17 @@ final class ManiphestTaskEditController extends ManiphestController {
|
|||
}
|
||||
|
||||
if ($can_edit_projects) {
|
||||
$caption = null;
|
||||
if ($can_create_projects) {
|
||||
$caption = javelin_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/project/create/',
|
||||
'mustcapture' => true,
|
||||
'sigil' => 'project-create',
|
||||
),
|
||||
pht('Create New Project'));
|
||||
}
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
|
@ -671,15 +686,7 @@ final class ManiphestTaskEditController extends ManiphestController {
|
|||
->setName('projects')
|
||||
->setValue($projects_value)
|
||||
->setID($project_tokenizer_id)
|
||||
->setCaption(
|
||||
javelin_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/project/create/',
|
||||
'mustcapture' => true,
|
||||
'sigil' => 'project-create',
|
||||
),
|
||||
pht('Create New Project')))
|
||||
->setCaption($caption)
|
||||
->setDatasource(new PhabricatorProjectDatasource()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue