Clean up ancestor path implementation.
* mpull for cleaner ancestor access * move implementation to PhabricatorProject * as new function getDisplayNameWithAncestorPath * no pht usage, since there are no localisable items
This commit is contained in:
@@ -585,6 +585,18 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
|||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDisplayNameWithAncestorPath() {
|
||||||
|
// Figure out the ancestors for this project
|
||||||
|
// so that we can prepend that to the display name.
|
||||||
|
$ancestors = mpull(array_reverse($this->getAncestorProjects()), 'getName');
|
||||||
|
$ancestors[] = $this->getName();
|
||||||
|
|
||||||
|
$project_name_with_path = implode(' > ', $ancestors);
|
||||||
|
|
||||||
|
// no pht usage, since we don't have translatable items.
|
||||||
|
return $project_name_with_path;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDisplayIconKey() {
|
public function getDisplayIconKey() {
|
||||||
if ($this->isMilestone()) {
|
if ($this->isMilestone()) {
|
||||||
$key = PhabricatorProjectIconSet::getMilestoneIconKey();
|
$key = PhabricatorProjectIconSet::getMilestoneIconKey();
|
||||||
|
|||||||
@@ -105,18 +105,6 @@ final class PhabricatorProjectDatasource
|
|||||||
|
|
||||||
$all_strings = array();
|
$all_strings = array();
|
||||||
|
|
||||||
// Figure out the ancestors for this project
|
|
||||||
// so that we can prepend that to the display name.
|
|
||||||
$ancestors = array_reverse($proj->getAncestorProjects());
|
|
||||||
$ancestor_strings = array();
|
|
||||||
foreach ($ancestors as $ancestor) {
|
|
||||||
$ancestor_strings[] = $ancestor->getName();
|
|
||||||
}
|
|
||||||
$ancestor_strings = implode(' > ', $ancestor_strings);
|
|
||||||
if (strlen($ancestor_strings) > 0) {
|
|
||||||
$ancestor_strings = $ancestor_strings.' > ';
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: We list the project's name first because results will be
|
// NOTE: We list the project's name first because results will be
|
||||||
// sorted into prefix vs content phases incorrectly if we don't: it
|
// sorted into prefix vs content phases incorrectly if we don't: it
|
||||||
// will look like "Parent (Milestone)" matched "Parent" as a prefix,
|
// will look like "Parent (Milestone)" matched "Parent" as a prefix,
|
||||||
@@ -135,7 +123,7 @@ final class PhabricatorProjectDatasource
|
|||||||
|
|
||||||
$proj_result = id(new PhabricatorTypeaheadResult())
|
$proj_result = id(new PhabricatorTypeaheadResult())
|
||||||
->setName($all_strings)
|
->setName($all_strings)
|
||||||
->setDisplayName($ancestor_strings.$proj->getDisplayName())
|
->setDisplayName($proj->getDisplayNameWithAncestorPath())
|
||||||
->setDisplayType($proj->getDisplayIconName())
|
->setDisplayType($proj->getDisplayIconName())
|
||||||
->setURI($proj->getURI())
|
->setURI($proj->getURI())
|
||||||
->setPHID($phid)
|
->setPHID($phid)
|
||||||
|
|||||||
Reference in New Issue
Block a user