mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Do author PHID lookups in Diffusion views.
This commit is contained in:
parent
7140107ed9
commit
e4cd939734
8 changed files with 91 additions and 6 deletions
|
@ -31,6 +31,17 @@ class DiffusionHistoryController extends DiffusionController {
|
|||
$history_query->setLimit($page_size + 1);
|
||||
$history = $history_query->loadHistory();
|
||||
|
||||
$phids = array();
|
||||
foreach ($history as $item) {
|
||||
$data = $item->getCommitData();
|
||||
if ($data) {
|
||||
if ($data->getCommitDetail('authorPHID')) {
|
||||
$phids[] = $data->getCommitDetail('authorPHID');
|
||||
}
|
||||
}
|
||||
}
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||
|
||||
$pager = new AphrontPagerView();
|
||||
$pager->setPageSize($page_size);
|
||||
$pager->setOffset($offset);
|
||||
|
@ -53,6 +64,7 @@ class DiffusionHistoryController extends DiffusionController {
|
|||
|
||||
$history_table = new DiffusionHistoryTableView();
|
||||
$history_table->setDiffusionRequest($drequest);
|
||||
$history_table->setHandles($handles);
|
||||
$history_table->setHistory($history);
|
||||
|
||||
$history_panel = new AphrontPanelView();
|
||||
|
|
|
@ -9,8 +9,11 @@
|
|||
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/history/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/view/historytable');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'view/control/pager');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionHistoryController.php');
|
||||
|
|
|
@ -26,8 +26,16 @@ class DiffusionLastModifiedController extends DiffusionController {
|
|||
$drequest);
|
||||
list($commit, $commit_data) = $modified_query->loadLastModification();
|
||||
|
||||
$phids = array();
|
||||
if ($commit_data->getCommitDetail('authorPHID')) {
|
||||
$phids = array($commit_data->getCommitDetail('authorPHID'));
|
||||
}
|
||||
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||
|
||||
$output = DiffusionBrowseTableView::renderLastModifiedColumns(
|
||||
$drequest->getRepository(),
|
||||
$handles,
|
||||
$commit,
|
||||
$commit_data);
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'aphront/response/ajax');
|
|||
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/lastmodified/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/view/browsetable');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
|
|
@ -29,10 +29,37 @@ class DiffusionRepositoryController extends DiffusionController {
|
|||
$history_query = DiffusionHistoryQuery::newFromDiffusionRequest(
|
||||
$drequest);
|
||||
$history_query->setLimit(15);
|
||||
|
||||
$history = $history_query->loadHistory();
|
||||
|
||||
$browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest);
|
||||
$browse_results = $browse_query->loadPaths();
|
||||
|
||||
$phids = array();
|
||||
|
||||
foreach ($history as $item) {
|
||||
$data = $item->getCommitData();
|
||||
if ($data) {
|
||||
if ($data->getCommitDetail('authorPHID')) {
|
||||
$phids[$data->getCommitDetail('authorPHID')] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($browse_results as $item) {
|
||||
$data = $item->getLastCommitData();
|
||||
if ($data) {
|
||||
if ($data->getCommitDetail('authorPHID')) {
|
||||
$phids[$data->getCommitDetail('authorPHID')] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$phids = array_keys($phids);
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||
|
||||
$history_table = new DiffusionHistoryTableView();
|
||||
$history_table->setDiffusionRequest($drequest);
|
||||
$history_table->setHandles($handles);
|
||||
$history_table->setHistory($history);
|
||||
|
||||
$callsign = $drequest->getRepository()->getCallsign();
|
||||
|
@ -49,12 +76,11 @@ class DiffusionRepositoryController extends DiffusionController {
|
|||
|
||||
$content[] = $panel;
|
||||
|
||||
$browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest);
|
||||
$results = $browse_query->loadPaths();
|
||||
|
||||
$browse_table = new DiffusionBrowseTableView();
|
||||
$browse_table->setDiffusionRequest($drequest);
|
||||
$browse_table->setPaths($results);
|
||||
$browse_table->setHandles($handles);
|
||||
$browse_table->setPaths($browse_results);
|
||||
|
||||
$browse_panel = new AphrontPanelView();
|
||||
$browse_panel->setHeader('Browse Repository');
|
||||
|
|
|
@ -13,9 +13,11 @@ phutil_require_module('phabricator', 'applications/diffusion/query/history/base'
|
|||
phutil_require_module('phabricator', 'applications/diffusion/view/branchtable');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/view/browsetable');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/view/historytable');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionRepositoryController.php');
|
||||
|
|
|
@ -19,14 +19,21 @@
|
|||
final class DiffusionBrowseTableView extends DiffusionView {
|
||||
|
||||
private $paths;
|
||||
private $handles = array();
|
||||
|
||||
public function setPaths(array $paths) {
|
||||
$this->paths = $paths;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHandles(array $handles) {
|
||||
$this->handles = $handles;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function renderLastModifiedColumns(
|
||||
PhabricatorRepository $repository,
|
||||
array $handles,
|
||||
PhabricatorRepositoryCommit $commit = null,
|
||||
PhabricatorRepositoryCommitData $data = null) {
|
||||
|
||||
|
@ -44,7 +51,12 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
}
|
||||
|
||||
if ($data) {
|
||||
$author = phutil_escape_html($data->getAuthorName());
|
||||
$author_phid = $data->getCommitDetail('authorPHID');
|
||||
if ($author_phid && isset($handles[$author_phid])) {
|
||||
$author = $handles[$author_phid]->renderLink();
|
||||
} else {
|
||||
$author = phutil_escape_html($data->getAuthorName());
|
||||
}
|
||||
$details = phutil_escape_html($data->getSummary());
|
||||
} else {
|
||||
$author = '';
|
||||
|
@ -96,6 +108,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
if ($commit) {
|
||||
$dict = self::renderLastModifiedColumns(
|
||||
$repository,
|
||||
$this->handles,
|
||||
$commit,
|
||||
$path->getLastCommitData());
|
||||
} else {
|
||||
|
|
|
@ -19,15 +19,23 @@
|
|||
final class DiffusionHistoryTableView extends DiffusionView {
|
||||
|
||||
private $history;
|
||||
private $handles = array();
|
||||
|
||||
public function setHistory(array $history) {
|
||||
$this->history = $history;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHandles(array $handles) {
|
||||
$this->handles = $handles;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
|
||||
$handles = $this->handles;
|
||||
|
||||
$rows = array();
|
||||
foreach ($this->history as $history) {
|
||||
$epoch = $history->getEpoch();
|
||||
|
@ -40,6 +48,18 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
|||
$time = null;
|
||||
}
|
||||
|
||||
$data = $history->getCommitData();
|
||||
$author_phid = null;
|
||||
if ($data) {
|
||||
$author_phid = $data->getCommitDetail('authorPHID');
|
||||
}
|
||||
|
||||
if ($author_phid && isset($handles[$author_phid])) {
|
||||
$author = $handles[$author_phid]->renderLink();
|
||||
} else {
|
||||
$author = phutil_escape_html($history->getAuthorName());
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
$this->linkBrowse(
|
||||
$drequest->getPath(),
|
||||
|
@ -54,7 +74,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
|||
$history->getFileType()),
|
||||
$date,
|
||||
$time,
|
||||
phutil_escape_html($history->getAuthorName()),
|
||||
$author,
|
||||
phutil_escape_html($history->getSummary()),
|
||||
// TODO: etc etc
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue