1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 05:12:41 +01:00

Remove all setObjectURI() from ActionListViews

Summary:
Ref T10004. After D14804, we get this behavior by default and no longer need to set it explicitly.

(If some endpoint did eventually need to set it explicitly, it could just change what it passes to `setHref()`, but I believe we currently have no such endpoints and do not foresee ever having any.)

Test Plan:
  - As a logged out user, clicked various links in Differential, Maniphest, Files, etc., always got redirected to a sensible place after login.
  - Grepped for `setObjectURI()`, `getObjectURI()` (there are a few remaining callsites, but to a different method with the same name in Doorkeeper).

Reviewers: chad

Reviewed By: chad

Subscribers: hach-que

Maniphest Tasks: T10004

Differential Revision: https://secure.phabricator.com/D14805
This commit is contained in:
epriestley 2015-12-17 06:31:33 -08:00
parent e869e7df0b
commit 2868a69f65
49 changed files with 22 additions and 111 deletions

View file

@ -152,7 +152,6 @@ final class PhabricatorCalendarEventViewController
$is_attending = $event->getIsUserAttending($viewer->getPHID());
$actions = id(new PhabricatorActionListView())
->setObjectURI($this->getApplicationURI('event/'.$id.'/'))
->setUser($viewer)
->setObject($event);

View file

@ -99,7 +99,6 @@ final class PhabricatorDashboardManageController
$id = $dashboard->getID();
$actions = id(new PhabricatorActionListView())
->setObjectURI($this->getApplicationURI('view/'.$dashboard->getID().'/'))
->setObject($dashboard)
->setUser($viewer);

View file

@ -84,7 +84,6 @@ final class PhabricatorDashboardPanelViewController
$id = $panel->getID();
$actions = id(new PhabricatorActionListView())
->setObjectURI('/'.$panel->getMonogram())
->setObject($panel)
->setUser($viewer);

View file

@ -63,8 +63,7 @@ final class DifferentialRevisionDetailView extends AphrontView {
$actions = id(new PhabricatorActionListView())
->setUser($user)
->setObject($revision)
->setObjectURI($this->getURI());
->setObject($revision);
foreach ($this->getActions() as $action) {
$actions->addAction($action);
}

View file

@ -903,8 +903,7 @@ final class DiffusionCommitController extends DiffusionController {
$actions = id(new PhabricatorActionListView())
->setUser($user)
->setObject($commit)
->setObjectURI($request->getRequestURI());
->setObject($commit);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$user,

View file

@ -480,13 +480,11 @@ final class DiffusionRepositoryController extends DiffusionController {
private function buildActionList(PhabricatorRepository $repository) {
$viewer = $this->getRequest()->getUser();
$view_uri = $this->getApplicationURI($repository->getCallsign().'/');
$edit_uri = $this->getApplicationURI($repository->getCallsign().'/edit/');
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($repository)
->setObjectURI($view_uri);
->setObject($repository);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,

View file

@ -224,7 +224,6 @@ final class DiffusionRepositoryEditMainController
$viewer = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$edit = id(new PhabricatorActionView())
@ -327,7 +326,6 @@ final class DiffusionRepositoryEditMainController
$viewer = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$edit = id(new PhabricatorActionView())
@ -364,7 +362,6 @@ final class DiffusionRepositoryEditMainController
$viewer = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$edit = id(new PhabricatorActionView())
@ -419,7 +416,6 @@ final class DiffusionRepositoryEditMainController
$viewer = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$edit = id(new PhabricatorActionView())
@ -469,7 +465,6 @@ final class DiffusionRepositoryEditMainController
$viewer = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$edit = id(new PhabricatorActionView())
@ -509,7 +504,6 @@ final class DiffusionRepositoryEditMainController
$viewer = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$edit = id(new PhabricatorActionView())
@ -551,7 +545,6 @@ final class DiffusionRepositoryEditMainController
$viewer = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$edit = id(new PhabricatorActionView())
@ -592,7 +585,6 @@ final class DiffusionRepositoryEditMainController
$viewer = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$edit = id(new PhabricatorActionView())
@ -640,7 +632,6 @@ final class DiffusionRepositoryEditMainController
$viewer = $this->getViewer();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$edit = id(new PhabricatorActionView())
@ -678,7 +669,6 @@ final class DiffusionRepositoryEditMainController
$viewer = $this->getViewer();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$edit = id(new PhabricatorActionView())
@ -732,7 +722,6 @@ final class DiffusionRepositoryEditMainController
$user = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($user);
$edit = id(new PhabricatorActionView())
@ -1240,7 +1229,6 @@ final class DiffusionRepositoryEditMainController
$viewer = $this->getRequest()->getUser();
$mirror_actions = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$new_mirror_uri = $this->getRepositoryControllerURI(
@ -1319,7 +1307,6 @@ final class DiffusionRepositoryEditMainController
$viewer = $this->getRequest()->getUser();
$view = id(new PhabricatorActionListView())
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$edit = id(new PhabricatorActionView())

View file

@ -125,8 +125,7 @@ final class DivinerBookController extends DivinerController {
$action_view = id(new PhabricatorActionListView())
->setUser($user)
->setObject($book)
->setObjectURI($this->getRequest()->getRequestURI());
->setObject($book);
$action_view->addAction(
id(new PhabricatorActionView())

View file

@ -67,7 +67,6 @@ final class DrydockAuthorizationViewController
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($this->getRequest()->getRequestURI())
->setObject($authorization);
$can_edit = PhabricatorPolicyFilter::hasCapability(

View file

@ -86,7 +86,6 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController {
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($this->getRequest()->getRequestURI())
->setObject($blueprint);
$edit_uri = $this->getApplicationURI("blueprint/edit/{$id}/");

View file

@ -66,7 +66,6 @@ final class DrydockLeaseViewController extends DrydockLeaseController {
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($this->getRequest()->getRequestURI())
->setObject($lease);
$id = $lease->getID();

View file

@ -68,7 +68,6 @@ final class DrydockRepositoryOperationViewController
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($this->getRequest()->getRequestURI())
->setObject($operation);
return $view;

View file

@ -74,7 +74,6 @@ final class DrydockResourceViewController extends DrydockResourceController {
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($this->getRequest()->getRequestURI())
->setObject($resource);
$can_release = $resource->canRelease();

View file

@ -120,7 +120,6 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($this->getRequest()->getRequestURI())
->setObject($file);
$can_download = !$file->getIsPartial();

View file

@ -445,8 +445,7 @@ final class HarbormasterBuildViewController
$list = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($build)
->setObjectURI("/build/{$id}");
->setObject($build);
$can_restart = $build->canRestartBuild();
$can_pause = $build->canPauseBuild();

View file

@ -74,8 +74,7 @@ final class HarbormasterBuildableViewController
$list = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($buildable)
->setObjectURI($buildable->getMonogram());
->setObject($buildable);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,

View file

@ -221,8 +221,7 @@ final class HarbormasterPlanViewController extends HarbormasterPlanController {
$list = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($plan)
->setObjectURI($this->getApplicationURI("plan/{$id}/"));
->setObject($plan);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,

View file

@ -67,8 +67,7 @@ final class HeraldRuleViewController extends HeraldController {
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($rule)
->setObjectURI('/'.$rule->getMonogram());
->setObject($rule);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,

View file

@ -98,7 +98,6 @@ final class LegalpadDocumentManageController extends LegalpadController {
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($this->getRequest()->getRequestURI())
->setObject($document);
$can_edit = PhabricatorPolicyFilter::hasCapability(

View file

@ -104,7 +104,6 @@ final class PhabricatorMacroViewController
$view = id(new PhabricatorActionListView())
->setUser($request->getUser())
->setObject($macro)
->setObjectURI($request->getRequestURI())
->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Macro'))

View file

@ -136,8 +136,7 @@ final class ManiphestTaskDetailController extends ManiphestController {
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($task)
->setObjectURI($this->getRequest()->getRequestURI());
->setObject($task);
$view->addAction(
id(new PhabricatorActionView())

View file

@ -135,8 +135,7 @@ final class PhabricatorApplicationDetailViewController
PhabricatorApplication $selected) {
$view = id(new PhabricatorActionListView())
->setUser($user)
->setObjectURI($this->getRequest()->getRequestURI());
->setUser($user);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$user,

View file

@ -59,7 +59,6 @@ final class NuanceQueueViewController extends NuanceController {
$id = $queue->getID();
$actions = id(new PhabricatorActionListView())
->setObjectURI($queue->getURI())
->setUser($viewer);
$can_edit = PhabricatorPolicyFilter::hasCapability(

View file

@ -80,7 +80,6 @@ final class NuanceSourceViewController extends NuanceController {
$id = $source->getID();
$actions = id(new PhabricatorActionListView())
->setObjectURI($source->getURI())
->setUser($viewer);
$can_edit = PhabricatorPolicyFilter::hasCapability(

View file

@ -89,7 +89,6 @@ final class PassphraseCredentialViewController extends PassphraseController {
}
$actions = id(new PhabricatorActionListView())
->setObjectURI('/K'.$id)
->setObject($credential)
->setUser($viewer);

View file

@ -131,8 +131,7 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
$action_list = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($paste)
->setObjectURI($this->getRequest()->getRequestURI());
->setObject($paste);
$action_list->addAction(
id(new PhabricatorActionView())

View file

@ -43,7 +43,6 @@ final class PhabricatorPeopleProfileController
$actions = id(new PhabricatorActionListView())
->setObject($user)
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$can_edit = PhabricatorPolicyFilter::hasCapability(

View file

@ -134,7 +134,6 @@ final class PhameBlogManageController extends PhameBlogController {
private function renderActions(PhameBlog $blog, PhabricatorUser $viewer) {
$actions = id(new PhabricatorActionListView())
->setObject($blog)
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$can_edit = PhabricatorPolicyFilter::hasCapability(

View file

@ -108,7 +108,6 @@ final class PhameBlogViewController extends PhameLiveController {
$actions = id(new PhabricatorActionListView())
->setObject($blog)
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$can_edit = PhabricatorPolicyFilter::hasCapability(

View file

@ -155,7 +155,6 @@ final class PhamePostViewController
$actions = id(new PhabricatorActionListView())
->setObject($post)
->setObjectURI($this->getRequest()->getRequestURI())
->setUser($viewer);
$can_edit = PhabricatorPolicyFilter::hasCapability(

View file

@ -28,7 +28,6 @@ final class PhluxViewController extends PhluxController {
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($request->getRequestURI())
->setObject($var);
$can_edit = PhabricatorPolicyFilter::hasCapability(

View file

@ -117,7 +117,6 @@ final class PholioMockViewController extends PholioController {
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($this->getRequest()->getRequestURI())
->setObject($mock);
$can_edit = PhabricatorPolicyFilter::hasCapability(

View file

@ -44,7 +44,6 @@ final class PhortuneAccountViewController extends PhortuneController {
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($request->getRequestURI())
->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Account'))

View file

@ -22,8 +22,7 @@ final class PhortuneProductViewController extends PhortuneController {
$edit_uri = $this->getApplicationURI('product/edit/'.$product->getID().'/');
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($request->getRequestURI());
->setUser($viewer);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(

View file

@ -38,8 +38,7 @@ final class PhortuneSubscriptionViewController extends PhortuneController {
->setHeader($title);
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($request->getRequestURI());
->setUser($viewer);
$edit_uri = $subscription->getEditURI();

View file

@ -92,8 +92,7 @@ abstract class PhragmentController extends PhabricatorController {
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($fragment)
->setObjectURI($fragment->getURI());
->setObject($fragment);
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Download Fragment'))

View file

@ -106,8 +106,7 @@ final class PhragmentSnapshotViewController extends PhragmentController {
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($snapshot)
->setObjectURI($snapshot->getURI());
->setObject($snapshot);
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Download Snapshot as ZIP'))

View file

@ -51,8 +51,7 @@ final class PhragmentVersionController extends PhragmentController {
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($version)
->setObjectURI($version->getURI());
->setObject($version);
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Download Version'))

View file

@ -267,7 +267,6 @@ final class PhrictionDocumentController
$action_view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI($this->getRequest()->getRequestURI())
->setObject($document);
if (!$document->getID()) {

View file

@ -91,7 +91,6 @@ final class PhabricatorPhurlURLViewController
$id = $url->getID();
$actions = id(new PhabricatorActionListView())
->setObjectURI($url->getURI())
->setUser($viewer)
->setObject($url);

View file

@ -143,8 +143,7 @@ final class PonderQuestionViewController extends PonderController {
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($question)
->setObjectURI($request->getRequestURI());
->setObject($question);
$view->addAction(
id(new PhabricatorActionView())

View file

@ -168,8 +168,7 @@ final class PonderAnswerView extends AphrontTagView {
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($answer)
->setObjectURI('Q'.$answer->getQuestionID());
->setObject($answer);
$user_marked = $answer->getUserVote();
$can_vote = $viewer->isLoggedIn();

View file

@ -83,7 +83,6 @@ final class PhabricatorProjectColumnDetailController
$base_uri = '/board/'.$project_id.'/';
$actions = id(new PhabricatorActionListView())
->setObjectURI($this->getApplicationURI($base_uri.'column/'.$id.'/'))
->setUser($viewer);
$can_edit = PhabricatorPolicyFilter::hasCapability(

View file

@ -79,8 +79,7 @@ final class PhabricatorProjectProfileController
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($project)
->setObjectURI($request->getRequestURI());
->setObject($project);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,

View file

@ -87,8 +87,7 @@ final class ReleephBranchViewController extends ReleephBranchController {
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($branch)
->setObjectURI($this->getRequest()->getRequestURI());
->setObject($branch);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,

View file

@ -86,8 +86,7 @@ final class ReleephProductViewController extends ReleephProductController {
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($product)
->setObjectURI($this->getRequest()->getRequestURI());
->setObject($product);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,

View file

@ -102,8 +102,7 @@ final class PhabricatorSpacesViewController
$viewer = $this->getRequest()->getUser();
$list = id(new PhabricatorActionListView())
->setUser($viewer)
->setObjectURI('/'.$space->getMonogram());
->setUser($viewer);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,

View file

@ -4,7 +4,6 @@ final class PhabricatorActionListView extends AphrontView {
private $actions = array();
private $object;
private $objectURI;
private $id = null;
public function setObject(PhabricatorLiskDAO $object) {
@ -12,11 +11,6 @@ final class PhabricatorActionListView extends AphrontView {
return $this;
}
public function setObjectURI($uri) {
$this->objectURI = $uri;
return $this;
}
public function addAction(PhabricatorActionView $view) {
$this->actions[] = $view;
return $this;
@ -47,7 +41,6 @@ final class PhabricatorActionListView extends AphrontView {
}
foreach ($actions as $action) {
$action->setObjectURI($this->objectURI);
$action->setUser($this->user);
}

View file

@ -10,7 +10,6 @@ final class PhabricatorActionView extends AphrontView {
private $workflow;
private $renderAsForm;
private $download;
private $objectURI;
private $sigils = array();
private $metadata;
private $selected;
@ -34,15 +33,6 @@ final class PhabricatorActionView extends AphrontView {
return $this->metadata;
}
public function setObjectURI($object_uri) {
$this->objectURI = $object_uri;
return $this;
}
public function getObjectURI() {
return $this->objectURI;
}
public function setDownload($download) {
$this->download = $download;
return $this;
@ -62,19 +52,7 @@ final class PhabricatorActionView extends AphrontView {
return $this;
}
/**
* If the user is not logged in and the action is relatively complicated,
* give them a generic login link that will re-direct to the page they're
* viewing.
*/
public function getHref() {
if (($this->workflow || $this->renderAsForm) && !$this->download) {
if (!$this->user || !$this->user->isLoggedIn()) {
return id(new PhutilURI('/auth/start/'))
->setQueryParam('next', (string)$this->getObjectURI());
}
}
return $this->href;
}