mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-27 07:50:57 +01:00
Explicitly load assets in revision list
Summary: Rendering method shouldn't load data. The view probably shouldn't load data either because it is a job for component (object that both loads data and displays them) but we don't have that concept in Phabricator. This at least improves the architecture a little bit. Test Plan: /differential/ Reviewers: epriestley Reviewed By: epriestley CC: alanh, aran, Korvin Differential Revision: https://secure.phabricator.com/D3325
This commit is contained in:
parent
b50cdc6e43
commit
8ee2a6f988
5 changed files with 31 additions and 11 deletions
|
@ -439,7 +439,8 @@ final class DifferentialRevisionListController extends DifferentialController {
|
|||
|
||||
$view = id(clone $template)
|
||||
->setHighlightAge(true)
|
||||
->setRevisions($active);
|
||||
->setRevisions($active)
|
||||
->loadAssets();
|
||||
$views[] = array(
|
||||
'title' => 'Action Required',
|
||||
'view' => $view,
|
||||
|
@ -468,7 +469,8 @@ final class DifferentialRevisionListController extends DifferentialController {
|
|||
}
|
||||
|
||||
$view = id(clone $template)
|
||||
->setRevisions($waiting);
|
||||
->setRevisions($waiting)
|
||||
->loadAssets();
|
||||
$views[] = array(
|
||||
'title' => 'Waiting On Others',
|
||||
'view' => $view,
|
||||
|
@ -486,7 +488,8 @@ final class DifferentialRevisionListController extends DifferentialController {
|
|||
'all' => 'Revisions',
|
||||
);
|
||||
$view = id(clone $template)
|
||||
->setRevisions($revisions);
|
||||
->setRevisions($revisions)
|
||||
->loadAssets();
|
||||
$views[] = array(
|
||||
'title' => idx($titles, $filter),
|
||||
'view' => $view,
|
||||
|
|
|
@ -862,7 +862,8 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
|||
$view = id(new DifferentialRevisionListView())
|
||||
->setRevisions($revisions)
|
||||
->setFields(DifferentialRevisionListView::getDefaultFields())
|
||||
->setUser($this->getRequest()->getUser());
|
||||
->setUser($this->getRequest()->getUser())
|
||||
->loadAssets();
|
||||
|
||||
$phids = $view->getRequiredHandlePHIDs();
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
final class DifferentialRevisionListView extends AphrontView {
|
||||
|
||||
private $revisions;
|
||||
private $flags = array();
|
||||
private $handles;
|
||||
private $user;
|
||||
private $fields;
|
||||
|
@ -69,6 +70,23 @@ final class DifferentialRevisionListView extends AphrontView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function loadAssets() {
|
||||
$user = $this->user;
|
||||
if (!$user) {
|
||||
throw new Exception("Call setUser() before loadAssets()!");
|
||||
}
|
||||
if ($this->revisions === null) {
|
||||
throw new Exception("Call setRevisions() before loadAssets()!");
|
||||
}
|
||||
|
||||
$this->flags = id(new PhabricatorFlagQuery())
|
||||
->withOwnerPHIDs(array($user->getPHID()))
|
||||
->withObjectPHIDs(mpull($this->revisions, 'getPHID'))
|
||||
->execute();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
$user = $this->user;
|
||||
|
@ -88,11 +106,7 @@ final class DifferentialRevisionListView extends AphrontView {
|
|||
Javelin::initBehavior('phabricator-tooltips', array());
|
||||
require_celerity_resource('aphront-tooltip-css');
|
||||
|
||||
$flags = id(new PhabricatorFlagQuery())
|
||||
->withOwnerPHIDs(array($user->getPHID()))
|
||||
->withObjectPHIDs(mpull($this->revisions, 'getPHID'))
|
||||
->execute();
|
||||
$flagged = mpull($flags, null, 'getObjectPHID');
|
||||
$flagged = mpull($this->flags, null, 'getObjectPHID');
|
||||
|
||||
foreach ($this->fields as $field) {
|
||||
$field->setUser($this->user);
|
||||
|
|
|
@ -137,7 +137,8 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
$view = id(new DifferentialRevisionListView())
|
||||
->setRevisions($revisions)
|
||||
->setFields(DifferentialRevisionListView::getDefaultFields())
|
||||
->setUser($this->getRequest()->getUser());
|
||||
->setUser($this->getRequest()->getUser())
|
||||
->loadAssets();
|
||||
|
||||
$phids = $view->getRequiredHandlePHIDs();
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||
|
|
|
@ -326,7 +326,8 @@ final class PhabricatorDirectoryMainController
|
|||
->setHighlightAge(true)
|
||||
->setRevisions($active)
|
||||
->setFields(DifferentialRevisionListView::getDefaultFields())
|
||||
->setUser($user);
|
||||
->setUser($user)
|
||||
->loadAssets();
|
||||
$phids = array_merge(
|
||||
array($user_phid),
|
||||
$revision_view->getRequiredHandlePHIDs());
|
||||
|
|
Loading…
Reference in a new issue