mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Use standard handle loading in Releeph
Summary: Ref T3718. Move from unbatched / ad-hoc loading to standard stuff for handles. Test Plan: Looked at some requests and saw no changes. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T3718 Differential Revision: https://secure.phabricator.com/D8810
This commit is contained in:
parent
c7f5dc0208
commit
fde4ccf9b2
10 changed files with 72 additions and 85 deletions
|
@ -31,19 +31,6 @@ abstract class DifferentialCustomField
|
|||
return parent::shouldEnableForRole($role);
|
||||
}
|
||||
|
||||
protected function renderHandleList(array $handles) {
|
||||
if (!$handles) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$out = array();
|
||||
foreach ($handles as $handle) {
|
||||
$out[] = $handle->renderLink();
|
||||
}
|
||||
|
||||
return phutil_implode_html(phutil_tag('br'), $out);
|
||||
}
|
||||
|
||||
public function getRequiredDiffPropertiesForRevisionView() {
|
||||
if ($this->getProxy()) {
|
||||
return $this->getProxy()->getRequiredDiffPropertiesForRevisionView();
|
||||
|
|
|
@ -11,24 +11,23 @@ final class ReleephAuthorFieldSpecification
|
|||
return 'Author';
|
||||
}
|
||||
|
||||
public function renderPropertyViewValue(array $handles) {
|
||||
public function getRequiredHandlePHIDsForPropertyView() {
|
||||
$pull = $this->getReleephRequest();
|
||||
$commit = $pull->loadPhabricatorRepositoryCommit();
|
||||
if (!$commit) {
|
||||
return null;
|
||||
return array();
|
||||
}
|
||||
|
||||
$author_phid = $commit->getAuthorPHID();
|
||||
if (!$author_phid) {
|
||||
return null;
|
||||
return array();
|
||||
}
|
||||
|
||||
$handle = id(new PhabricatorHandleQuery())
|
||||
->setViewer($this->getUser())
|
||||
->withPHIDs(array($author_phid))
|
||||
->executeOne();
|
||||
return array($author_phid);
|
||||
}
|
||||
|
||||
return $handle->renderLink();
|
||||
public function renderPropertyViewValue(array $handles) {
|
||||
return $this->renderHandleList($handles);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,25 +10,12 @@ final class ReleephDependsOnFieldSpecification
|
|||
return pht('Depends On');
|
||||
}
|
||||
|
||||
public function getRequiredHandlePHIDsForPropertyView() {
|
||||
return $this->getDependentRevisionPHIDs();
|
||||
}
|
||||
|
||||
public function renderPropertyViewValue(array $handles) {
|
||||
$revision_phids = $this->getDependentRevisionPHIDs();
|
||||
if (!$revision_phids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$links = array();
|
||||
$handles = id(new PhabricatorHandleQuery())
|
||||
->setViewer($this->getUser())
|
||||
->withPHIDs($revision_phids)
|
||||
->execute();
|
||||
foreach ($revision_phids as $revision_phid) {
|
||||
$links[] = id(clone $handles[$revision_phid])
|
||||
// Hack to remove the strike-through rendering of diff links
|
||||
->setStatus(null)
|
||||
->renderLink();
|
||||
}
|
||||
|
||||
return phutil_implode_html(phutil_tag('br'), $links);
|
||||
return $this->renderHandleList($handles);
|
||||
}
|
||||
|
||||
private function getDependentRevisionPHIDs() {
|
||||
|
@ -36,7 +23,7 @@ final class ReleephDependsOnFieldSpecification
|
|||
->getReleephRequest()
|
||||
->loadDifferentialRevision();
|
||||
if (!$revision) {
|
||||
return null;
|
||||
return array();
|
||||
}
|
||||
|
||||
return PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
|
|
|
@ -18,7 +18,7 @@ final class ReleephDiffSizeFieldSpecification
|
|||
public function renderPropertyViewValue(array $handles) {
|
||||
$diff_rev = $this->getReleephRequest()->loadDifferentialRevision();
|
||||
if (!$diff_rev) {
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
|
||||
$diffs = $diff_rev->loadRelatives(
|
||||
|
|
|
@ -30,14 +30,6 @@ abstract class ReleephFieldSpecification
|
|||
return $value;
|
||||
}
|
||||
|
||||
public function slowlyLoadHandle($phid) {
|
||||
// TODO: Remove this, it's transitional as fields modernize.
|
||||
return id(new PhabricatorHandleQuery())
|
||||
->withPHIDs(array($phid))
|
||||
->setViewer($this->getUser())
|
||||
->executeOne();
|
||||
}
|
||||
|
||||
abstract public function getName();
|
||||
|
||||
/* -( Storage )------------------------------------------------------------ */
|
||||
|
|
|
@ -11,6 +11,12 @@ final class ReleephIntentFieldSpecification
|
|||
return 'Intent';
|
||||
}
|
||||
|
||||
public function getRequiredHandlePHIDsForPropertyView() {
|
||||
$pull = $this->getReleephRequest();
|
||||
$intents = $pull->getUserIntents();
|
||||
return array_keys($intents);
|
||||
}
|
||||
|
||||
public function renderPropertyViewValue(array $handles) {
|
||||
$pull = $this->getReleephRequest();
|
||||
|
||||
|
@ -21,16 +27,6 @@ final class ReleephIntentFieldSpecification
|
|||
return null;
|
||||
}
|
||||
|
||||
$user_phids = array_keys($intents);
|
||||
if ($user_phids) {
|
||||
$handles = id(new PhabricatorHandleQuery())
|
||||
->withPHIDs($user_phids)
|
||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||
->execute();
|
||||
} else {
|
||||
$handles = array();
|
||||
}
|
||||
|
||||
$pushers = array();
|
||||
$others = array();
|
||||
|
||||
|
|
|
@ -11,9 +11,15 @@ final class ReleephOriginalCommitFieldSpecification
|
|||
return 'Commit';
|
||||
}
|
||||
|
||||
public function getRequiredHandlePHIDsForPropertyView() {
|
||||
return array(
|
||||
$this->getReleephRequest()->getRequestCommitPHID(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function renderPropertyViewValue(array $handles) {
|
||||
$pull = $this->getReleephRequest();
|
||||
return $this->slowlyLoadHandle($pull->getRequestCommitPHID())->renderLink();
|
||||
return $this->renderHandleList($handles);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,13 +11,19 @@ final class ReleephRequestorFieldSpecification
|
|||
return 'Requestor';
|
||||
}
|
||||
|
||||
public function renderPropertyViewValue(array $handles) {
|
||||
public function getRequiredHandlePHIDsForPropertyView() {
|
||||
$phids = array();
|
||||
|
||||
$phid = $this->getReleephRequest()->getRequestUserPHID();
|
||||
$handle = id(new PhabricatorHandleQuery())
|
||||
->setViewer($this->getUser())
|
||||
->withPHIDs(array($phid))
|
||||
->executeOne();
|
||||
return $handle->renderLink();
|
||||
if ($phid) {
|
||||
$phids[] = $phid;
|
||||
}
|
||||
|
||||
return $phids;
|
||||
}
|
||||
|
||||
public function renderPropertyViewValue(array $handles) {
|
||||
return $this->renderHandleList($handles);
|
||||
}
|
||||
|
||||
public function shouldAppearOnCommitMessage() {
|
||||
|
|
|
@ -11,26 +11,19 @@ final class ReleephRevisionFieldSpecification
|
|||
return 'Revision';
|
||||
}
|
||||
|
||||
public function renderPropertyViewValue(array $handles) {
|
||||
$phid = $this
|
||||
->getReleephRequest()
|
||||
->loadRequestCommitDiffPHID();
|
||||
if (!$phid) {
|
||||
return null;
|
||||
public function getRequiredHandlePHIDsForPropertyView() {
|
||||
$phids = array();
|
||||
|
||||
$phid = $this->getReleephRequest()->loadRequestCommitDiffPHID();
|
||||
if ($phid) {
|
||||
$phids[] = $phid;
|
||||
}
|
||||
|
||||
$handles = $this->getReleephRequest()->getHandles();
|
||||
$handle = $handles[$phid];
|
||||
$link = $handle
|
||||
// Hack to remove the strike-through rendering of diff links
|
||||
->setStatus(null)
|
||||
->renderLink();
|
||||
return phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'releeph-header-text-truncated',
|
||||
),
|
||||
$link);
|
||||
return $phids;
|
||||
}
|
||||
|
||||
public function renderPropertyViewValue(array $handles) {
|
||||
return $this->renderHandleList($handles);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* @task core Core Properties and Field Identity
|
||||
* @task proxy Field Proxies
|
||||
* @task context Contextual Data
|
||||
* @task render Rendering Utilities
|
||||
* @task storage Field Storage
|
||||
* @task edit Integration with Edit Views
|
||||
* @task view Integration with Property Views
|
||||
|
@ -467,6 +468,26 @@ abstract class PhabricatorCustomField {
|
|||
}
|
||||
|
||||
|
||||
/* -( Rendering Utilities )------------------------------------------------ */
|
||||
|
||||
|
||||
/**
|
||||
* @task render
|
||||
*/
|
||||
protected function renderHandleList(array $handles) {
|
||||
if (!$handles) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$out = array();
|
||||
foreach ($handles as $handle) {
|
||||
$out[] = $handle->renderLink();
|
||||
}
|
||||
|
||||
return phutil_implode_html(phutil_tag('br'), $out);
|
||||
}
|
||||
|
||||
|
||||
/* -( Storage )------------------------------------------------------------ */
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue