1
0
Fork 0
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:
epriestley 2014-07-10 17:28:29 -07:00
parent fc36ec0da1
commit 793eced32d
19 changed files with 96 additions and 43 deletions

View file

@ -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',

View file

@ -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());
}

View file

@ -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,

View file

@ -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))

View file

@ -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))

View file

@ -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/',
);

View file

@ -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/',

View file

@ -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',

View file

@ -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);

View file

@ -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))

View file

@ -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(

View file

@ -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())

View file

@ -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(),
);
}

View file

@ -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())

View file

@ -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;
}
}

View file

@ -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))

View file

@ -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));
}

View file

@ -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++) {

View file

@ -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;