mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Modernize "projects" typeahead datasource
Summary: Ref T4420. Update "projects" source. Test Plan: - Edited projects on a Differential revision. - Edited projects on a commit. - Edited projects on a repository. - Edited projects in feed search. - Edited projects in a Herald rule field. - Edited projects in a Herald rule action. - Edited projects in Maniphest batch editor. - Edited projects on Maniphest task. - Edited projects in "Associate Projects..." action in Maniphest. - Edited projects on Maniphest search in "all projects", "any project" and "not projects" fields. - Edited projects on a Paste. - Edited projects on a Pholio mock. - Edited projects on a custom policy rule. - Edited projects on a Ponder question. - Edited projects on a Diffusion search query. - Edited projects on a global search query. - Edited projects on a slowvote. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9884
This commit is contained in:
parent
fc36ec0da1
commit
793eced32d
19 changed files with 96 additions and 43 deletions
|
@ -1984,6 +1984,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectCustomFieldStorage' => 'applications/project/storage/PhabricatorProjectCustomFieldStorage.php',
|
||||
'PhabricatorProjectCustomFieldStringIndex' => 'applications/project/storage/PhabricatorProjectCustomFieldStringIndex.php',
|
||||
'PhabricatorProjectDAO' => 'applications/project/storage/PhabricatorProjectDAO.php',
|
||||
'PhabricatorProjectDatasource' => 'applications/project/typeahead/PhabricatorProjectDatasource.php',
|
||||
'PhabricatorProjectDescriptionField' => 'applications/project/customfield/PhabricatorProjectDescriptionField.php',
|
||||
'PhabricatorProjectEditDetailsController' => 'applications/project/controller/PhabricatorProjectEditDetailsController.php',
|
||||
'PhabricatorProjectEditIconController' => 'applications/project/controller/PhabricatorProjectEditIconController.php',
|
||||
|
@ -4857,6 +4858,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectCustomFieldStorage' => 'PhabricatorCustomFieldStorage',
|
||||
'PhabricatorProjectCustomFieldStringIndex' => 'PhabricatorCustomFieldStringIndexStorage',
|
||||
'PhabricatorProjectDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorProjectDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||
'PhabricatorProjectDescriptionField' => 'PhabricatorProjectStandardCustomField',
|
||||
'PhabricatorProjectEditDetailsController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectEditIconController' => 'PhabricatorProjectController',
|
||||
|
|
|
@ -56,7 +56,7 @@ final class DifferentialProjectsField
|
|||
public function renderEditControl(array $handles) {
|
||||
return id(new AphrontFormTokenizerControl())
|
||||
->setName($this->getFieldKey())
|
||||
->setDatasource('/typeahead/common/projects/')
|
||||
->setDatasource(new PhabricatorProjectDatasource())
|
||||
->setValue($handles)
|
||||
->setLabel($this->getFieldName());
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ final class DiffusionCommitEditController extends DiffusionController {
|
|||
'sigil' => 'project-create',
|
||||
),
|
||||
pht('Create New Project')))
|
||||
->setDatasource('/typeahead/common/projects/'));;
|
||||
->setDatasource(new PhabricatorProjectDatasource()));
|
||||
|
||||
Javelin::initBehavior('project-create', array(
|
||||
'tokenizerID' => $tokenizer_id,
|
||||
|
|
|
@ -125,7 +125,7 @@ final class DiffusionRepositoryEditBasicController
|
|||
->setValue($v_desc))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/projects/')
|
||||
->setDatasource(new PhabricatorProjectDatasource())
|
||||
->setName('projectPHIDs')
|
||||
->setLabel(pht('Projects'))
|
||||
->setValue($project_handles))
|
||||
|
|
|
@ -84,7 +84,7 @@ final class PhabricatorFeedSearchEngine
|
|||
->setValue($user_handles))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/projects/')
|
||||
->setDatasource(new PhabricatorProjectDatasource())
|
||||
->setName('projectPHIDs')
|
||||
->setLabel(pht('Include Projects'))
|
||||
->setValue($proj_handles))
|
||||
|
|
|
@ -595,13 +595,13 @@ final class HeraldRuleController extends HeraldController {
|
|||
'buildplan' => new HarbormasterBuildPlanDatasource(),
|
||||
'arcanistprojects' => new DiffusionArcanistProjectDatasource(),
|
||||
'package' => new PhabricatorOwnersPackageDatasource(),
|
||||
'project' => new PhabricatorProjectDatasource(),
|
||||
);
|
||||
|
||||
$sources = mpull($sources, 'getDatasourceURI');
|
||||
$sources += array(
|
||||
'email' => '/typeahead/common/mailable/',
|
||||
'user' => '/typeahead/common/accounts/',
|
||||
'project' => '/typeahead/common/projects/',
|
||||
'userorproject' => '/typeahead/common/accountsorprojects/',
|
||||
);
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@ final class ManiphestBatchEditController extends ManiphestController {
|
|||
$template = new AphrontTokenizerTemplateView();
|
||||
$template = $template->render();
|
||||
|
||||
$projects_source = new PhabricatorProjectDatasource();
|
||||
|
||||
require_celerity_resource('maniphest-batch-editor');
|
||||
Javelin::initBehavior(
|
||||
'maniphest-batch-editor',
|
||||
|
@ -69,8 +71,8 @@ final class ManiphestBatchEditController extends ManiphestController {
|
|||
'tokenizerTemplate' => $template,
|
||||
'sources' => array(
|
||||
'project' => array(
|
||||
'src' => '/typeahead/common/projects/',
|
||||
'placeholder' => pht('Type a project name...'),
|
||||
'src' => $projects_source->getDatasourceURI(),
|
||||
'placeholder' => $projects_source->getPlaceholderText(),
|
||||
),
|
||||
'owner' => array(
|
||||
'src' => '/typeahead/common/searchowner/',
|
||||
|
|
|
@ -282,11 +282,13 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||
ManiphestTransaction::TYPE_PROJECTS => 'projects',
|
||||
);
|
||||
|
||||
$projects_source = new PhabricatorProjectDatasource();
|
||||
|
||||
$tokenizer_map = array(
|
||||
ManiphestTransaction::TYPE_PROJECTS => array(
|
||||
'id' => 'projects-tokenizer',
|
||||
'src' => '/typeahead/common/projects/',
|
||||
'placeholder' => pht('Type a project name...'),
|
||||
'src' => $projects_source->getDatasourceURI(),
|
||||
'placeholder' => $projects_source->getPlaceholderText(),
|
||||
),
|
||||
ManiphestTransaction::TYPE_OWNER => array(
|
||||
'id' => 'assign-tokenizer',
|
||||
|
|
|
@ -650,7 +650,7 @@ final class ManiphestTaskEditController extends ManiphestController {
|
|||
'sigil' => 'project-create',
|
||||
),
|
||||
pht('Create New Project')))
|
||||
->setDatasource('/typeahead/common/projects/'));
|
||||
->setDatasource(new PhabricatorProjectDatasource()));
|
||||
}
|
||||
|
||||
$field_list->appendFieldsToForm($form);
|
||||
|
|
|
@ -322,7 +322,7 @@ final class ManiphestTaskSearchEngine
|
|||
$with_unassigned))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/projects/')
|
||||
->setDatasource(new PhabricatorProjectDatasource())
|
||||
->setName('allProjects')
|
||||
->setLabel(pht('In All Projects'))
|
||||
->setValue($all_project_handles));
|
||||
|
@ -341,13 +341,13 @@ final class ManiphestTaskSearchEngine
|
|||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/projects/')
|
||||
->setDatasource(new PhabricatorProjectDatasource())
|
||||
->setName('anyProjects')
|
||||
->setLabel(pht('In Any Project'))
|
||||
->setValue($any_project_handles))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/projects/')
|
||||
->setDatasource(new PhabricatorProjectDatasource())
|
||||
->setName('excludeProjects')
|
||||
->setLabel(pht('Not In Projects'))
|
||||
->setValue($exclude_project_handles))
|
||||
|
|
|
@ -186,7 +186,7 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
|
|||
->setLabel(pht('Projects'))
|
||||
->setName('projects')
|
||||
->setValue($project_handles)
|
||||
->setDatasource('/typeahead/common/projects/'));
|
||||
->setDatasource(new PhabricatorProjectDatasource()));
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
|
|
|
@ -341,40 +341,41 @@ final class PholioMockEditController extends PholioController {
|
|||
$form->addHiddenInput('status', 'open');
|
||||
}
|
||||
|
||||
$form->appendChild(
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setLabel(pht('Projects'))
|
||||
->setName('projects')
|
||||
->setValue($project_handles)
|
||||
->setDatasource('/typeahead/common/projects/'))
|
||||
->setDatasource(new PhabricatorProjectDatasource()))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setLabel(pht('CC'))
|
||||
->setName('cc')
|
||||
->setValue($handles)
|
||||
->setUser($user)
|
||||
->setDatasource('/typeahead/common/mailable/'))
|
||||
->setLabel(pht('CC'))
|
||||
->setName('cc')
|
||||
->setValue($handles)
|
||||
->setUser($user)
|
||||
->setDatasource('/typeahead/common/mailable/'))
|
||||
->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setUser($user)
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
|
||||
->setPolicyObject($mock)
|
||||
->setPolicies($policies)
|
||||
->setName('can_view'))
|
||||
->setUser($user)
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
|
||||
->setPolicyObject($mock)
|
||||
->setPolicies($policies)
|
||||
->setName('can_view'))
|
||||
->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setUser($user)
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
||||
->setPolicyObject($mock)
|
||||
->setPolicies($policies)
|
||||
->setName('can_edit'))
|
||||
->setUser($user)
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
||||
->setPolicyObject($mock)
|
||||
->setPolicies($policies)
|
||||
->setName('can_edit'))
|
||||
->appendChild(
|
||||
id(new AphrontFormMarkupControl())
|
||||
->setValue($list_control))
|
||||
->setValue($list_control))
|
||||
->appendChild(
|
||||
id(new AphrontFormMarkupControl())
|
||||
->setValue($drop_control)
|
||||
->setError($e_images))
|
||||
->setValue($drop_control)
|
||||
->setError($e_images))
|
||||
->appendChild($submit);
|
||||
|
||||
$form_box = id(new PHUIObjectBoxView())
|
||||
|
|
|
@ -39,10 +39,12 @@ final class PhabricatorPolicyRuleProjects
|
|||
}
|
||||
|
||||
public function getValueControlTemplate() {
|
||||
$projects_source = new PhabricatorProjectDatasource();
|
||||
|
||||
return array(
|
||||
'markup' => new AphrontTokenizerTemplateView(),
|
||||
'uri' => '/typeahead/common/projects/',
|
||||
'placeholder' => pht('Type a project name...'),
|
||||
'uri' => $projects_source->getDatasourceURI(),
|
||||
'placeholder' => $projects_source->getPlaceholderText(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ final class PonderQuestionEditController extends PonderController {
|
|||
->setLabel(pht('Projects'))
|
||||
->setName('projects')
|
||||
->setValue($project_handles)
|
||||
->setDatasource('/typeahead/common/projects/'));
|
||||
->setDatasource(new PhabricatorProjectDatasource()));
|
||||
|
||||
$form ->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectDatasource
|
||||
extends PhabricatorTypeaheadDatasource {
|
||||
|
||||
public function getPlaceholderText() {
|
||||
return pht('Type a project name...');
|
||||
}
|
||||
|
||||
public function getDatasourceApplicationClass() {
|
||||
return 'PhabricatorApplicationProject';
|
||||
}
|
||||
|
||||
public function loadResults() {
|
||||
$viewer = $this->getViewer();
|
||||
$raw_query = $this->getRawQuery();
|
||||
|
||||
$results = array();
|
||||
|
||||
$projs = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->needImages(true)
|
||||
->execute();
|
||||
foreach ($projs as $proj) {
|
||||
$closed = null;
|
||||
if ($proj->isArchived()) {
|
||||
$closed = pht('Archived');
|
||||
}
|
||||
|
||||
$proj_result = id(new PhabricatorTypeaheadResult())
|
||||
->setName($proj->getName())
|
||||
->setDisplayType('Project')
|
||||
->setURI('/tag/'.$proj->getPrimarySlug().'/')
|
||||
->setPHID($proj->getPHID())
|
||||
->setIcon($proj->getIcon())
|
||||
->setPriorityType('proj')
|
||||
->setClosed($closed);
|
||||
|
||||
$proj_result->setImageURI($proj->getProfileImageURI());
|
||||
|
||||
$results[] = $proj_result;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
|
@ -106,7 +106,7 @@ final class PhabricatorRepositorySearchEngine
|
|||
->setValue($name))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/projects/')
|
||||
->setDatasource(new PhabricatorProjectDatasource())
|
||||
->setName('anyProjects')
|
||||
->setLabel(pht('In Any Project'))
|
||||
->setValue($any_project_handles))
|
||||
|
|
|
@ -161,7 +161,7 @@ final class PhabricatorSearchApplicationSearchEngine
|
|||
id(new AphrontFormTokenizerControl())
|
||||
->setName('projectPHIDs')
|
||||
->setLabel('In Any Project')
|
||||
->setDatasource('/typeahead/common/projects/')
|
||||
->setDatasource(new PhabricatorProjectDatasource())
|
||||
->setValue($project_handles));
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ final class PhabricatorSlowvoteEditController
|
|||
->setLabel(pht('Projects'))
|
||||
->setName('projects')
|
||||
->setValue($project_handles)
|
||||
->setDatasource('/typeahead/common/projects/'));
|
||||
->setDatasource(new PhabricatorProjectDatasource()));
|
||||
|
||||
if ($is_new) {
|
||||
for ($ii = 0; $ii < 10; $ii++) {
|
||||
|
|
|
@ -59,9 +59,6 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
$need_lists = true;
|
||||
$need_projs = true;
|
||||
break;
|
||||
case 'projects':
|
||||
$need_projs = true;
|
||||
break;
|
||||
case 'usersorprojects':
|
||||
case 'accountsorprojects':
|
||||
$need_users = true;
|
||||
|
|
Loading…
Reference in a new issue