mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-13 02:12:41 +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_query->setLimit($page_size + 1);
|
||||||
$history = $history_query->loadHistory();
|
$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 = new AphrontPagerView();
|
||||||
$pager->setPageSize($page_size);
|
$pager->setPageSize($page_size);
|
||||||
$pager->setOffset($offset);
|
$pager->setOffset($offset);
|
||||||
|
@ -53,6 +64,7 @@ class DiffusionHistoryController extends DiffusionController {
|
||||||
|
|
||||||
$history_table = new DiffusionHistoryTableView();
|
$history_table = new DiffusionHistoryTableView();
|
||||||
$history_table->setDiffusionRequest($drequest);
|
$history_table->setDiffusionRequest($drequest);
|
||||||
|
$history_table->setHandles($handles);
|
||||||
$history_table->setHistory($history);
|
$history_table->setHistory($history);
|
||||||
|
|
||||||
$history_panel = new AphrontPanelView();
|
$history_panel = new AphrontPanelView();
|
||||||
|
|
|
@ -9,8 +9,11 @@
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/query/history/base');
|
phutil_require_module('phabricator', 'applications/diffusion/query/history/base');
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/view/historytable');
|
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/control/pager');
|
||||||
phutil_require_module('phabricator', 'view/layout/panel');
|
phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('DiffusionHistoryController.php');
|
phutil_require_source('DiffusionHistoryController.php');
|
||||||
|
|
|
@ -26,8 +26,16 @@ class DiffusionLastModifiedController extends DiffusionController {
|
||||||
$drequest);
|
$drequest);
|
||||||
list($commit, $commit_data) = $modified_query->loadLastModification();
|
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(
|
$output = DiffusionBrowseTableView::renderLastModifiedColumns(
|
||||||
$drequest->getRepository(),
|
$drequest->getRepository(),
|
||||||
|
$handles,
|
||||||
$commit,
|
$commit,
|
||||||
$commit_data);
|
$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/controller/base');
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/query/lastmodified/base');
|
phutil_require_module('phabricator', 'applications/diffusion/query/lastmodified/base');
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/view/browsetable');
|
phutil_require_module('phabricator', 'applications/diffusion/view/browsetable');
|
||||||
|
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,37 @@ class DiffusionRepositoryController extends DiffusionController {
|
||||||
$history_query = DiffusionHistoryQuery::newFromDiffusionRequest(
|
$history_query = DiffusionHistoryQuery::newFromDiffusionRequest(
|
||||||
$drequest);
|
$drequest);
|
||||||
$history_query->setLimit(15);
|
$history_query->setLimit(15);
|
||||||
|
|
||||||
$history = $history_query->loadHistory();
|
$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 = new DiffusionHistoryTableView();
|
||||||
$history_table->setDiffusionRequest($drequest);
|
$history_table->setDiffusionRequest($drequest);
|
||||||
|
$history_table->setHandles($handles);
|
||||||
$history_table->setHistory($history);
|
$history_table->setHistory($history);
|
||||||
|
|
||||||
$callsign = $drequest->getRepository()->getCallsign();
|
$callsign = $drequest->getRepository()->getCallsign();
|
||||||
|
@ -49,12 +76,11 @@ class DiffusionRepositoryController extends DiffusionController {
|
||||||
|
|
||||||
$content[] = $panel;
|
$content[] = $panel;
|
||||||
|
|
||||||
$browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest);
|
|
||||||
$results = $browse_query->loadPaths();
|
|
||||||
|
|
||||||
$browse_table = new DiffusionBrowseTableView();
|
$browse_table = new DiffusionBrowseTableView();
|
||||||
$browse_table->setDiffusionRequest($drequest);
|
$browse_table->setDiffusionRequest($drequest);
|
||||||
$browse_table->setPaths($results);
|
$browse_table->setHandles($handles);
|
||||||
|
$browse_table->setPaths($browse_results);
|
||||||
|
|
||||||
$browse_panel = new AphrontPanelView();
|
$browse_panel = new AphrontPanelView();
|
||||||
$browse_panel->setHeader('Browse Repository');
|
$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/branchtable');
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/view/browsetable');
|
phutil_require_module('phabricator', 'applications/diffusion/view/browsetable');
|
||||||
phutil_require_module('phabricator', 'applications/diffusion/view/historytable');
|
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('phabricator', 'view/layout/panel');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup');
|
phutil_require_module('phutil', 'markup');
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('DiffusionRepositoryController.php');
|
phutil_require_source('DiffusionRepositoryController.php');
|
||||||
|
|
|
@ -19,14 +19,21 @@
|
||||||
final class DiffusionBrowseTableView extends DiffusionView {
|
final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
|
|
||||||
private $paths;
|
private $paths;
|
||||||
|
private $handles = array();
|
||||||
|
|
||||||
public function setPaths(array $paths) {
|
public function setPaths(array $paths) {
|
||||||
$this->paths = $paths;
|
$this->paths = $paths;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setHandles(array $handles) {
|
||||||
|
$this->handles = $handles;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public static function renderLastModifiedColumns(
|
public static function renderLastModifiedColumns(
|
||||||
PhabricatorRepository $repository,
|
PhabricatorRepository $repository,
|
||||||
|
array $handles,
|
||||||
PhabricatorRepositoryCommit $commit = null,
|
PhabricatorRepositoryCommit $commit = null,
|
||||||
PhabricatorRepositoryCommitData $data = null) {
|
PhabricatorRepositoryCommitData $data = null) {
|
||||||
|
|
||||||
|
@ -44,7 +51,12 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data) {
|
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());
|
$details = phutil_escape_html($data->getSummary());
|
||||||
} else {
|
} else {
|
||||||
$author = '';
|
$author = '';
|
||||||
|
@ -96,6 +108,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
if ($commit) {
|
if ($commit) {
|
||||||
$dict = self::renderLastModifiedColumns(
|
$dict = self::renderLastModifiedColumns(
|
||||||
$repository,
|
$repository,
|
||||||
|
$this->handles,
|
||||||
$commit,
|
$commit,
|
||||||
$path->getLastCommitData());
|
$path->getLastCommitData());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -19,15 +19,23 @@
|
||||||
final class DiffusionHistoryTableView extends DiffusionView {
|
final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
|
|
||||||
private $history;
|
private $history;
|
||||||
|
private $handles = array();
|
||||||
|
|
||||||
public function setHistory(array $history) {
|
public function setHistory(array $history) {
|
||||||
$this->history = $history;
|
$this->history = $history;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setHandles(array $handles) {
|
||||||
|
$this->handles = $handles;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
$drequest = $this->getDiffusionRequest();
|
$drequest = $this->getDiffusionRequest();
|
||||||
|
|
||||||
|
$handles = $this->handles;
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach ($this->history as $history) {
|
foreach ($this->history as $history) {
|
||||||
$epoch = $history->getEpoch();
|
$epoch = $history->getEpoch();
|
||||||
|
@ -40,6 +48,18 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
$time = null;
|
$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(
|
$rows[] = array(
|
||||||
$this->linkBrowse(
|
$this->linkBrowse(
|
||||||
$drequest->getPath(),
|
$drequest->getPath(),
|
||||||
|
@ -54,7 +74,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
$history->getFileType()),
|
$history->getFileType()),
|
||||||
$date,
|
$date,
|
||||||
$time,
|
$time,
|
||||||
phutil_escape_html($history->getAuthorName()),
|
$author,
|
||||||
phutil_escape_html($history->getSummary()),
|
phutil_escape_html($history->getSummary()),
|
||||||
// TODO: etc etc
|
// TODO: etc etc
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue