1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Remove ReleephUserView

Summary:
Fixes T3738. Facebook uses this to provide a couple of integrations (push karma, is user an intern?), but the mechanism is both very complex and not very general.

Instead, these features are better implemented in Hovercards or via CustomField. We'll help Facebook integrate things when the time comes, but per discussion in T3738 none of this is critical or especially complicated.

Test Plan:
  - Grepped for all callsites.
  - Viewed a request and verified that author/requestor populated and rendered correctly.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T3738

Differential Revision: https://secure.phabricator.com/D8631
This commit is contained in:
epriestley 2014-03-29 09:14:32 -07:00
parent ce5714526a
commit 6c8cef3bee
6 changed files with 10 additions and 119 deletions

View file

@ -2501,7 +2501,6 @@ phutil_register_library_map(array(
'ReleephController' => 'applications/releeph/controller/ReleephController.php',
'ReleephDAO' => 'applications/releeph/storage/ReleephDAO.php',
'ReleephDefaultFieldSelector' => 'applications/releeph/field/selector/ReleephDefaultFieldSelector.php',
'ReleephDefaultUserView' => 'applications/releeph/view/user/ReleephDefaultUserView.php',
'ReleephDependsOnFieldSpecification' => 'applications/releeph/field/specification/ReleephDependsOnFieldSpecification.php',
'ReleephDiffChurnFieldSpecification' => 'applications/releeph/field/specification/ReleephDiffChurnFieldSpecification.php',
'ReleephDiffMessageFieldSpecification' => 'applications/releeph/field/specification/ReleephDiffMessageFieldSpecification.php',
@ -2554,7 +2553,6 @@ phutil_register_library_map(array(
'ReleephSeverityFieldSpecification' => 'applications/releeph/field/specification/ReleephSeverityFieldSpecification.php',
'ReleephStatusFieldSpecification' => 'applications/releeph/field/specification/ReleephStatusFieldSpecification.php',
'ReleephSummaryFieldSpecification' => 'applications/releeph/field/specification/ReleephSummaryFieldSpecification.php',
'ReleephUserView' => 'applications/releeph/view/user/ReleephUserView.php',
'ShellLogView' => 'applications/harbormaster/view/ShellLogView.php',
'SlowvoteEmbedView' => 'applications/slowvote/view/SlowvoteEmbedView.php',
'SlowvoteRemarkupRule' => 'applications/slowvote/remarkup/SlowvoteRemarkupRule.php',
@ -5473,7 +5471,6 @@ phutil_register_library_map(array(
'ReleephController' => 'PhabricatorController',
'ReleephDAO' => 'PhabricatorLiskDAO',
'ReleephDefaultFieldSelector' => 'ReleephFieldSelector',
'ReleephDefaultUserView' => 'ReleephUserView',
'ReleephDependsOnFieldSpecification' => 'ReleephFieldSpecification',
'ReleephDiffChurnFieldSpecification' => 'ReleephFieldSpecification',
'ReleephDiffMessageFieldSpecification' => 'ReleephFieldSpecification',
@ -5545,7 +5542,6 @@ phutil_register_library_map(array(
'ReleephSeverityFieldSpecification' => 'ReleephLevelFieldSpecification',
'ReleephStatusFieldSpecification' => 'ReleephFieldSpecification',
'ReleephSummaryFieldSpecification' => 'ReleephFieldSpecification',
'ReleephUserView' => 'AphrontView',
'ShellLogView' => 'AphrontView',
'SlowvoteEmbedView' => 'AphrontView',
'SlowvoteRemarkupRule' => 'PhabricatorRemarkupRuleObject',

View file

@ -59,18 +59,6 @@ final class PhabricatorApplicationReleephConfigOptions
"stable.")),
$this->newOption('releeph.fields', $custom_field_type, $default)
->setCustomData('ReleephFieldSpecification'),
$this->newOption(
'releeph.user-view',
'class',
'ReleephDefaultUserView')
->setBaseClass('ReleephUserView')
->setSummary(pht('Extra markup when rendering usernames'))
->setDescription(
pht(
"A wrapper to render Phabricator users in Releeph, with custom ".
"markup. For example, Facebook extends this to render additional ".
"information about requestors, to each Releeph project's ".
"pushers.")),
$this->newOption(
'releeph.default-branch-template',
'string',

View file

@ -17,11 +17,6 @@ final class ReleephAuthorFieldSpecification
self::$authorMap[$releeph_request->getPHID()] = $author_phid;
}
}
ReleephUserView::getNewInstance()
->setUser($this->getUser())
->setReleephProject($this->getReleephProject())
->load(self::$authorMap);
}
public function getName() {
@ -32,9 +27,11 @@ final class ReleephAuthorFieldSpecification
$rr = $this->getReleephRequest();
$author_phid = idx(self::$authorMap, $rr->getPHID());
if ($author_phid) {
return ReleephUserView::getNewInstance()
->setRenderUserPHID($author_phid)
->render();
$handle = id(new PhabricatorHandleQuery())
->setViewer($this->getUser())
->withPHIDs(array($author_phid))
->executeOne();
return $handle->renderLink();
} else {
return 'Unknown Author';
}

View file

@ -7,23 +7,17 @@ final class ReleephRequestorFieldSpecification
return 'requestor';
}
public function bulkLoad(array $releeph_requests) {
$phids = mpull($releeph_requests, 'getRequestUserPHID');
ReleephUserView::getNewInstance()
->setUser($this->getUser())
->setReleephProject($this->getReleephProject())
->load($phids);
}
public function getName() {
return 'Requestor';
}
public function renderValueForHeaderView() {
$phid = $this->getReleephRequest()->getRequestUserPHID();
return ReleephUserView::getNewInstance()
->setRenderUserPHID($phid)
->render();
$handle = id(new PhabricatorHandleQuery())
->setViewer($this->getUser())
->withPHIDs(array($phid))
->executeOne();
return $handle->renderLink();
}
public function shouldAppearOnCommitMessage() {

View file

@ -1,9 +0,0 @@
<?php
final class ReleephDefaultUserView extends ReleephUserView {
public function render() {
return $this->getHandle()->renderLink();
}
}

View file

@ -1,75 +0,0 @@
<?php
abstract class ReleephUserView extends AphrontView {
/**
* This function should bulk load everything you need to render all the given
* user phids.
*
* Many parts of Releeph load users for rendering. Accordingly, this
* function will be called multiple times for each part of the UI that
* renders users, so you should accumulate your results on each call.
*
* You should also implement render() (from AphrontView) to render each
* user's PHID.
*/
protected function loadInner(array $phids) {
// This is a hook!
}
final public static function getNewInstance() {
$key = 'releeph.user-view';
$class = PhabricatorEnv::getEnvConfig($key);
return newv($class, array());
}
private static $handles = array();
private static $seen = array();
final public function load(array $phids) {
$todo = array();
foreach ($phids as $key => $phid) {
if (!idx(self::$seen, $phid)) {
$todo[$key] = $phid;
self::$seen[$phid] = true;
}
}
if ($todo) {
self::$handles = array_merge(
self::$handles,
id(new PhabricatorHandleQuery())
->setViewer($this->getUser())
->withPHIDs($todo)
->execute());
$this->loadInner($todo);
}
}
private $phid;
private $releephProject;
final public function setRenderUserPHID($phid) {
$this->phid = $phid;
return $this;
}
final public function setReleephProject(ReleephProject $project) {
$this->releephProject = $project;
return $this;
}
final protected function getRenderUserPHID() {
return $this->phid;
}
final protected function getReleephProject() {
return $this->releephProject;
}
final protected function getHandle() {
return self::$handles[$this->phid];
}
}