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

Typeahead, handle and herald integration for packages.

This commit is contained in:
epriestley 2011-04-03 22:23:31 -07:00
parent 66388e87d8
commit e407b2311e
5 changed files with 58 additions and 2 deletions

View file

@ -445,10 +445,11 @@ class HeraldRuleController extends HeraldController {
'source' => array( 'source' => array(
'email' => '/typeahead/common/mailable/', 'email' => '/typeahead/common/mailable/',
'user' => '/typeahead/common/users/', 'user' => '/typeahead/common/users/',
'repository' => '/typeahead/common/repository/', 'repository' => '/typeahead/common/repositories/',
'package' => '/typeahead/common/packages/',
/* /*
'tag' => '/datasource/tag/', 'tag' => '/datasource/tag/',
'package' => '/datasource/package/',
*/ */
), ),
'markup' => $template, 'markup' => $template,

View file

@ -28,6 +28,7 @@ final class PhabricatorPHIDConstants {
const PHID_TYPE_MAGIC = '!!!!'; const PHID_TYPE_MAGIC = '!!!!';
const PHID_TYPE_REPO = 'REPO'; const PHID_TYPE_REPO = 'REPO';
const PHID_TYPE_CMIT = 'CMIT'; const PHID_TYPE_CMIT = 'CMIT';
const PHID_TYPE_OPKG = 'OPKG';
public static function getTypes() { public static function getTypes() {
return array( return array(

View file

@ -223,6 +223,28 @@ class PhabricatorObjectHandleData {
$handles[$phid] = $handle; $handles[$phid] = $handle;
} }
break; break;
case PhabricatorPHIDConstants::PHID_TYPE_OPKG:
$class = 'PhabricatorOwnersPackage';
PhutilSymbolLoader::loadClass($class);
$object = newv($class, array());
$packages = $object->loadAllWhere('phid in (%Ls)', $phids);
$packages = mpull($packages, null, 'getPHID');
foreach ($phids as $phid) {
$handle = new PhabricatorObjectHandle();
$handle->setPHID($phid);
$handle->setType($type);
if (empty($packages[$phid])) {
$handle->setName('Unknown Package');
} else {
$package = $packages[$phid];
$handle->setName($package->getName());
$handle->setURI('/owners/package/'.$package->getID().'/');
}
$handles[$phid] = $handle;
}
break;
default: default:
$loader = null; $loader = null;
if (isset($external_loaders[$type])) { if (isset($external_loaders[$type])) {

View file

@ -28,6 +28,8 @@ class PhabricatorTypeaheadCommonDatasourceController
$need_users = false; $need_users = false;
$need_lists = false; $need_lists = false;
$need_projs = false; $need_projs = false;
$need_repos = false;
$need_packages = false;
$need_upforgrabs = false; $need_upforgrabs = false;
switch ($this->type) { switch ($this->type) {
case 'searchowner': case 'searchowner':
@ -43,6 +45,12 @@ class PhabricatorTypeaheadCommonDatasourceController
case 'projects': case 'projects':
$need_projs = true; $need_projs = true;
break; break;
case 'repositories':
$need_repos = true;
break;
case 'packages':
$need_packages = true;
break;
} }
$data = array(); $data = array();
@ -88,6 +96,28 @@ class PhabricatorTypeaheadCommonDatasourceController
} }
} }
if ($need_repos) {
$repos = id(new PhabricatorRepository())->loadAll();
foreach ($repos as $repo) {
$data[] = array(
'r'.$repo->getCallsign().' ('.$repo->getName().')',
'/diffusion/'.$repo->getCallsign().'/',
$repo->getPHID(),
);
}
}
if ($need_packages) {
$packages = id(new PhabricatorOwnersPackage())->loadAll();
foreach ($packages as $package) {
$data[] = array(
$package->getName(),
'/owners/package/'.$package->getID().'/',
$package->getPHID(),
);
}
}
return id(new AphrontAjaxResponse()) return id(new AphrontAjaxResponse())
->setContent($data); ->setContent($data);
} }

View file

@ -8,8 +8,10 @@
phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'applications/metamta/storage/mailinglist'); phutil_require_module('phabricator', 'applications/metamta/storage/mailinglist');
phutil_require_module('phabricator', 'applications/owners/storage/package');
phutil_require_module('phabricator', 'applications/people/storage/user'); phutil_require_module('phabricator', 'applications/people/storage/user');
phutil_require_module('phabricator', 'applications/project/storage/project'); phutil_require_module('phabricator', 'applications/project/storage/project');
phutil_require_module('phabricator', 'applications/repository/storage/repository');
phutil_require_module('phabricator', 'applications/typeahead/controller/base'); phutil_require_module('phabricator', 'applications/typeahead/controller/base');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');