mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-02 10:51:01 +01:00
Project search, plus "Up For Grabs".
Summary: Test Plan: Reviewers: CC:
This commit is contained in:
parent
dc88a04390
commit
fcb4cf57d7
6 changed files with 78 additions and 15 deletions
|
@ -38,6 +38,23 @@ class PhabricatorObjectHandleData {
|
||||||
|
|
||||||
foreach ($types as $type => $phids) {
|
foreach ($types as $type => $phids) {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
|
case '!!!!':
|
||||||
|
// Black magic!
|
||||||
|
foreach ($phids as $phid) {
|
||||||
|
$handle = new PhabricatorObjectHandle();
|
||||||
|
$handle->setPHID($phid);
|
||||||
|
$handle->setType($type);
|
||||||
|
switch ($phid) {
|
||||||
|
case 'PHID-!!!!-UP-FOR-GRABS':
|
||||||
|
$handle->setName('Up For Grabs');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$handle->setName('Foul Magicks');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$handles[$phid] = $handle;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'USER':
|
case 'USER':
|
||||||
$class = 'PhabricatorUser';
|
$class = 'PhabricatorUser';
|
||||||
PhutilSymbolLoader::loadClass($class);
|
PhutilSymbolLoader::loadClass($class);
|
||||||
|
@ -49,12 +66,11 @@ class PhabricatorObjectHandleData {
|
||||||
foreach ($phids as $phid) {
|
foreach ($phids as $phid) {
|
||||||
$handle = new PhabricatorObjectHandle();
|
$handle = new PhabricatorObjectHandle();
|
||||||
$handle->setPHID($phid);
|
$handle->setPHID($phid);
|
||||||
|
$handle->setType($type);
|
||||||
if (empty($users[$phid])) {
|
if (empty($users[$phid])) {
|
||||||
$handle->setType(self::TYPE_UNKNOWN);
|
|
||||||
$handle->setName('Unknown User');
|
$handle->setName('Unknown User');
|
||||||
} else {
|
} else {
|
||||||
$user = $users[$phid];
|
$user = $users[$phid];
|
||||||
$handle->setType($type);
|
|
||||||
$handle->setName($user->getUsername());
|
$handle->setName($user->getUsername());
|
||||||
$handle->setURI('/p/'.$user->getUsername().'/');
|
$handle->setURI('/p/'.$user->getUsername().'/');
|
||||||
$handle->setEmail($user->getEmail());
|
$handle->setEmail($user->getEmail());
|
||||||
|
@ -82,12 +98,11 @@ class PhabricatorObjectHandleData {
|
||||||
foreach ($phids as $phid) {
|
foreach ($phids as $phid) {
|
||||||
$handle = new PhabricatorObjectHandle();
|
$handle = new PhabricatorObjectHandle();
|
||||||
$handle->setPHID($phid);
|
$handle->setPHID($phid);
|
||||||
|
$handle->setType($type);
|
||||||
if (empty($lists[$phid])) {
|
if (empty($lists[$phid])) {
|
||||||
$handle->setType(self::TYPE_UNKNOWN);
|
|
||||||
$handle->setName('Unknown Mailing List');
|
$handle->setName('Unknown Mailing List');
|
||||||
} else {
|
} else {
|
||||||
$list = $lists[$phid];
|
$list = $lists[$phid];
|
||||||
$handle->setType($type);
|
|
||||||
$handle->setEmail($list->getEmail());
|
$handle->setEmail($list->getEmail());
|
||||||
$handle->setName($list->getName());
|
$handle->setName($list->getName());
|
||||||
$handle->setURI($list->getURI());
|
$handle->setURI($list->getURI());
|
||||||
|
@ -107,12 +122,11 @@ class PhabricatorObjectHandleData {
|
||||||
foreach ($phids as $phid) {
|
foreach ($phids as $phid) {
|
||||||
$handle = new PhabricatorObjectHandle();
|
$handle = new PhabricatorObjectHandle();
|
||||||
$handle->setPHID($phid);
|
$handle->setPHID($phid);
|
||||||
|
$handle->setType($type);
|
||||||
if (empty($revs[$phid])) {
|
if (empty($revs[$phid])) {
|
||||||
$handle->setType(self::TYPE_UNKNOWN);
|
|
||||||
$handle->setName('Unknown Revision');
|
$handle->setName('Unknown Revision');
|
||||||
} else {
|
} else {
|
||||||
$rev = $revs[$phid];
|
$rev = $revs[$phid];
|
||||||
$handle->setType($type);
|
|
||||||
$handle->setName($rev->getTitle());
|
$handle->setName($rev->getTitle());
|
||||||
$handle->setURI('/D'.$rev->getID());
|
$handle->setURI('/D'.$rev->getID());
|
||||||
$handle->setFullName('D'.$rev->getID().': '.$rev->getTitle());
|
$handle->setFullName('D'.$rev->getID().': '.$rev->getTitle());
|
||||||
|
@ -131,12 +145,11 @@ class PhabricatorObjectHandleData {
|
||||||
foreach ($phids as $phid) {
|
foreach ($phids as $phid) {
|
||||||
$handle = new PhabricatorObjectHandle();
|
$handle = new PhabricatorObjectHandle();
|
||||||
$handle->setPHID($phid);
|
$handle->setPHID($phid);
|
||||||
|
$handle->setType($type);
|
||||||
if (empty($tasks[$phid])) {
|
if (empty($tasks[$phid])) {
|
||||||
$handle->setType(self::TYPE_UNKNOWN);
|
|
||||||
$handle->setName('Unknown Revision');
|
$handle->setName('Unknown Revision');
|
||||||
} else {
|
} else {
|
||||||
$task = $tasks[$phid];
|
$task = $tasks[$phid];
|
||||||
$handle->setType($type);
|
|
||||||
$handle->setName($task->getTitle());
|
$handle->setName($task->getTitle());
|
||||||
$handle->setURI('/T'.$task->getID());
|
$handle->setURI('/T'.$task->getID());
|
||||||
$handle->setFullName('T'.$task->getID().': '.$task->getTitle());
|
$handle->setFullName('T'.$task->getID().': '.$task->getTitle());
|
||||||
|
@ -155,12 +168,11 @@ class PhabricatorObjectHandleData {
|
||||||
foreach ($phids as $phid) {
|
foreach ($phids as $phid) {
|
||||||
$handle = new PhabricatorObjectHandle();
|
$handle = new PhabricatorObjectHandle();
|
||||||
$handle->setPHID($phid);
|
$handle->setPHID($phid);
|
||||||
|
$handle->setType($type);
|
||||||
if (empty($files[$phid])) {
|
if (empty($files[$phid])) {
|
||||||
$handle->setType(self::TYPE_UNKNOWN);
|
|
||||||
$handle->setName('Unknown File');
|
$handle->setName('Unknown File');
|
||||||
} else {
|
} else {
|
||||||
$file = $files[$phid];
|
$file = $files[$phid];
|
||||||
$handle->setType($type);
|
|
||||||
$handle->setName($file->getName());
|
$handle->setName($file->getName());
|
||||||
$handle->setURI($file->getViewURI());
|
$handle->setURI($file->getViewURI());
|
||||||
}
|
}
|
||||||
|
@ -178,12 +190,11 @@ class PhabricatorObjectHandleData {
|
||||||
foreach ($phids as $phid) {
|
foreach ($phids as $phid) {
|
||||||
$handle = new PhabricatorObjectHandle();
|
$handle = new PhabricatorObjectHandle();
|
||||||
$handle->setPHID($phid);
|
$handle->setPHID($phid);
|
||||||
|
$handle->setType($type);
|
||||||
if (empty($projects[$phid])) {
|
if (empty($projects[$phid])) {
|
||||||
$handle->setType(self::TYPE_UNKNOWN);
|
|
||||||
$handle->setName('Unknown Project');
|
$handle->setName('Unknown Project');
|
||||||
} else {
|
} else {
|
||||||
$project = $projects[$phid];
|
$project = $projects[$phid];
|
||||||
$handle->setType($type);
|
|
||||||
$handle->setName($project->getName());
|
$handle->setName($project->getName());
|
||||||
$handle->setURI('/project/view/'.$project->getID().'/');
|
$handle->setURI('/project/view/'.$project->getID().'/');
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ final class PhabricatorSearchRelationship {
|
||||||
const RELATIONSHIP_SUBSCRIBER = 'subs';
|
const RELATIONSHIP_SUBSCRIBER = 'subs';
|
||||||
const RELATIONSHIP_COMMENTER = 'comm';
|
const RELATIONSHIP_COMMENTER = 'comm';
|
||||||
const RELATIONSHIP_OWNER = 'ownr';
|
const RELATIONSHIP_OWNER = 'ownr';
|
||||||
|
const RELATIONSHIP_PROJECT = 'proj';
|
||||||
|
|
||||||
const RELATIONSHIP_OPEN = 'open';
|
const RELATIONSHIP_OPEN = 'open';
|
||||||
const RELATIONSHIP_TOUCH = 'poke';
|
const RELATIONSHIP_TOUCH = 'poke';
|
||||||
|
|
|
@ -55,6 +55,10 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
|
||||||
$query->setParameter('open', $request->getInt('open'));
|
$query->setParameter('open', $request->getInt('open'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->getArr('project')) {
|
||||||
|
$query->setParameter('project', $request->getArr('project'));
|
||||||
|
}
|
||||||
|
|
||||||
$query->save();
|
$query->save();
|
||||||
return id(new AphrontRedirectResponse())
|
return id(new AphrontRedirectResponse())
|
||||||
->setURI('/search/'.$query->getID().'/');
|
->setURI('/search/'.$query->getID().'/');
|
||||||
|
@ -74,7 +78,8 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
|
||||||
|
|
||||||
$phids = array_merge(
|
$phids = array_merge(
|
||||||
$query->getParameter('author', array()),
|
$query->getParameter('author', array()),
|
||||||
$query->getParameter('owner', array())
|
$query->getParameter('owner', array()),
|
||||||
|
$query->getParameter('project', array())
|
||||||
);
|
);
|
||||||
|
|
||||||
$handles = id(new PhabricatorObjectHandleData($phids))
|
$handles = id(new PhabricatorObjectHandleData($phids))
|
||||||
|
@ -90,6 +95,11 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
|
||||||
$query->getParameter('owner', array()));
|
$query->getParameter('owner', array()));
|
||||||
$owner_value = mpull($owner_value, 'getFullName', 'getPHID');
|
$owner_value = mpull($owner_value, 'getFullName', 'getPHID');
|
||||||
|
|
||||||
|
$project_value = array_select_keys(
|
||||||
|
$handles,
|
||||||
|
$query->getParameter('project', array()));
|
||||||
|
$project_value = mpull($project_value, 'getFullName', 'getPHID');
|
||||||
|
|
||||||
$search_form = new AphrontFormView();
|
$search_form = new AphrontFormView();
|
||||||
$search_form
|
$search_form
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
@ -121,8 +131,16 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
->setName('owner')
|
->setName('owner')
|
||||||
->setLabel('Owner')
|
->setLabel('Owner')
|
||||||
->setDatasource('/typeahead/common/users/')
|
->setDatasource('/typeahead/common/searchowner/')
|
||||||
->setValue($owner_value))
|
->setValue($owner_value)
|
||||||
|
->setCaption(
|
||||||
|
'Tip: search for "Up For Grabs" to find unowned documents.'))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormTokenizerControl())
|
||||||
|
->setName('project')
|
||||||
|
->setLabel('Project')
|
||||||
|
->setDatasource('/typeahead/common/projects/')
|
||||||
|
->setValue($project_value))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormSubmitControl())
|
id(new AphrontFormSubmitControl())
|
||||||
->setValue('Search'));
|
->setValue('Search'));
|
||||||
|
|
|
@ -92,6 +92,12 @@ class PhabricatorSearchMySQLExecutor extends PhabricatorSearchExecutor {
|
||||||
'owner',
|
'owner',
|
||||||
PhabricatorSearchRelationship::RELATIONSHIP_OWNER);
|
PhabricatorSearchRelationship::RELATIONSHIP_OWNER);
|
||||||
|
|
||||||
|
$join[] = $this->joinRelationship(
|
||||||
|
$conn_r,
|
||||||
|
$query,
|
||||||
|
'project',
|
||||||
|
PhabricatorSearchRelationship::RELATIONSHIP_PROJECT);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$join[] = $this->joinRelationship(
|
$join[] = $this->joinRelationship(
|
||||||
$conn_r,
|
$conn_r,
|
||||||
|
|
|
@ -83,12 +83,28 @@ class PhabricatorSearchManiphestIndexer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($task->getProjectPHIDs() as $phid) {
|
||||||
|
$doc->addRelationship(
|
||||||
|
PhabricatorSearchRelationship::RELATIONSHIP_PROJECT,
|
||||||
|
$phid,
|
||||||
|
'PROJ',
|
||||||
|
$task->getDateModified()); // Bogus.
|
||||||
|
}
|
||||||
|
|
||||||
if ($owner && $owner->getNewValue()) {
|
if ($owner && $owner->getNewValue()) {
|
||||||
$doc->addRelationship(
|
$doc->addRelationship(
|
||||||
PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
|
PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
|
||||||
$owner->getNewValue(),
|
$owner->getNewValue(),
|
||||||
'USER',
|
'USER',
|
||||||
$owner->getDateCreated());
|
$owner->getDateCreated());
|
||||||
|
} else {
|
||||||
|
$doc->addRelationship(
|
||||||
|
PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
|
||||||
|
'PHID-!!!!-UP-FOR-GRABS',
|
||||||
|
'!!!!',
|
||||||
|
$owner
|
||||||
|
? $owner->getDateCreated()
|
||||||
|
: $task->getDateCreated());
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($touches as $touch => $time) {
|
foreach ($touches as $touch => $time) {
|
||||||
|
|
|
@ -28,7 +28,11 @@ class PhabricatorTypeaheadCommonDatasourceController
|
||||||
$need_users = false;
|
$need_users = false;
|
||||||
$need_lists = false;
|
$need_lists = false;
|
||||||
$need_projs = false;
|
$need_projs = false;
|
||||||
|
$need_upforgrabs = false;
|
||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
|
case 'searchowner':
|
||||||
|
$need_users = true;
|
||||||
|
$need_upforgrabs = true;
|
||||||
case 'users':
|
case 'users':
|
||||||
$need_users = true;
|
$need_users = true;
|
||||||
break;
|
break;
|
||||||
|
@ -43,6 +47,13 @@ class PhabricatorTypeaheadCommonDatasourceController
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
|
if ($need_upforgrabs) {
|
||||||
|
$data[] = array(
|
||||||
|
'Up For Grabs',
|
||||||
|
null,
|
||||||
|
'PHID-!!!!-UP-FOR-GRABS',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ($need_users) {
|
if ($need_users) {
|
||||||
$users = id(new PhabricatorUser())->loadAll();
|
$users = id(new PhabricatorUser())->loadAll();
|
||||||
|
|
Loading…
Reference in a new issue