1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 13:00:56 +01:00

Don't show un-completeable results in people/project autocomplete

Summary:
Fixes T10285.

  - If a result (like a milestone) has no primary hashtag, try to fill in a secondary hashtag.
  - If we can't find any hashtag, don't return the result.

This produces these behaviors:

  - By default, you can't autocomplete milestones.
  - If you give one a hashtag, you can.

We might want to give milestones "special" hashtags eventually (like `#xyz/33`) but this fixes the confusing/broken behavior in the UI and we can wait for a better use case for letting you autocomplete milestones, I think.

Also, don't try to cycle hashtags when renaming milestones. This was a little inconsistent before.

Test Plan:
  - Autocompleted normal projects.
  - Autocompleted milestones with explicit hashtags.
  - No autocomplete entry for milestones with no special hashtags.
  - Used normal typeahead to get tag-less milestones to make sure I didn't break anything.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10285

Differential Revision: https://secure.phabricator.com/D15261
This commit is contained in:
epriestley 2016-02-12 09:05:05 -08:00
parent 2f054edfa2
commit 68d05934a7
3 changed files with 29 additions and 6 deletions

View file

@ -169,11 +169,12 @@ final class PhabricatorProjectTransactionEditor
case PhabricatorProjectTransaction::TYPE_NAME:
// First, add the old name as a secondary slug; this is helpful
// for renames and generally a good thing to do.
if ($old !== null) {
$this->addSlug($object, $old, false);
if (!$this->getIsMilestone()) {
if ($old !== null) {
$this->addSlug($object, $old, false);
}
$this->addSlug($object, $new, false);
}
$this->addSlug($object, $new, false);
return;
case PhabricatorProjectTransaction::TYPE_SLUGS:
$old = $xaction->getOldValue();

View file

@ -38,6 +38,8 @@ final class PhabricatorProjectDatasource
$query->withIsMilestone(false);
}
$for_autocomplete = $this->getParameter('autocomplete');
$projs = $this->executeQuery($query);
$projs = mpull($projs, null, 'getPHID');
@ -58,6 +60,23 @@ final class PhabricatorProjectDatasource
if (!isset($has_cols[$proj->getPHID()])) {
continue;
}
$slug = $proj->getPrimarySlug();
if (!strlen($slug)) {
foreach ($proj->getSlugs() as $slug_object) {
$slug = $slug_object->getSlug();
if (strlen($slug)) {
break;
}
}
}
// If we're building results for the autocompleter and this project
// doesn't have any usable slugs, don't return it as a result.
if ($for_autocomplete && !strlen($slug)) {
continue;
}
$closed = null;
if ($proj->isArchived()) {
$closed = pht('Archived');
@ -78,7 +97,6 @@ final class PhabricatorProjectDatasource
->setPriorityType('proj')
->setClosed($closed);
$slug = $proj->getPrimarySlug();
if (strlen($slug)) {
$proj_result->setAutocomplete('#'.$slug);
}

View file

@ -45,7 +45,11 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
$root_id = celerity_generate_unique_node_id();
$user_datasource = new PhabricatorPeopleDatasource();
$proj_datasource = new PhabricatorProjectDatasource();
$proj_datasource = id(new PhabricatorProjectDatasource())
->setParameters(
array(
'autocomplete' => 1,
));
Javelin::initBehavior(
'phabricator-remarkup-assist',