diff --git a/resources/sql/autopatches/20190412.herald.01.rebuild.php b/resources/sql/autopatches/20190412.herald.01.rebuild.php new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20190412.herald.01.rebuild.php @@ -0,0 +1,3 @@ +renderHandleList($value)); } + public function getPHIDsAffectedByAction(HeraldActionRecord $record) { + return $record->getTarget(); + } + } diff --git a/src/applications/differential/herald/DifferentialReviewersAddReviewersHeraldAction.php b/src/applications/differential/herald/DifferentialReviewersAddReviewersHeraldAction.php --- a/src/applications/differential/herald/DifferentialReviewersAddReviewersHeraldAction.php +++ b/src/applications/differential/herald/DifferentialReviewersAddReviewersHeraldAction.php @@ -29,4 +29,8 @@ return pht('Add reviewers: %s.', $this->renderHandleList($value)); } + public function getPHIDsAffectedByAction(HeraldActionRecord $record) { + return $record->getTarget(); + } + } diff --git a/src/applications/diffusion/herald/DiffusionAuditorsAddAuditorsHeraldAction.php b/src/applications/diffusion/herald/DiffusionAuditorsAddAuditorsHeraldAction.php --- a/src/applications/diffusion/herald/DiffusionAuditorsAddAuditorsHeraldAction.php +++ b/src/applications/diffusion/herald/DiffusionAuditorsAddAuditorsHeraldAction.php @@ -30,4 +30,8 @@ return pht('Add auditors: %s.', $this->renderHandleList($value)); } + public function getPHIDsAffectedByAction(HeraldActionRecord $record) { + return $record->getTarget(); + } + } diff --git a/src/applications/owners/controller/PhabricatorOwnersDetailController.php b/src/applications/owners/controller/PhabricatorOwnersDetailController.php --- a/src/applications/owners/controller/PhabricatorOwnersDetailController.php +++ b/src/applications/owners/controller/PhabricatorOwnersDetailController.php @@ -144,6 +144,8 @@ $crumbs->addTextCrumb($package->getMonogram()); $crumbs->setBorder(true); + $rules_view = $this->newRulesView($package); + $timeline = $this->buildTransactionTimeline( $package, new PhabricatorOwnersPackageTransactionQuery()); @@ -154,6 +156,7 @@ ->setCurtain($curtain) ->setMainColumn(array( $this->renderPathsTable($paths, $repositories), + $rules_view, $commit_panels, $timeline, )) @@ -345,4 +348,55 @@ 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); + } + } diff --git a/src/applications/subscriptions/herald/PhabricatorSubscriptionsAddSubscribersHeraldAction.php b/src/applications/subscriptions/herald/PhabricatorSubscriptionsAddSubscribersHeraldAction.php --- a/src/applications/subscriptions/herald/PhabricatorSubscriptionsAddSubscribersHeraldAction.php +++ b/src/applications/subscriptions/herald/PhabricatorSubscriptionsAddSubscribersHeraldAction.php @@ -29,4 +29,8 @@ return pht('Add subscribers: %s.', $this->renderHandleList($value)); } + public function getPHIDsAffectedByAction(HeraldActionRecord $record) { + return $record->getTarget(); + } + } diff --git a/src/applications/subscriptions/herald/PhabricatorSubscriptionsRemoveSubscribersHeraldAction.php b/src/applications/subscriptions/herald/PhabricatorSubscriptionsRemoveSubscribersHeraldAction.php --- a/src/applications/subscriptions/herald/PhabricatorSubscriptionsRemoveSubscribersHeraldAction.php +++ b/src/applications/subscriptions/herald/PhabricatorSubscriptionsRemoveSubscribersHeraldAction.php @@ -29,4 +29,8 @@ return pht('Remove subscribers: %s.', $this->renderHandleList($value)); } + public function getPHIDsAffectedByAction(HeraldActionRecord $record) { + return $record->getTarget(); + } + }