mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Remove Controller->renderHandlesForPHIDs()
Summary: Ref T7689. Remove all remaining callsites for this method. Test Plan: - Viewed a custom policy; viewed handles in the policy rules. - Viewed a Releeph product; viewed "Pushers". - Viewed a project; viewed "Watchers"; viewed "Members"; viewed "Looks Like". - Viewed repository edit; viewed "Credential"; viewed "Storage Service"; viewed "Projects". - Viewed repository detail; viewed "Projects". - Viewed commit; viewed (faked) "Reverts"; viewed (faked) "Reverted By". - These are kind of a pain to generate so I faked 'em. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7689 Differential Revision: https://secure.phabricator.com/D12208
This commit is contained in:
parent
a8271ecd40
commit
e1eafd784e
9 changed files with 39 additions and 63 deletions
|
@ -447,30 +447,6 @@ abstract class PhabricatorController extends AphrontController {
|
|||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a list of links to handles, identified by PHIDs. The handles must
|
||||
* already be loaded.
|
||||
*
|
||||
* @param list<phid> List of PHIDs to render links to.
|
||||
* @param string Style, one of "\n" (to put each item on its own line)
|
||||
* or "," (to list items inline, separated by commas).
|
||||
* @return string Rendered list of handle links.
|
||||
*/
|
||||
protected function renderHandlesForPHIDs(array $phids, $style = "\n") {
|
||||
$style_map = array(
|
||||
"\n" => phutil_tag('br'),
|
||||
',' => ', ',
|
||||
);
|
||||
|
||||
if (empty($style_map[$style])) {
|
||||
throw new Exception("Unknown handle list style '{$style}'!");
|
||||
}
|
||||
|
||||
return implode_selected_handle_links($style_map[$style],
|
||||
$this->handles,
|
||||
array_filter($phids));
|
||||
}
|
||||
|
||||
public function buildApplicationMenu() {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -614,13 +614,11 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
}
|
||||
|
||||
if ($reverts_phids) {
|
||||
$this->loadHandles($reverts_phids);
|
||||
$props[pht('Reverts')] = $this->renderHandlesForPHIDs($reverts_phids);
|
||||
$props[pht('Reverts')] = $viewer->renderHandleList($reverts_phids);
|
||||
}
|
||||
|
||||
if ($reverted_by_phids) {
|
||||
$this->loadHandles($reverted_by_phids);
|
||||
$props[pht('Reverted By')] = $this->renderHandlesForPHIDs(
|
||||
$props[pht('Reverted By')] = $viewer->renderHandleList(
|
||||
$reverted_by_phids);
|
||||
}
|
||||
|
||||
|
|
|
@ -234,10 +234,9 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
$repository->getPHID(),
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
if ($project_phids) {
|
||||
$this->loadHandles($project_phids);
|
||||
$view->addProperty(
|
||||
pht('Projects'),
|
||||
$this->renderHandlesForPHIDs($project_phids));
|
||||
$user->renderHandleList($project_phids));
|
||||
}
|
||||
|
||||
if ($repository->isHosted()) {
|
||||
|
|
|
@ -265,8 +265,7 @@ final class DiffusionRepositoryEditMainController
|
|||
$repository->getPHID(),
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
if ($project_phids) {
|
||||
$this->loadHandles($project_phids);
|
||||
$project_text = $this->renderHandlesForPHIDs($project_phids);
|
||||
$project_text = $viewer->renderHandleList($project_phids);
|
||||
} else {
|
||||
$project_text = phutil_tag('em', array(), pht('None'));
|
||||
}
|
||||
|
@ -546,10 +545,9 @@ final class DiffusionRepositoryEditMainController
|
|||
|
||||
$credential_phid = $repository->getCredentialPHID();
|
||||
if ($credential_phid) {
|
||||
$this->loadHandles(array($credential_phid));
|
||||
$view->addProperty(
|
||||
pht('Credential'),
|
||||
$this->getHandle($credential_phid)->renderLink());
|
||||
$viewer->renderHandle($credential_phid));
|
||||
}
|
||||
|
||||
return $view;
|
||||
|
@ -584,8 +582,7 @@ final class DiffusionRepositoryEditMainController
|
|||
|
||||
$service_phid = $repository->getAlmanacServicePHID();
|
||||
if ($service_phid) {
|
||||
$handles = $this->loadViewerHandles(array($service_phid));
|
||||
$v_service = $handles[$service_phid]->renderLink();
|
||||
$v_service = $viewer->renderHandle($service_phid);
|
||||
} else {
|
||||
$v_service = phutil_tag(
|
||||
'em',
|
||||
|
|
|
@ -11,20 +11,20 @@ final class PHUIHandleListView
|
|||
extends AphrontTagView {
|
||||
|
||||
private $handleList;
|
||||
private $inline;
|
||||
private $asInline;
|
||||
|
||||
public function setHandleList(PhabricatorHandleList $list) {
|
||||
$this->handleList = $list;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInline($inline) {
|
||||
$this->inline = $inline;
|
||||
public function setAsInline($inline) {
|
||||
$this->asInline = $inline;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getInline() {
|
||||
return $this->inline;
|
||||
public function getAsInline() {
|
||||
return $this->asInline;
|
||||
}
|
||||
|
||||
protected function getTagName() {
|
||||
|
@ -39,7 +39,7 @@ final class PHUIHandleListView
|
|||
$items[] = $handle->renderLink();
|
||||
}
|
||||
|
||||
if ($this->getInline()) {
|
||||
if ($this->getAsInline()) {
|
||||
$items = phutil_implode_html(', ', $items);
|
||||
} else {
|
||||
$items = phutil_implode_html(phutil_tag('br'), $items);
|
||||
|
|
|
@ -13,6 +13,7 @@ final class PHUIHandleView
|
|||
|
||||
private $handleList;
|
||||
private $handlePHID;
|
||||
private $asTag;
|
||||
|
||||
public function setHandleList(PhabricatorHandleList $list) {
|
||||
$this->handleList = $list;
|
||||
|
@ -24,8 +25,18 @@ final class PHUIHandleView
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setAsTag($tag) {
|
||||
$this->asTag = $tag;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
return $this->handleList[$this->handlePHID]->renderLink();
|
||||
$handle = $this->handleList[$this->handlePHID];
|
||||
if ($this->asTag) {
|
||||
return $handle->renderTag();
|
||||
} else {
|
||||
return $handle->renderLink();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -167,11 +167,6 @@ final class PhabricatorProjectProfileController
|
|||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$this->loadHandles(
|
||||
array_merge(
|
||||
$project->getMemberPHIDs(),
|
||||
$project->getWatcherPHIDs()));
|
||||
|
||||
$view = id(new PHUIPropertyListView())
|
||||
->setUser($viewer)
|
||||
->setObject($project)
|
||||
|
@ -189,24 +184,26 @@ final class PhabricatorProjectProfileController
|
|||
$view->addProperty(
|
||||
pht('Members'),
|
||||
$project->getMemberPHIDs()
|
||||
? $this->renderHandlesForPHIDs($project->getMemberPHIDs(), ',')
|
||||
? $viewer
|
||||
->renderHandleList($project->getMemberPHIDs())
|
||||
->setAsInline(true)
|
||||
: phutil_tag('em', array(), pht('None')));
|
||||
|
||||
$view->addProperty(
|
||||
pht('Watchers'),
|
||||
$project->getWatcherPHIDs()
|
||||
? $this->renderHandlesForPHIDs($project->getWatcherPHIDs(), ',')
|
||||
? $viewer
|
||||
->renderHandleList($project->getWatcherPHIDs())
|
||||
->setAsInline(true)
|
||||
: phutil_tag('em', array(), pht('None')));
|
||||
|
||||
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
|
||||
$viewer,
|
||||
$project);
|
||||
|
||||
$this->loadHandles(array($project->getPHID()));
|
||||
|
||||
$view->addProperty(
|
||||
pht('Looks Like'),
|
||||
$this->getHandle($project->getPHID())->renderTag());
|
||||
$viewer->renderHandle($project->getPHID())->setAsTag(true));
|
||||
|
||||
$view->addProperty(
|
||||
pht('Joinable By'),
|
||||
|
|
|
@ -55,9 +55,6 @@ final class ReleephProductViewController extends ReleephProductController
|
|||
->execute();
|
||||
$repos = mpull($repos, null, 'getPHID');
|
||||
|
||||
$phids = mpull($branches, 'getCreatedByUserPHID');
|
||||
$this->loadHandles($phids);
|
||||
|
||||
$requests = array();
|
||||
if ($branches) {
|
||||
$requests = id(new ReleephRequestQuery())
|
||||
|
@ -237,10 +234,9 @@ final class ReleephProductViewController extends ReleephProductController
|
|||
|
||||
$pushers = $product->getPushers();
|
||||
if ($pushers) {
|
||||
$this->loadHandles($pushers);
|
||||
$properties->addProperty(
|
||||
pht('Pushers'),
|
||||
$this->renderHandlesForPHIDs($pushers));
|
||||
$viewer->renderHandleList($pushers));
|
||||
}
|
||||
|
||||
return id(new PHUIObjectBoxView())
|
||||
|
|
|
@ -63,8 +63,6 @@ final class PhabricatorApplicationTransactionValueController
|
|||
$rule_objects[$class] = newv($class, array());
|
||||
}
|
||||
$policy->attachRuleObjects($rule_objects);
|
||||
$handle_phids = $this->extractPHIDs($policy, $rule_objects);
|
||||
$handles = $this->loadHandles($handle_phids);
|
||||
|
||||
$this->requireResource('policy-transaction-detail-css');
|
||||
$cancel_uri = $this->guessCancelURI($viewer, $xaction);
|
||||
|
@ -114,13 +112,17 @@ final class PhabricatorApplicationTransactionValueController
|
|||
->setIconFont($icon)
|
||||
->setText(
|
||||
ucfirst($rule['action']).' '.$rule_object->getRuleDescription());
|
||||
$handle_phids =
|
||||
$rule_object->getRequiredHandlePHIDsForSummary($rule['value']);
|
||||
|
||||
$handle_phids = $rule_object->getRequiredHandlePHIDsForSummary(
|
||||
$rule['value']);
|
||||
if ($handle_phids) {
|
||||
$value = $this->renderHandlesForPHIDs($handle_phids, ',');
|
||||
$value = $this->getViewer()
|
||||
->renderHandleList($handle_phids)
|
||||
->setInline(true);
|
||||
} else {
|
||||
$value = $rule['value'];
|
||||
}
|
||||
|
||||
$details[] = phutil_tag('div',
|
||||
array(
|
||||
'class' => 'policy-transaction-detail-row',
|
||||
|
|
Loading…
Reference in a new issue