Page MenuHomePhabricator

D7713.id17431.diff
No OneTemporary

D7713.id17431.diff

Index: src/applications/diffusion/controller/DiffusionRepositoryController.php
===================================================================
--- src/applications/diffusion/controller/DiffusionRepositoryController.php
+++ src/applications/diffusion/controller/DiffusionRepositoryController.php
@@ -399,6 +399,18 @@
->setWorkflow(!$can_edit)
->setDisabled(!$can_edit));
+ if ($repository->isHosted()) {
+ $callsign = $repository->getCallsign();
+ $push_uri = $this->getApplicationURI(
+ 'pushlog/?repositories=r'.$callsign);
+
+ $view->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('View Push Logs'))
+ ->setIcon('transcript')
+ ->setHref($push_uri));
+ }
+
return $view;
}
Index: src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
===================================================================
--- src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
+++ src/applications/repository/query/PhabricatorRepositoryPushLogQuery.php
@@ -5,6 +5,7 @@
private $ids;
private $repositoryPHIDs;
+ private $pusherPHIDs;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -16,6 +17,11 @@
return $this;
}
+ public function withPusherPHIDs(array $pusher_phids) {
+ $this->pusherPHIDs = $pusher_phids;
+ return $this;
+ }
+
protected function loadPage() {
$table = new PhabricatorRepositoryPushLog();
$conn_r = $table->establishConnection('r');
@@ -73,6 +79,13 @@
$this->repositoryPHIDs);
}
+ if ($this->pusherPHIDs) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'pusherPHID in (%Ls)',
+ $this->pusherPHIDs);
+ }
+
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
Index: src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php
===================================================================
--- src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php
+++ src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php
@@ -6,12 +6,37 @@
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
+ $saved->setParameter(
+ 'repositoryPHIDs',
+ $this->readPHIDsFromRequest(
+ $request,
+ 'repositories',
+ array(
+ PhabricatorRepositoryPHIDTypeRepository::TYPECONST,
+ )));
+
+ $saved->setParameter(
+ 'pusherPHIDs',
+ $this->readUsersFromRequest(
+ $request,
+ 'pushers'));
+
return $saved;
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new PhabricatorRepositoryPushLogQuery());
+ $repository_phids = $saved->getParameter('repositoryPHIDs');
+ if ($repository_phids) {
+ $query->withRepositoryPHIDs($repository_phids);
+ }
+
+ $pusher_phids = $saved->getParameter('pusherPHIDs');
+ if ($pusher_phids) {
+ $query->withPusherPHIDs($pusher_phids);
+ }
+
return $query;
}
@@ -19,6 +44,38 @@
AphrontFormView $form,
PhabricatorSavedQuery $saved_query) {
+ $repository_phids = $saved_query->getParameter('repositoryPHIDs', array());
+ $pusher_phids = $saved_query->getParameter('pusherPHIDs', array());
+
+ $all_phids = array_merge(
+ $repository_phids,
+ $pusher_phids);
+
+ if ($all_phids) {
+ $handles = id(new PhabricatorHandleQuery())
+ ->setViewer($this->requireViewer())
+ ->withPHIDs($all_phids)
+ ->execute();
+ } else {
+ $handles = array();
+ }
+
+ $repository_handles = array_select_keys($handles, $repository_phids);
+ $pusher_handles = array_select_keys($handles, $pusher_phids);
+
+ $form
+ ->appendChild(
+ id(new AphrontFormTokenizerControl())
+ ->setDatasource('/typeahead/common/repositories/')
+ ->setName('repositories')
+ ->setLabel(pht('Repositories'))
+ ->setValue($repository_handles))
+ ->appendChild(
+ id(new AphrontFormTokenizerControl())
+ ->setDatasource('/typeahead/common/accounts/')
+ ->setName('pushers')
+ ->setLabel(pht('Pushers'))
+ ->setValue($pusher_handles));
}
protected function getURI($path) {
Index: src/applications/search/engine/PhabricatorApplicationSearchEngine.php
===================================================================
--- src/applications/search/engine/PhabricatorApplicationSearchEngine.php
+++ src/applications/search/engine/PhabricatorApplicationSearchEngine.php
@@ -299,6 +299,56 @@
}
+ /**
+ * Read a list of generic PHIDs from a request in a flexible way. Like
+ * @{method:readUsersFromRequest}, this method supports either array or
+ * comma-delimited forms. Objects can be specified either by PHID or by
+ * object name.
+ *
+ * @param AphrontRequest Request to read PHIDs from.
+ * @param string Key to read in the request.
+ * @param list<const> Optional, list of permitted PHID types.
+ * @return list<phid> List of object PHIDs.
+ *
+ * @task read
+ */
+ protected function readPHIDsFromRequest(
+ AphrontRequest $request,
+ $key,
+ array $allow_types = array()) {
+
+ $list = $request->getArr($key, null);
+ if ($list === null) {
+ $list = $request->getStrList($key);
+ }
+
+ if (!$list) {
+ return array();
+ }
+
+ $objects = id(new PhabricatorObjectQuery())
+ ->setViewer($this->requireViewer())
+ ->withNames($list)
+ ->execute();
+ $list = mpull($objects, 'getPHID');
+
+ if (!$list) {
+ return array();
+ }
+
+ // If only certain PHID types are allowed, filter out all the others.
+ if ($allow_types) {
+ $allow_types = array_fuse($allow_types);
+ foreach ($list as $key => $phid) {
+ if (empty($allow_types[phid_get_type($phid)])) {
+ unset($list[$key]);
+ }
+ }
+ }
+
+ return $list;
+ }
+
protected function readBoolFromRequest(
AphrontRequest $request,
$key) {

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 5, 4:32 PM (2 w, 21 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6746755
Default Alt Text
D7713.id17431.diff (6 KB)

Event Timeline