1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Allow Harbormaster build plans to be tagged with projects and searched by tag

Summary: Ref T10457. This is mostly just for consitency, but I imagine it will make managing large/complex build processes easier, and if we support Herald rules it would eventually let you write "Build plan's tags include [whatever]" to apply behavior to a group of plans.

Test Plan: {F1133107}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10457

Differential Revision: https://secure.phabricator.com/D15360
This commit is contained in:
epriestley 2016-02-27 09:19:20 -08:00
parent f078fd98d7
commit 5512e9724f
4 changed files with 32 additions and 4 deletions

View file

@ -5201,6 +5201,7 @@ phutil_register_library_map(array(
'PhabricatorPolicyInterface', 'PhabricatorPolicyInterface',
'PhabricatorSubscribableInterface', 'PhabricatorSubscribableInterface',
'PhabricatorNgramsInterface', 'PhabricatorNgramsInterface',
'PhabricatorProjectInterface',
), ),
'HarbormasterBuildPlanDatasource' => 'PhabricatorTypeaheadDatasource', 'HarbormasterBuildPlanDatasource' => 'PhabricatorTypeaheadDatasource',
'HarbormasterBuildPlanDefaultEditCapability' => 'PhabricatorPolicyCapability', 'HarbormasterBuildPlanDefaultEditCapability' => 'PhabricatorPolicyCapability',

View file

@ -84,12 +84,24 @@ final class HarbormasterBuildPlanSearchEngine
$viewer = $this->requireViewer(); $viewer = $this->requireViewer();
if ($plans) {
$edge_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(mpull($plans, 'getPHID'))
->withEdgeTypes(
array(
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
));
$edge_query->execute();
}
$list = new PHUIObjectItemListView(); $list = new PHUIObjectItemListView();
foreach ($plans as $plan) { foreach ($plans as $plan) {
$id = $plan->getID(); $id = $plan->getID();
$item = id(new PHUIObjectItemView()) $item = id(new PHUIObjectItemView())
->setObjectName(pht('Plan %d', $plan->getID())) ->setObjectName(pht('Plan %d', $id))
->setHeader($plan->getName()); ->setHeader($plan->getName());
if ($plan->isDisabled()) { if ($plan->isDisabled()) {
@ -102,6 +114,17 @@ final class HarbormasterBuildPlanSearchEngine
$item->setHref($this->getApplicationURI("plan/{$id}/")); $item->setHref($this->getApplicationURI("plan/{$id}/"));
$phid = $plan->getPHID();
$project_phids = $edge_query->getDestinationPHIDs(array($phid));
$project_handles = $viewer->loadHandles($project_phids);
$item->addAttribute(
id(new PHUIHandleTagListView())
->setLimit(4)
->setNoDataString(pht('No Projects'))
->setSlim(true)
->setHandles($project_handles));
$list->addItem($item); $list->addItem($item);
} }

View file

@ -8,7 +8,8 @@ final class HarbormasterBuildPlan extends HarbormasterDAO
PhabricatorApplicationTransactionInterface, PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface, PhabricatorPolicyInterface,
PhabricatorSubscribableInterface, PhabricatorSubscribableInterface,
PhabricatorNgramsInterface { PhabricatorNgramsInterface,
PhabricatorProjectInterface {
protected $name; protected $name;
protected $planStatus; protected $planStatus;

View file

@ -53,7 +53,7 @@ final class PHUIHandleTagListView extends AphrontTagView {
$handles = $this->handles; $handles = $this->handles;
// If the list is empty, we may render a "No Projects" tag. // If the list is empty, we may render a "No Projects" tag.
if (!$handles) { if (!count($handles)) {
if (strlen($this->noDataString)) { if (strlen($this->noDataString)) {
$no_data_tag = $this->newPlaceholderTag() $no_data_tag = $this->newPlaceholderTag()
->setName($this->noDataString); ->setName($this->noDataString);
@ -61,7 +61,10 @@ final class PHUIHandleTagListView extends AphrontTagView {
} }
} }
if ($this->limit) { if ($this->limit && ($this->limit > count($handles))) {
if (!is_array($handles)) {
$handles = iterator_to_array($handles);
}
$handles = array_slice($handles, 0, $this->limit); $handles = array_slice($handles, 0, $this->limit);
} }