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
This commit is contained in:
@@ -73,13 +73,14 @@ final class PhabricatorWorkerTaskDetailController
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function buildActionListView(PhabricatorWorkerTask $task) {
|
private function buildActionListView(PhabricatorWorkerTask $task) {
|
||||||
$user = $this->getRequest()->getUser();
|
$request = $this->getRequest();
|
||||||
|
$user = $request->getUser();
|
||||||
$view = new PhabricatorActionListView();
|
|
||||||
$view->setUser($user);
|
|
||||||
|
|
||||||
$id = $task->getID();
|
$id = $task->getID();
|
||||||
|
|
||||||
|
$view = id(new PhabricatorActionListView())
|
||||||
|
->setUser($user)
|
||||||
|
->setObjectURI($request->getRequestURI());
|
||||||
|
|
||||||
if ($task->isArchived()) {
|
if ($task->isArchived()) {
|
||||||
$result_success = PhabricatorWorkerArchiveTask::RESULT_SUCCESS;
|
$result_success = PhabricatorWorkerArchiveTask::RESULT_SUCCESS;
|
||||||
$can_retry = ($task->getResult() != $result_success);
|
$can_retry = ($task->getResult() != $result_success);
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ final class DifferentialPeopleMenuEventListener extends PhutilEventListener {
|
|||||||
$actions = $event->getValue('actions');
|
$actions = $event->getValue('actions');
|
||||||
|
|
||||||
$actions[] = id(new PhabricatorActionView())
|
$actions[] = id(new PhabricatorActionView())
|
||||||
->setUser($event->getUser())
|
|
||||||
->setRenderAsForm(true)
|
->setRenderAsForm(true)
|
||||||
->setIcon('differential-dark')
|
->setIcon('differential-dark')
|
||||||
->setIconSheet(PHUIIconView::SPRITE_APPS)
|
->setIconSheet(PHUIIconView::SPRITE_APPS)
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ final class DifferentialRevisionDetailView extends AphrontView {
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setObject($revision);
|
->setObject($revision)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI());
|
||||||
foreach ($this->getActions() as $action) {
|
foreach ($this->getActions() as $action) {
|
||||||
$obj = id(new PhabricatorActionView())
|
$obj = id(new PhabricatorActionView())
|
||||||
->setIcon(idx($action, 'icon', 'edit'))
|
->setIcon(idx($action, 'icon', 'edit'))
|
||||||
|
|||||||
@@ -378,6 +378,7 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
|||||||
|
|
||||||
return id(new PhabricatorActionListView())
|
return id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->addAction($blame_button)
|
->addAction($blame_button)
|
||||||
->addAction($highlight_button)
|
->addAction($highlight_button)
|
||||||
->addAction($lint_button)
|
->addAction($lint_button)
|
||||||
@@ -821,6 +822,7 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setUser($this->getRequest()->getUser())
|
->setUser($this->getRequest()->getUser())
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->addAction($this->createEditAction());
|
->addAction($this->createEditAction());
|
||||||
|
|
||||||
return array($actions, $properties);
|
return array($actions, $properties);
|
||||||
@@ -837,6 +839,7 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setUser($this->getRequest()->getUser())
|
->setUser($this->getRequest()->getUser())
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->addAction($this->createEditAction())
|
->addAction($this->createEditAction())
|
||||||
->addAction(
|
->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
|
|||||||
@@ -860,7 +860,8 @@ final class DiffusionCommitController extends DiffusionController {
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setObject($commit);
|
->setObject($commit)
|
||||||
|
->setObjectURI($request->getRequestURI());
|
||||||
|
|
||||||
// TODO -- integrate permissions into whether or not this action is shown
|
// TODO -- integrate permissions into whether or not this action is shown
|
||||||
$uri = '/diffusion/'.$repository->getCallSign().'/commit/'.
|
$uri = '/diffusion/'.$repository->getCallSign().'/commit/'.
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ final class DiffusionRepositoryEditController extends DiffusionController {
|
|||||||
$user = $this->getRequest()->getUser();
|
$user = $this->getRequest()->getUser();
|
||||||
|
|
||||||
$view = id(new PhabricatorActionListView())
|
$view = id(new PhabricatorActionListView())
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->setUser($user);
|
->setUser($user);
|
||||||
|
|
||||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
@@ -122,6 +123,7 @@ final class DiffusionRepositoryEditController extends DiffusionController {
|
|||||||
$user = $this->getRequest()->getUser();
|
$user = $this->getRequest()->getUser();
|
||||||
|
|
||||||
$view = id(new PhabricatorActionListView())
|
$view = id(new PhabricatorActionListView())
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->setUser($user);
|
->setUser($user);
|
||||||
|
|
||||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ final class DrydockLeaseViewController extends DrydockController {
|
|||||||
private function buildActionListView(DrydockLease $lease) {
|
private function buildActionListView(DrydockLease $lease) {
|
||||||
$view = id(new PhabricatorActionListView())
|
$view = id(new PhabricatorActionListView())
|
||||||
->setUser($this->getRequest()->getUser())
|
->setUser($this->getRequest()->getUser())
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->setObject($lease);
|
->setObject($lease);
|
||||||
|
|
||||||
$id = $lease->getID();
|
$id = $lease->getID();
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ final class DrydockResourceViewController extends DrydockController {
|
|||||||
private function buildActionListView(DrydockResource $resource) {
|
private function buildActionListView(DrydockResource $resource) {
|
||||||
$view = id(new PhabricatorActionListView())
|
$view = id(new PhabricatorActionListView())
|
||||||
->setUser($this->getRequest()->getUser())
|
->setUser($this->getRequest()->getUser())
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->setObject($resource);
|
->setObject($resource);
|
||||||
|
|
||||||
$can_close = ($resource->getStatus() == DrydockResourceStatus::STATUS_OPEN);
|
$can_close = ($resource->getStatus() == DrydockResourceStatus::STATUS_OPEN);
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ final class PhabricatorFileInfoController extends PhabricatorFileController {
|
|||||||
|
|
||||||
$view = id(new PhabricatorActionListView())
|
$view = id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->setObject($file);
|
->setObject($file);
|
||||||
|
|
||||||
if ($file->isViewableInBrowser()) {
|
if ($file->isViewableInBrowser()) {
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ final class LegalpadDocumentViewController extends LegalpadController {
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->setObject($document);
|
->setObject($document);
|
||||||
|
|
||||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
|||||||
@@ -106,10 +106,12 @@ final class PhabricatorMacroViewController
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function buildActionView(PhabricatorFileImageMacro $macro) {
|
private function buildActionView(PhabricatorFileImageMacro $macro) {
|
||||||
$view = new PhabricatorActionListView();
|
$request = $this->getRequest();
|
||||||
$view->setUser($this->getRequest()->getUser());
|
$view = id(new PhabricatorActionListView())
|
||||||
$view->setObject($macro);
|
->setUser($request->getUser())
|
||||||
$view->addAction(
|
->setObject($macro)
|
||||||
|
->setObjectURI($request->getRequestURI())
|
||||||
|
->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Edit Macro'))
|
->setName(pht('Edit Macro'))
|
||||||
->setHref($this->getApplicationURI('/edit/'.$macro->getID().'/'))
|
->setHref($this->getApplicationURI('/edit/'.$macro->getID().'/'))
|
||||||
|
|||||||
@@ -381,11 +381,11 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||||||
$id = $task->getID();
|
$id = $task->getID();
|
||||||
$phid = $task->getPHID();
|
$phid = $task->getPHID();
|
||||||
|
|
||||||
$view = new PhabricatorActionListView();
|
$view = id(new PhabricatorActionListView())
|
||||||
$view->setUser($viewer);
|
->setUser($viewer)
|
||||||
$view->setObject($task);
|
->setObject($task)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
$view->addAction(
|
->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Edit Task'))
|
->setName(pht('Edit Task'))
|
||||||
->setIcon('edit')
|
->setIcon('edit')
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ final class PhabricatorApplicationDetailViewController
|
|||||||
PhabricatorUser $user, PhabricatorApplication $selected) {
|
PhabricatorUser $user, PhabricatorApplication $selected) {
|
||||||
|
|
||||||
$view = id(new PhabricatorActionListView())
|
$view = id(new PhabricatorActionListView())
|
||||||
->setUser($user);
|
->setUser($user)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI());
|
||||||
|
|
||||||
if ($selected->canUninstall()) {
|
if ($selected->canUninstall()) {
|
||||||
if ($selected->isInstalled()) {
|
if ($selected->isInstalled()) {
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
|
|||||||
return id(new PhabricatorActionListView())
|
return id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setObject($paste)
|
->setObject($paste)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->addAction(
|
->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Fork This Paste'))
|
->setName(pht('Fork This Paste'))
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ final class PhabricatorPeopleProfileController
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setObject($user)
|
->setObject($user)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->setUser($viewer);
|
->setUser($viewer);
|
||||||
|
|
||||||
$can_edit = ($user->getPHID() == $viewer->getPHID());
|
$can_edit = ($user->getPHID() == $viewer->getPHID());
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ final class PhameBlogViewController extends PhameController {
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setObject($blog)
|
->setObject($blog)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->setUser($user);
|
->setUser($user);
|
||||||
|
|
||||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ final class PhamePostViewController extends PhameController {
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setObject($post)
|
->setObject($post)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->setUser($user);
|
->setUser($user);
|
||||||
|
|
||||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ final class PhluxViewController extends PhluxController {
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
->setObjectURI($request->getRequestURI())
|
||||||
->setObject($var);
|
->setObject($var);
|
||||||
|
|
||||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ final class PholioMockViewController extends PholioController {
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->setObject($mock);
|
->setObject($mock);
|
||||||
|
|
||||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ final class PhortuneAccountViewController extends PhortuneController {
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
->setObjectURI($request->getRequestURI())
|
||||||
->addAction(
|
->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Edit Account'))
|
->setName(pht('Edit Account'))
|
||||||
@@ -88,6 +89,7 @@ final class PhortuneAccountViewController extends PhortuneController {
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
->setObjectURI($request->getRequestURI())
|
||||||
->addAction(
|
->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Add Payment Method'))
|
->setName(pht('Add Payment Method'))
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ final class PhortuneProductViewController extends PhortuneController {
|
|||||||
|
|
||||||
$actions = id(new PhabricatorActionListView())
|
$actions = id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
->setObjectURI($request->getRequestURI())
|
||||||
->addAction(
|
->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Edit Product'))
|
->setName(pht('Edit Product'))
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ final class PhrequentUIEventListener
|
|||||||
$object->getPHID());
|
$object->getPHID());
|
||||||
if (!$tracking) {
|
if (!$tracking) {
|
||||||
$track_action = id(new PhabricatorActionView())
|
$track_action = id(new PhabricatorActionView())
|
||||||
->setUser($user)
|
|
||||||
->setName(pht('Start Tracking Time'))
|
->setName(pht('Start Tracking Time'))
|
||||||
->setIcon('history')
|
->setIcon('history')
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
@@ -46,7 +45,6 @@ final class PhrequentUIEventListener
|
|||||||
->setHref('/phrequent/track/start/'.$object->getPHID().'/');
|
->setHref('/phrequent/track/start/'.$object->getPHID().'/');
|
||||||
} else {
|
} else {
|
||||||
$track_action = id(new PhabricatorActionView())
|
$track_action = id(new PhabricatorActionView())
|
||||||
->setUser($user)
|
|
||||||
->setName(pht('Stop Tracking Time'))
|
->setName(pht('Stop Tracking Time'))
|
||||||
->setIcon('history')
|
->setIcon('history')
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
|
|||||||
@@ -273,6 +273,7 @@ final class PhrictionDocumentController
|
|||||||
|
|
||||||
$action_view = id(new PhabricatorActionListView())
|
$action_view = id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI())
|
||||||
->setObject($document);
|
->setObject($document);
|
||||||
|
|
||||||
if (!$document->getID()) {
|
if (!$document->getID()) {
|
||||||
|
|||||||
@@ -100,13 +100,11 @@ final class PonderQuestionViewController extends PonderController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function buildActionListView(PonderQuestion $question) {
|
private function buildActionListView(PonderQuestion $question) {
|
||||||
$viewer = $this->getRequest()->getUser();
|
$request = $this->getRequest();
|
||||||
$view = new PhabricatorActionListView();
|
return id(new PhabricatorActionListView())
|
||||||
|
->setUser($request->getUser())
|
||||||
$view->setUser($viewer);
|
->setObject($question)
|
||||||
$view->setObject($question);
|
->setObjectURI($request->getRequestURI());
|
||||||
|
|
||||||
return $view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildPropertyListView(
|
private function buildPropertyListView(
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ final class PhabricatorProjectProfileController
|
|||||||
|
|
||||||
$action_list = id(new PhabricatorActionListView())
|
$action_list = id(new PhabricatorActionListView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
->setObjectURI($request->getRequestURI())
|
||||||
->addAction($action);
|
->addAction($action);
|
||||||
|
|
||||||
$nav_view->appendChild($header);
|
$nav_view->appendChild($header);
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ final class PhabricatorSubscriptionsUIEventListener
|
|||||||
if ($object->isAutomaticallySubscribed($user->getPHID())) {
|
if ($object->isAutomaticallySubscribed($user->getPHID())) {
|
||||||
$sub_action = id(new PhabricatorActionView())
|
$sub_action = id(new PhabricatorActionView())
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
->setUser($user)
|
|
||||||
->setDisabled(true)
|
->setDisabled(true)
|
||||||
->setRenderAsForm(true)
|
->setRenderAsForm(true)
|
||||||
->setHref('/subscriptions/add/'.$object->getPHID().'/')
|
->setHref('/subscriptions/add/'.$object->getPHID().'/')
|
||||||
@@ -59,7 +58,6 @@ final class PhabricatorSubscriptionsUIEventListener
|
|||||||
|
|
||||||
if ($subscribed) {
|
if ($subscribed) {
|
||||||
$sub_action = id(new PhabricatorActionView())
|
$sub_action = id(new PhabricatorActionView())
|
||||||
->setUser($user)
|
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
->setRenderAsForm(true)
|
->setRenderAsForm(true)
|
||||||
->setHref('/subscriptions/delete/'.$object->getPHID().'/')
|
->setHref('/subscriptions/delete/'.$object->getPHID().'/')
|
||||||
@@ -67,7 +65,6 @@ final class PhabricatorSubscriptionsUIEventListener
|
|||||||
->setIcon('disable');
|
->setIcon('disable');
|
||||||
} else {
|
} else {
|
||||||
$sub_action = id(new PhabricatorActionView())
|
$sub_action = id(new PhabricatorActionView())
|
||||||
->setUser($user)
|
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
->setRenderAsForm(true)
|
->setRenderAsForm(true)
|
||||||
->setHref('/subscriptions/add/'.$object->getPHID().'/')
|
->setHref('/subscriptions/add/'.$object->getPHID().'/')
|
||||||
|
|||||||
@@ -41,14 +41,12 @@ final class PhabricatorTokenUIEventListener
|
|||||||
|
|
||||||
if (!$current) {
|
if (!$current) {
|
||||||
$token_action = id(new PhabricatorActionView())
|
$token_action = id(new PhabricatorActionView())
|
||||||
->setUser($user)
|
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
->setHref('/token/give/'.$object->getPHID().'/')
|
->setHref('/token/give/'.$object->getPHID().'/')
|
||||||
->setName(pht('Award Token'))
|
->setName(pht('Award Token'))
|
||||||
->setIcon('like');
|
->setIcon('like');
|
||||||
} else {
|
} else {
|
||||||
$token_action = id(new PhabricatorActionView())
|
$token_action = id(new PhabricatorActionView())
|
||||||
->setUser($user)
|
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
->setHref('/token/give/'.$object->getPHID().'/')
|
->setHref('/token/give/'.$object->getPHID().'/')
|
||||||
->setName(pht('Rescind Token'))
|
->setName(pht('Rescind Token'))
|
||||||
|
|||||||
@@ -41,8 +41,9 @@ final class PhabricatorActionListExample extends PhabricatorUIExample {
|
|||||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = new PhabricatorActionListView();
|
$view = id(new PhabricatorActionListView())
|
||||||
$view->setUser($user);
|
->setUser($user)
|
||||||
|
->setObjectURI($this->getRequest()->getRequestURI());
|
||||||
|
|
||||||
$view->addAction(
|
$view->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ final class PhabricatorActionListView extends AphrontView {
|
|||||||
|
|
||||||
private $actions = array();
|
private $actions = array();
|
||||||
private $object;
|
private $object;
|
||||||
|
private $objectURI;
|
||||||
private $id = null;
|
private $id = null;
|
||||||
|
|
||||||
public function setObject(PhabricatorLiskDAO $object) {
|
public function setObject(PhabricatorLiskDAO $object) {
|
||||||
@@ -11,6 +12,11 @@ final class PhabricatorActionListView extends AphrontView {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setObjectURI($uri) {
|
||||||
|
$this->objectURI = $uri;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function addAction(PhabricatorActionView $view) {
|
public function addAction(PhabricatorActionView $view) {
|
||||||
$this->actions[] = $view;
|
$this->actions[] = $view;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -41,6 +47,11 @@ final class PhabricatorActionListView extends AphrontView {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($actions as $action) {
|
||||||
|
$action->setObjectURI($this->objectURI);
|
||||||
|
$action->setUser($this->user);
|
||||||
|
}
|
||||||
|
|
||||||
require_celerity_resource('phabricator-action-list-view-css');
|
require_celerity_resource('phabricator-action-list-view-css');
|
||||||
|
|
||||||
return phutil_tag(
|
return phutil_tag(
|
||||||
|
|||||||
@@ -10,6 +10,15 @@ final class PhabricatorActionView extends AphrontView {
|
|||||||
private $workflow;
|
private $workflow;
|
||||||
private $renderAsForm;
|
private $renderAsForm;
|
||||||
private $download;
|
private $download;
|
||||||
|
private $objectURI;
|
||||||
|
|
||||||
|
public function setObjectURI($object_uri) {
|
||||||
|
$this->objectURI = $object_uri;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function getObjectURI() {
|
||||||
|
return $this->objectURI;
|
||||||
|
}
|
||||||
|
|
||||||
public function setDownload($download) {
|
public function setDownload($download) {
|
||||||
$this->download = $download;
|
$this->download = $download;
|
||||||
@@ -25,6 +34,22 @@ final class PhabricatorActionView extends AphrontView {
|
|||||||
return $this;
|
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) {
|
||||||
|
if (!$this->user || !$this->user->isLoggedIn()) {
|
||||||
|
return id(new PhutilURI('/auth/start/'))
|
||||||
|
->setQueryParam('next', (string)$this->getObjectURI());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->href;
|
||||||
|
}
|
||||||
|
|
||||||
public function setIcon($icon) {
|
public function setIcon($icon) {
|
||||||
$this->icon = $icon;
|
$this->icon = $icon;
|
||||||
return $this;
|
return $this;
|
||||||
@@ -97,7 +122,7 @@ final class PhabricatorActionView extends AphrontView {
|
|||||||
$item = phabricator_form(
|
$item = phabricator_form(
|
||||||
$this->user,
|
$this->user,
|
||||||
array(
|
array(
|
||||||
'action' => $this->href,
|
'action' => $this->getHref(),
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'sigil' => implode(' ', $sigils),
|
'sigil' => implode(' ', $sigils),
|
||||||
),
|
),
|
||||||
@@ -106,7 +131,7 @@ final class PhabricatorActionView extends AphrontView {
|
|||||||
$item = javelin_tag(
|
$item = javelin_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'href' => $this->href,
|
'href' => $this->getHref(),
|
||||||
'class' => 'phabricator-action-view-item',
|
'class' => 'phabricator-action-view-item',
|
||||||
'sigil' => $this->workflow ? 'workflow' : null,
|
'sigil' => $this->workflow ? 'workflow' : null,
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user