1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Index and show Owners packages affected by Herald rules

Summary:
Depends on D20412. See PHI1147.

  - Index the targets of "Add Reviewer", "Add Blocking Reviewer", "Add Auditor", "Add Subscriber", and "Remove Subscriber" Herald rules. My major goal is to get Owners packages. This will also hit projects/users, but we just don't read those edges (for now, at least).
  - Add a "Related Herald Rules" panel to Owners Package pages.
  - Add a migration to reindex Herald rules for the recent build plan stuff and this, now that such a migration is easy to write.

Test Plan:
Ran migration, verified all rules reindexed.

{F6372695}

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Differential Revision: https://secure.phabricator.com/D20413
This commit is contained in:
epriestley 2019-04-12 16:09:38 -07:00
parent 4eab3c4c8d
commit 4b8a67ccde
7 changed files with 77 additions and 0 deletions

View file

@ -0,0 +1,3 @@
<?php
PhabricatorRebuildIndexesWorker::rebuildObjectsWithQuery('HeraldRuleQuery');

View file

@ -29,4 +29,8 @@ final class DifferentialReviewersAddBlockingReviewersHeraldAction
return pht('Add blocking reviewers: %s.', $this->renderHandleList($value)); return pht('Add blocking reviewers: %s.', $this->renderHandleList($value));
} }
public function getPHIDsAffectedByAction(HeraldActionRecord $record) {
return $record->getTarget();
}
} }

View file

@ -29,4 +29,8 @@ final class DifferentialReviewersAddReviewersHeraldAction
return pht('Add reviewers: %s.', $this->renderHandleList($value)); return pht('Add reviewers: %s.', $this->renderHandleList($value));
} }
public function getPHIDsAffectedByAction(HeraldActionRecord $record) {
return $record->getTarget();
}
} }

View file

@ -30,4 +30,8 @@ final class DiffusionAuditorsAddAuditorsHeraldAction
return pht('Add auditors: %s.', $this->renderHandleList($value)); return pht('Add auditors: %s.', $this->renderHandleList($value));
} }
public function getPHIDsAffectedByAction(HeraldActionRecord $record) {
return $record->getTarget();
}
} }

View file

@ -144,6 +144,8 @@ final class PhabricatorOwnersDetailController
$crumbs->addTextCrumb($package->getMonogram()); $crumbs->addTextCrumb($package->getMonogram());
$crumbs->setBorder(true); $crumbs->setBorder(true);
$rules_view = $this->newRulesView($package);
$timeline = $this->buildTransactionTimeline( $timeline = $this->buildTransactionTimeline(
$package, $package,
new PhabricatorOwnersPackageTransactionQuery()); new PhabricatorOwnersPackageTransactionQuery());
@ -154,6 +156,7 @@ final class PhabricatorOwnersDetailController
->setCurtain($curtain) ->setCurtain($curtain)
->setMainColumn(array( ->setMainColumn(array(
$this->renderPathsTable($paths, $repositories), $this->renderPathsTable($paths, $repositories),
$rules_view,
$commit_panels, $commit_panels,
$timeline, $timeline,
)) ))
@ -345,4 +348,55 @@ final class PhabricatorOwnersDetailController
return $box; return $box;
} }
private function newRulesView(PhabricatorOwnersPackage $package) {
$viewer = $this->getViewer();
$limit = 10;
$rules = id(new HeraldRuleQuery())
->setViewer($viewer)
->withDisabled(false)
->withAffectedObjectPHIDs(array($package->getPHID()))
->needValidateAuthors(true)
->setLimit($limit + 1)
->execute();
$more_results = (count($rules) > $limit);
$rules = array_slice($rules, 0, $limit);
$list = id(new HeraldRuleListView())
->setViewer($viewer)
->setRules($rules)
->newObjectList();
$list->setNoDataString(
pht(
'No active Herald rules add this package as an auditor, reviewer, '.
'or subscriber.'));
$more_href = new PhutilURI(
'/herald/',
array('affectedPHID' => $package->getPHID()));
if ($more_results) {
$list->newTailButton()
->setHref($more_href);
}
$more_link = id(new PHUIButtonView())
->setTag('a')
->setIcon('fa-list-ul')
->setText(pht('View All Rules'))
->setHref($more_href);
$header = id(new PHUIHeaderView())
->setHeader(pht('Affected By Herald Rules'))
->setHeaderIcon(id(new PhabricatorHeraldApplication())->getIcon())
->addActionLink($more_link);
return id(new PHUIObjectBoxView())
->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->appendChild($list);
}
} }

View file

@ -29,4 +29,8 @@ final class PhabricatorSubscriptionsAddSubscribersHeraldAction
return pht('Add subscribers: %s.', $this->renderHandleList($value)); return pht('Add subscribers: %s.', $this->renderHandleList($value));
} }
public function getPHIDsAffectedByAction(HeraldActionRecord $record) {
return $record->getTarget();
}
} }

View file

@ -29,4 +29,8 @@ final class PhabricatorSubscriptionsRemoveSubscribersHeraldAction
return pht('Remove subscribers: %s.', $this->renderHandleList($value)); return pht('Remove subscribers: %s.', $this->renderHandleList($value));
} }
public function getPHIDsAffectedByAction(HeraldActionRecord $record) {
return $record->getTarget();
}
} }