mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
Give Owners packages the "O" monogram
Summary: Ref T10939. This isn't ideal because it's easy to confuse with zero ("O" vs "0") but I think this will mostly be read-only so it's probably one of the least-bad uses we could make of "O". We haven't really gotten into trouble with "I" (vs "1") for initiatives. Still, open to better ideas. The goal here is to allow commit messages to include packages in some reasonable way, like `Reviewers: O123 Package Name, epriestley, alincoln`. The parser will ignore the "Package Name" part, that's just for humans. And I don't expect humans to type this, but when the use `arc diff --edit` or similar to update an //existing// revision, the reviewer needs to be represented somehow. It also needs to appear in the commit messages that `arc land` finalizes somehow. I didn't hook up `/O123` as a URI, but this should do everything else I think. Test Plan: - Viewed package list. - Viewed package detail. - Did global search for `O12`. - Used `O12` and `{O12}` remarkup rules. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10939 Differential Revision: https://secure.phabricator.com/D15910
This commit is contained in:
parent
44057ad269
commit
9abc16df4d
7 changed files with 69 additions and 3 deletions
|
@ -2833,6 +2833,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorOwnersPackageOwnerDatasource' => 'applications/owners/typeahead/PhabricatorOwnersPackageOwnerDatasource.php',
|
||||
'PhabricatorOwnersPackagePHIDType' => 'applications/owners/phid/PhabricatorOwnersPackagePHIDType.php',
|
||||
'PhabricatorOwnersPackageQuery' => 'applications/owners/query/PhabricatorOwnersPackageQuery.php',
|
||||
'PhabricatorOwnersPackageRemarkupRule' => 'applications/owners/remarkup/PhabricatorOwnersPackageRemarkupRule.php',
|
||||
'PhabricatorOwnersPackageSearchEngine' => 'applications/owners/query/PhabricatorOwnersPackageSearchEngine.php',
|
||||
'PhabricatorOwnersPackageTestCase' => 'applications/owners/storage/__tests__/PhabricatorOwnersPackageTestCase.php',
|
||||
'PhabricatorOwnersPackageTransaction' => 'applications/owners/storage/PhabricatorOwnersPackageTransaction.php',
|
||||
|
@ -7411,6 +7412,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorOwnersPackageOwnerDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||
'PhabricatorOwnersPackagePHIDType' => 'PhabricatorPHIDType',
|
||||
'PhabricatorOwnersPackageQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhabricatorOwnersPackageRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||
'PhabricatorOwnersPackageSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'PhabricatorOwnersPackageTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorOwnersPackageTransaction' => 'PhabricatorApplicationTransaction',
|
||||
|
|
|
@ -39,6 +39,12 @@ final class PhabricatorOwnersApplication extends PhabricatorApplication {
|
|||
return self::GROUP_UTILITIES;
|
||||
}
|
||||
|
||||
public function getRemarkupRules() {
|
||||
return array(
|
||||
new PhabricatorOwnersPackageRemarkupRule(),
|
||||
);
|
||||
}
|
||||
|
||||
public function getRoutes() {
|
||||
return array(
|
||||
'/owners/' => array(
|
||||
|
|
|
@ -144,7 +144,7 @@ final class PhabricatorOwnersDetailController
|
|||
}
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb($package->getName());
|
||||
$crumbs->addTextCrumb($package->getMonogram());
|
||||
$crumbs->setBorder(true);
|
||||
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
|
|
|
@ -36,12 +36,47 @@ final class PhabricatorOwnersPackagePHIDType extends PhabricatorPHIDType {
|
|||
foreach ($handles as $phid => $handle) {
|
||||
$package = $objects[$phid];
|
||||
|
||||
$monogram = $package->getMonogram();
|
||||
$name = $package->getName();
|
||||
$id = $package->getID();
|
||||
|
||||
$handle->setName($name);
|
||||
$handle->setName($monogram);
|
||||
$handle->setFullName("{$monogram}: {$name}");
|
||||
$handle->setURI("/owners/package/{$id}/");
|
||||
|
||||
if ($package->isArchived()) {
|
||||
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function canLoadNamedObject($name) {
|
||||
return preg_match('/^O\d*[1-9]\d*$/i', $name);
|
||||
}
|
||||
|
||||
public function loadNamedObjects(
|
||||
PhabricatorObjectQuery $query,
|
||||
array $names) {
|
||||
|
||||
$id_map = array();
|
||||
foreach ($names as $name) {
|
||||
$id = (int)substr($name, 1);
|
||||
$id_map[$id][] = $name;
|
||||
}
|
||||
|
||||
$objects = id(new PhabricatorOwnersPackageQuery())
|
||||
->setViewer($query->getViewer())
|
||||
->withIDs(array_keys($id_map))
|
||||
->execute();
|
||||
|
||||
$results = array();
|
||||
foreach ($objects as $id => $object) {
|
||||
foreach (idx($id_map, $id, array()) as $name) {
|
||||
$results[$name] = $object;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ final class PhabricatorOwnersPackageSearchEngine
|
|||
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setObject($package)
|
||||
->setObjectName(pht('Package %d', $id))
|
||||
->setObjectName($package->getMonogram())
|
||||
->setHeader($package->getName())
|
||||
->setHref('/owners/package/'.$id.'/');
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorOwnersPackageRemarkupRule
|
||||
extends PhabricatorObjectRemarkupRule {
|
||||
|
||||
protected function getObjectNamePrefix() {
|
||||
return 'O';
|
||||
}
|
||||
|
||||
protected function loadObjects(array $ids) {
|
||||
$viewer = $this->getEngine()->getConfig('viewer');
|
||||
|
||||
return id(new PhabricatorOwnersPackageQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs($ids)
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
|
@ -289,6 +289,10 @@ final class PhabricatorOwnersPackage
|
|||
return isset($owner_phids[$phid]);
|
||||
}
|
||||
|
||||
public function getMonogram() {
|
||||
return 'O'.$this->getID();
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue