@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make PhabricatorActionListView logged-out user savvy

Summary:
Fixes T2691. Now, all PhabricatorActionListViews in the codebase setObjectHref to $request->getRequestURI. This value is passed over to PhabricatorActionItems right before they are rendered. If a PhabricatorActionItem is a workflow and there is no user OR the user is logged out, we used this objectURI to construct a log in URI.

Potentially added some undesirable behavior to aggressively setUser (and later setObjectURI) from within the List on Actions... This should be okay-ish unless there was a vision of actions having different user objects associated with them. I think this is a safe assumption.

Test Plan: played around with a mock all logged out (Ref T2652) and it worked!

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2691

Differential Revision: https://secure.phabricator.com/D6416

+90 -37
+6 -5
src/applications/daemon/controller/PhabricatorWorkerTaskDetailController.php
··· 73 73 } 74 74 75 75 private function buildActionListView(PhabricatorWorkerTask $task) { 76 - $user = $this->getRequest()->getUser(); 76 + $request = $this->getRequest(); 77 + $user = $request->getUser(); 78 + $id = $task->getID(); 77 79 78 - $view = new PhabricatorActionListView(); 79 - $view->setUser($user); 80 - 81 - $id = $task->getID(); 80 + $view = id(new PhabricatorActionListView()) 81 + ->setUser($user) 82 + ->setObjectURI($request->getRequestURI()); 82 83 83 84 if ($task->isArchived()) { 84 85 $result_success = PhabricatorWorkerArchiveTask::RESULT_SUCCESS;
-1
src/applications/differential/events/DifferentialPeopleMenuEventListener.php
··· 25 25 $actions = $event->getValue('actions'); 26 26 27 27 $actions[] = id(new PhabricatorActionView()) 28 - ->setUser($event->getUser()) 29 28 ->setRenderAsForm(true) 30 29 ->setIcon('differential-dark') 31 30 ->setIconSheet(PHUIIconView::SPRITE_APPS)
+2 -1
src/applications/differential/view/DifferentialRevisionDetailView.php
··· 45 45 46 46 $actions = id(new PhabricatorActionListView()) 47 47 ->setUser($user) 48 - ->setObject($revision); 48 + ->setObject($revision) 49 + ->setObjectURI($this->getRequest()->getRequestURI()); 49 50 foreach ($this->getActions() as $action) { 50 51 $obj = id(new PhabricatorActionView()) 51 52 ->setIcon(idx($action, 'icon', 'edit'))
+3
src/applications/diffusion/controller/DiffusionBrowseFileController.php
··· 378 378 379 379 return id(new PhabricatorActionListView()) 380 380 ->setUser($user) 381 + ->setObjectURI($this->getRequest()->getRequestURI()) 381 382 ->addAction($blame_button) 382 383 ->addAction($highlight_button) 383 384 ->addAction($lint_button) ··· 821 822 822 823 $actions = id(new PhabricatorActionListView()) 823 824 ->setUser($this->getRequest()->getUser()) 825 + ->setObjectURI($this->getRequest()->getRequestURI()) 824 826 ->addAction($this->createEditAction()); 825 827 826 828 return array($actions, $properties); ··· 837 839 838 840 $actions = id(new PhabricatorActionListView()) 839 841 ->setUser($this->getRequest()->getUser()) 842 + ->setObjectURI($this->getRequest()->getRequestURI()) 840 843 ->addAction($this->createEditAction()) 841 844 ->addAction( 842 845 id(new PhabricatorActionView())
+2 -1
src/applications/diffusion/controller/DiffusionCommitController.php
··· 860 860 861 861 $actions = id(new PhabricatorActionListView()) 862 862 ->setUser($user) 863 - ->setObject($commit); 863 + ->setObject($commit) 864 + ->setObjectURI($request->getRequestURI()); 864 865 865 866 // TODO -- integrate permissions into whether or not this action is shown 866 867 $uri = '/diffusion/'.$repository->getCallSign().'/commit/'.
+2
src/applications/diffusion/controller/DiffusionRepositoryEditController.php
··· 70 70 $user = $this->getRequest()->getUser(); 71 71 72 72 $view = id(new PhabricatorActionListView()) 73 + ->setObjectURI($this->getRequest()->getRequestURI()) 73 74 ->setUser($user); 74 75 75 76 $can_edit = PhabricatorPolicyFilter::hasCapability( ··· 122 123 $user = $this->getRequest()->getUser(); 123 124 124 125 $view = id(new PhabricatorActionListView()) 126 + ->setObjectURI($this->getRequest()->getRequestURI()) 125 127 ->setUser($user); 126 128 127 129 $can_edit = PhabricatorPolicyFilter::hasCapability(
+1
src/applications/drydock/controller/DrydockLeaseViewController.php
··· 63 63 private function buildActionListView(DrydockLease $lease) { 64 64 $view = id(new PhabricatorActionListView()) 65 65 ->setUser($this->getRequest()->getUser()) 66 + ->setObjectURI($this->getRequest()->getRequestURI()) 66 67 ->setObject($lease); 67 68 68 69 $id = $lease->getID();
+1
src/applications/drydock/controller/DrydockResourceViewController.php
··· 76 76 private function buildActionListView(DrydockResource $resource) { 77 77 $view = id(new PhabricatorActionListView()) 78 78 ->setUser($this->getRequest()->getUser()) 79 + ->setObjectURI($this->getRequest()->getRequestURI()) 79 80 ->setObject($resource); 80 81 81 82 $can_close = ($resource->getStatus() == DrydockResourceStatus::STATUS_OPEN);
+1
src/applications/files/controller/PhabricatorFileInfoController.php
··· 65 65 66 66 $view = id(new PhabricatorActionListView()) 67 67 ->setUser($user) 68 + ->setObjectURI($this->getRequest()->getRequestURI()) 68 69 ->setObject($file); 69 70 70 71 if ($file->isViewableInBrowser()) {
+1
src/applications/legalpad/controller/LegalpadDocumentViewController.php
··· 123 123 124 124 $actions = id(new PhabricatorActionListView()) 125 125 ->setUser($user) 126 + ->setObjectURI($this->getRequest()->getRequestURI()) 126 127 ->setObject($document); 127 128 128 129 $can_edit = PhabricatorPolicyFilter::hasCapability(
+7 -5
src/applications/macro/controller/PhabricatorMacroViewController.php
··· 106 106 } 107 107 108 108 private function buildActionView(PhabricatorFileImageMacro $macro) { 109 - $view = new PhabricatorActionListView(); 110 - $view->setUser($this->getRequest()->getUser()); 111 - $view->setObject($macro); 112 - $view->addAction( 113 - id(new PhabricatorActionView()) 109 + $request = $this->getRequest(); 110 + $view = id(new PhabricatorActionListView()) 111 + ->setUser($request->getUser()) 112 + ->setObject($macro) 113 + ->setObjectURI($request->getRequestURI()) 114 + ->addAction( 115 + id(new PhabricatorActionView()) 114 116 ->setName(pht('Edit Macro')) 115 117 ->setHref($this->getApplicationURI('/edit/'.$macro->getID().'/')) 116 118 ->setIcon('edit'));
+5 -5
src/applications/maniphest/controller/ManiphestTaskDetailController.php
··· 381 381 $id = $task->getID(); 382 382 $phid = $task->getPHID(); 383 383 384 - $view = new PhabricatorActionListView(); 385 - $view->setUser($viewer); 386 - $view->setObject($task); 387 - 388 - $view->addAction( 384 + $view = id(new PhabricatorActionListView()) 385 + ->setUser($viewer) 386 + ->setObject($task) 387 + ->setObjectURI($this->getRequest()->getRequestURI()) 388 + ->addAction( 389 389 id(new PhabricatorActionView()) 390 390 ->setName(pht('Edit Task')) 391 391 ->setIcon('edit')
+2 -1
src/applications/meta/controller/PhabricatorApplicationDetailViewController.php
··· 79 79 PhabricatorUser $user, PhabricatorApplication $selected) { 80 80 81 81 $view = id(new PhabricatorActionListView()) 82 - ->setUser($user); 82 + ->setUser($user) 83 + ->setObjectURI($this->getRequest()->getRequestURI()); 83 84 84 85 if ($selected->canUninstall()) { 85 86 if ($selected->isInstalled()) {
+1
src/applications/paste/controller/PhabricatorPasteViewController.php
··· 94 94 return id(new PhabricatorActionListView()) 95 95 ->setUser($user) 96 96 ->setObject($paste) 97 + ->setObjectURI($this->getRequest()->getRequestURI()) 97 98 ->addAction( 98 99 id(new PhabricatorActionView()) 99 100 ->setName(pht('Fork This Paste'))
+1
src/applications/people/controller/PhabricatorPeopleProfileController.php
··· 38 38 39 39 $actions = id(new PhabricatorActionListView()) 40 40 ->setObject($user) 41 + ->setObjectURI($this->getRequest()->getRequestURI()) 41 42 ->setUser($viewer); 42 43 43 44 $can_edit = ($user->getPHID() == $viewer->getPHID());
+1
src/applications/phame/controller/blog/PhameBlogViewController.php
··· 144 144 145 145 $actions = id(new PhabricatorActionListView()) 146 146 ->setObject($blog) 147 + ->setObjectURI($this->getRequest()->getRequestURI()) 147 148 ->setUser($user); 148 149 149 150 $can_edit = PhabricatorPolicyFilter::hasCapability(
+1
src/applications/phame/controller/post/PhamePostViewController.php
··· 87 87 88 88 $actions = id(new PhabricatorActionListView()) 89 89 ->setObject($post) 90 + ->setObjectURI($this->getRequest()->getRequestURI()) 90 91 ->setUser($user); 91 92 92 93 $can_edit = PhabricatorPolicyFilter::hasCapability(
+1
src/applications/phlux/controller/PhluxViewController.php
··· 35 35 36 36 $actions = id(new PhabricatorActionListView()) 37 37 ->setUser($user) 38 + ->setObjectURI($request->getRequestURI()) 38 39 ->setObject($var); 39 40 40 41 $can_edit = PhabricatorPolicyFilter::hasCapability(
+1
src/applications/pholio/controller/PholioMockViewController.php
··· 109 109 110 110 $actions = id(new PhabricatorActionListView()) 111 111 ->setUser($user) 112 + ->setObjectURI($this->getRequest()->getRequestURI()) 112 113 ->setObject($mock); 113 114 114 115 $can_edit = PhabricatorPolicyFilter::hasCapability(
+2
src/applications/phortune/controller/PhortuneAccountViewController.php
··· 34 34 35 35 $actions = id(new PhabricatorActionListView()) 36 36 ->setUser($user) 37 + ->setObjectURI($request->getRequestURI()) 37 38 ->addAction( 38 39 id(new PhabricatorActionView()) 39 40 ->setName(pht('Edit Account')) ··· 88 89 89 90 $actions = id(new PhabricatorActionListView()) 90 91 ->setUser($user) 92 + ->setObjectURI($request->getRequestURI()) 91 93 ->addAction( 92 94 id(new PhabricatorActionView()) 93 95 ->setName(pht('Add Payment Method'))
+1
src/applications/phortune/controller/PhortuneProductViewController.php
··· 34 34 35 35 $actions = id(new PhabricatorActionListView()) 36 36 ->setUser($user) 37 + ->setObjectURI($request->getRequestURI()) 37 38 ->addAction( 38 39 id(new PhabricatorActionView()) 39 40 ->setName(pht('Edit Product'))
-2
src/applications/phrequent/event/PhrequentUIEventListener.php
··· 38 38 $object->getPHID()); 39 39 if (!$tracking) { 40 40 $track_action = id(new PhabricatorActionView()) 41 - ->setUser($user) 42 41 ->setName(pht('Start Tracking Time')) 43 42 ->setIcon('history') 44 43 ->setWorkflow(true) ··· 46 45 ->setHref('/phrequent/track/start/'.$object->getPHID().'/'); 47 46 } else { 48 47 $track_action = id(new PhabricatorActionView()) 49 - ->setUser($user) 50 48 ->setName(pht('Stop Tracking Time')) 51 49 ->setIcon('history') 52 50 ->setWorkflow(true)
+1
src/applications/phriction/controller/PhrictionDocumentController.php
··· 273 273 274 274 $action_view = id(new PhabricatorActionListView()) 275 275 ->setUser($user) 276 + ->setObjectURI($this->getRequest()->getRequestURI()) 276 277 ->setObject($document); 277 278 278 279 if (!$document->getID()) {
+5 -7
src/applications/ponder/controller/PonderQuestionViewController.php
··· 100 100 } 101 101 102 102 private function buildActionListView(PonderQuestion $question) { 103 - $viewer = $this->getRequest()->getUser(); 104 - $view = new PhabricatorActionListView(); 105 - 106 - $view->setUser($viewer); 107 - $view->setObject($question); 108 - 109 - return $view; 103 + $request = $this->getRequest(); 104 + return id(new PhabricatorActionListView()) 105 + ->setUser($request->getUser()) 106 + ->setObject($question) 107 + ->setObjectURI($request->getRequestURI()); 110 108 } 111 109 112 110 private function buildPropertyListView(
+1
src/applications/project/controller/PhabricatorProjectProfileController.php
··· 94 94 95 95 $action_list = id(new PhabricatorActionListView()) 96 96 ->setUser($user) 97 + ->setObjectURI($request->getRequestURI()) 97 98 ->addAction($action); 98 99 99 100 $nav_view->appendChild($header);
-3
src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php
··· 36 36 if ($object->isAutomaticallySubscribed($user->getPHID())) { 37 37 $sub_action = id(new PhabricatorActionView()) 38 38 ->setWorkflow(true) 39 - ->setUser($user) 40 39 ->setDisabled(true) 41 40 ->setRenderAsForm(true) 42 41 ->setHref('/subscriptions/add/'.$object->getPHID().'/') ··· 59 58 60 59 if ($subscribed) { 61 60 $sub_action = id(new PhabricatorActionView()) 62 - ->setUser($user) 63 61 ->setWorkflow(true) 64 62 ->setRenderAsForm(true) 65 63 ->setHref('/subscriptions/delete/'.$object->getPHID().'/') ··· 67 65 ->setIcon('disable'); 68 66 } else { 69 67 $sub_action = id(new PhabricatorActionView()) 70 - ->setUser($user) 71 68 ->setWorkflow(true) 72 69 ->setRenderAsForm(true) 73 70 ->setHref('/subscriptions/add/'.$object->getPHID().'/')
-2
src/applications/tokens/event/PhabricatorTokenUIEventListener.php
··· 41 41 42 42 if (!$current) { 43 43 $token_action = id(new PhabricatorActionView()) 44 - ->setUser($user) 45 44 ->setWorkflow(true) 46 45 ->setHref('/token/give/'.$object->getPHID().'/') 47 46 ->setName(pht('Award Token')) 48 47 ->setIcon('like'); 49 48 } else { 50 49 $token_action = id(new PhabricatorActionView()) 51 - ->setUser($user) 52 50 ->setWorkflow(true) 53 51 ->setHref('/token/give/'.$object->getPHID().'/') 54 52 ->setName(pht('Rescind Token'))
+3 -2
src/applications/uiexample/examples/PhabricatorActionListExample.php
··· 41 41 return id(new AphrontDialogResponse())->setDialog($dialog); 42 42 } 43 43 44 - $view = new PhabricatorActionListView(); 45 - $view->setUser($user); 44 + $view = id(new PhabricatorActionListView()) 45 + ->setUser($user) 46 + ->setObjectURI($this->getRequest()->getRequestURI()); 46 47 47 48 $view->addAction( 48 49 id(new PhabricatorActionView())
+11
src/view/layout/PhabricatorActionListView.php
··· 4 4 5 5 private $actions = array(); 6 6 private $object; 7 + private $objectURI; 7 8 private $id = null; 8 9 9 10 public function setObject(PhabricatorLiskDAO $object) { 10 11 $this->object = $object; 12 + return $this; 13 + } 14 + 15 + public function setObjectURI($uri) { 16 + $this->objectURI = $uri; 11 17 return $this; 12 18 } 13 19 ··· 39 45 40 46 if (!$actions) { 41 47 return null; 48 + } 49 + 50 + foreach ($actions as $action) { 51 + $action->setObjectURI($this->objectURI); 52 + $action->setUser($this->user); 42 53 } 43 54 44 55 require_celerity_resource('phabricator-action-list-view-css');
+27 -2
src/view/layout/PhabricatorActionView.php
··· 10 10 private $workflow; 11 11 private $renderAsForm; 12 12 private $download; 13 + private $objectURI; 14 + 15 + public function setObjectURI($object_uri) { 16 + $this->objectURI = $object_uri; 17 + return $this; 18 + } 19 + public function getObjectURI() { 20 + return $this->objectURI; 21 + } 13 22 14 23 public function setDownload($download) { 15 24 $this->download = $download; ··· 23 32 public function setHref($href) { 24 33 $this->href = $href; 25 34 return $this; 35 + } 36 + 37 + /** 38 + * If the user is not logged in and the action is relatively complicated, 39 + * give them a generic login link that will re-direct to the page they're 40 + * viewing. 41 + */ 42 + public function getHref() { 43 + if ($this->workflow || $this->renderAsForm) { 44 + if (!$this->user || !$this->user->isLoggedIn()) { 45 + return id(new PhutilURI('/auth/start/')) 46 + ->setQueryParam('next', (string)$this->getObjectURI()); 47 + } 48 + } 49 + 50 + return $this->href; 26 51 } 27 52 28 53 public function setIcon($icon) { ··· 97 122 $item = phabricator_form( 98 123 $this->user, 99 124 array( 100 - 'action' => $this->href, 125 + 'action' => $this->getHref(), 101 126 'method' => 'POST', 102 127 'sigil' => implode(' ', $sigils), 103 128 ), ··· 106 131 $item = javelin_tag( 107 132 'a', 108 133 array( 109 - 'href' => $this->href, 134 + 'href' => $this->getHref(), 110 135 'class' => 'phabricator-action-view-item', 111 136 'sigil' => $this->workflow ? 'workflow' : null, 112 137 ),