1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01: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',
'PhabricatorSubscribableInterface',
'PhabricatorNgramsInterface',
'PhabricatorProjectInterface',
),
'HarbormasterBuildPlanDatasource' => 'PhabricatorTypeaheadDatasource',
'HarbormasterBuildPlanDefaultEditCapability' => 'PhabricatorPolicyCapability',

View file

@ -84,12 +84,24 @@ final class HarbormasterBuildPlanSearchEngine
$viewer = $this->requireViewer();
if ($plans) {
$edge_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(mpull($plans, 'getPHID'))
->withEdgeTypes(
array(
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
));
$edge_query->execute();
}
$list = new PHUIObjectItemListView();
foreach ($plans as $plan) {
$id = $plan->getID();
$item = id(new PHUIObjectItemView())
->setObjectName(pht('Plan %d', $plan->getID()))
->setObjectName(pht('Plan %d', $id))
->setHeader($plan->getName());
if ($plan->isDisabled()) {
@ -102,6 +114,17 @@ final class HarbormasterBuildPlanSearchEngine
$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);
}

View file

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

View file

@ -53,7 +53,7 @@ final class PHUIHandleTagListView extends AphrontTagView {
$handles = $this->handles;
// If the list is empty, we may render a "No Projects" tag.
if (!$handles) {
if (!count($handles)) {
if (strlen($this->noDataString)) {
$no_data_tag = $this->newPlaceholderTag()
->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);
}