mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 17:30:59 +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) {
|
||||
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':
|
||||
$class = 'PhabricatorUser';
|
||||
PhutilSymbolLoader::loadClass($class);
|
||||
|
@ -49,12 +66,11 @@ class PhabricatorObjectHandleData {
|
|||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
$handle->setPHID($phid);
|
||||
$handle->setType($type);
|
||||
if (empty($users[$phid])) {
|
||||
$handle->setType(self::TYPE_UNKNOWN);
|
||||
$handle->setName('Unknown User');
|
||||
} else {
|
||||
$user = $users[$phid];
|
||||
$handle->setType($type);
|
||||
$handle->setName($user->getUsername());
|
||||
$handle->setURI('/p/'.$user->getUsername().'/');
|
||||
$handle->setEmail($user->getEmail());
|
||||
|
@ -82,12 +98,11 @@ class PhabricatorObjectHandleData {
|
|||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
$handle->setPHID($phid);
|
||||
$handle->setType($type);
|
||||
if (empty($lists[$phid])) {
|
||||
$handle->setType(self::TYPE_UNKNOWN);
|
||||
$handle->setName('Unknown Mailing List');
|
||||
} else {
|
||||
$list = $lists[$phid];
|
||||
$handle->setType($type);
|
||||
$handle->setEmail($list->getEmail());
|
||||
$handle->setName($list->getName());
|
||||
$handle->setURI($list->getURI());
|
||||
|
@ -107,12 +122,11 @@ class PhabricatorObjectHandleData {
|
|||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
$handle->setPHID($phid);
|
||||
$handle->setType($type);
|
||||
if (empty($revs[$phid])) {
|
||||
$handle->setType(self::TYPE_UNKNOWN);
|
||||
$handle->setName('Unknown Revision');
|
||||
} else {
|
||||
$rev = $revs[$phid];
|
||||
$handle->setType($type);
|
||||
$handle->setName($rev->getTitle());
|
||||
$handle->setURI('/D'.$rev->getID());
|
||||
$handle->setFullName('D'.$rev->getID().': '.$rev->getTitle());
|
||||
|
@ -131,12 +145,11 @@ class PhabricatorObjectHandleData {
|
|||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
$handle->setPHID($phid);
|
||||
$handle->setType($type);
|
||||
if (empty($tasks[$phid])) {
|
||||
$handle->setType(self::TYPE_UNKNOWN);
|
||||
$handle->setName('Unknown Revision');
|
||||
} else {
|
||||
$task = $tasks[$phid];
|
||||
$handle->setType($type);
|
||||
$handle->setName($task->getTitle());
|
||||
$handle->setURI('/T'.$task->getID());
|
||||
$handle->setFullName('T'.$task->getID().': '.$task->getTitle());
|
||||
|
@ -155,12 +168,11 @@ class PhabricatorObjectHandleData {
|
|||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
$handle->setPHID($phid);
|
||||
$handle->setType($type);
|
||||
if (empty($files[$phid])) {
|
||||
$handle->setType(self::TYPE_UNKNOWN);
|
||||
$handle->setName('Unknown File');
|
||||
} else {
|
||||
$file = $files[$phid];
|
||||
$handle->setType($type);
|
||||
$handle->setName($file->getName());
|
||||
$handle->setURI($file->getViewURI());
|
||||
}
|
||||
|
@ -178,12 +190,11 @@ class PhabricatorObjectHandleData {
|
|||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
$handle->setPHID($phid);
|
||||
$handle->setType($type);
|
||||
if (empty($projects[$phid])) {
|
||||
$handle->setType(self::TYPE_UNKNOWN);
|
||||
$handle->setName('Unknown Project');
|
||||
} else {
|
||||
$project = $projects[$phid];
|
||||
$handle->setType($type);
|
||||
$handle->setName($project->getName());
|
||||
$handle->setURI('/project/view/'.$project->getID().'/');
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ final class PhabricatorSearchRelationship {
|
|||
const RELATIONSHIP_SUBSCRIBER = 'subs';
|
||||
const RELATIONSHIP_COMMENTER = 'comm';
|
||||
const RELATIONSHIP_OWNER = 'ownr';
|
||||
const RELATIONSHIP_PROJECT = 'proj';
|
||||
|
||||
const RELATIONSHIP_OPEN = 'open';
|
||||
const RELATIONSHIP_TOUCH = 'poke';
|
||||
|
|
|
@ -55,6 +55,10 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
|
|||
$query->setParameter('open', $request->getInt('open'));
|
||||
}
|
||||
|
||||
if ($request->getArr('project')) {
|
||||
$query->setParameter('project', $request->getArr('project'));
|
||||
}
|
||||
|
||||
$query->save();
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/search/'.$query->getID().'/');
|
||||
|
@ -74,7 +78,8 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
|
|||
|
||||
$phids = array_merge(
|
||||
$query->getParameter('author', array()),
|
||||
$query->getParameter('owner', array())
|
||||
$query->getParameter('owner', array()),
|
||||
$query->getParameter('project', array())
|
||||
);
|
||||
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))
|
||||
|
@ -90,6 +95,11 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
|
|||
$query->getParameter('owner', array()));
|
||||
$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
|
||||
->setUser($user)
|
||||
|
@ -121,8 +131,16 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
|
|||
id(new AphrontFormTokenizerControl())
|
||||
->setName('owner')
|
||||
->setLabel('Owner')
|
||||
->setDatasource('/typeahead/common/users/')
|
||||
->setValue($owner_value))
|
||||
->setDatasource('/typeahead/common/searchowner/')
|
||||
->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(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue('Search'));
|
||||
|
|
|
@ -92,6 +92,12 @@ class PhabricatorSearchMySQLExecutor extends PhabricatorSearchExecutor {
|
|||
'owner',
|
||||
PhabricatorSearchRelationship::RELATIONSHIP_OWNER);
|
||||
|
||||
$join[] = $this->joinRelationship(
|
||||
$conn_r,
|
||||
$query,
|
||||
'project',
|
||||
PhabricatorSearchRelationship::RELATIONSHIP_PROJECT);
|
||||
|
||||
/*
|
||||
$join[] = $this->joinRelationship(
|
||||
$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()) {
|
||||
$doc->addRelationship(
|
||||
PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
|
||||
$owner->getNewValue(),
|
||||
'USER',
|
||||
$owner->getDateCreated());
|
||||
} else {
|
||||
$doc->addRelationship(
|
||||
PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
|
||||
'PHID-!!!!-UP-FOR-GRABS',
|
||||
'!!!!',
|
||||
$owner
|
||||
? $owner->getDateCreated()
|
||||
: $task->getDateCreated());
|
||||
}
|
||||
|
||||
foreach ($touches as $touch => $time) {
|
||||
|
|
|
@ -28,7 +28,11 @@ class PhabricatorTypeaheadCommonDatasourceController
|
|||
$need_users = false;
|
||||
$need_lists = false;
|
||||
$need_projs = false;
|
||||
$need_upforgrabs = false;
|
||||
switch ($this->type) {
|
||||
case 'searchowner':
|
||||
$need_users = true;
|
||||
$need_upforgrabs = true;
|
||||
case 'users':
|
||||
$need_users = true;
|
||||
break;
|
||||
|
@ -43,6 +47,13 @@ class PhabricatorTypeaheadCommonDatasourceController
|
|||
|
||||
$data = array();
|
||||
|
||||
if ($need_upforgrabs) {
|
||||
$data[] = array(
|
||||
'Up For Grabs',
|
||||
null,
|
||||
'PHID-!!!!-UP-FOR-GRABS',
|
||||
);
|
||||
}
|
||||
|
||||
if ($need_users) {
|
||||
$users = id(new PhabricatorUser())->loadAll();
|
||||
|
|
Loading…
Reference in a new issue