mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-04 12:42:43 +01:00
make applicationTransactionsCommentView have a "Login to comment." button if user is not logged in
Summary: okay title. other apps can get this by implementing shouldAllowPublic and set(ting)RequestURI on TransactionsCommentView. note i put some css inline -- let me know if that belongs someplace else or needs better design. Test Plan: viewed a mock logged out and saw new button. used new button and ended up on the mock logged in with a clean URI. Reviewers: epriestley, chad Reviewed By: chad CC: aran, Korvin Maniphest Tasks: T2653 Differential Revision: https://secure.phabricator.com/D5266
This commit is contained in:
parent
e6c73a8396
commit
e3181fcbe7
6 changed files with 75 additions and 13 deletions
|
@ -70,11 +70,15 @@ final class PhabricatorLoginController
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$next_uri_path = $this->getRequest()->getPath();
|
|
||||||
if ($next_uri_path == '/login/') {
|
$next_uri = $request->getStr('next');
|
||||||
$next_uri = '/';
|
if (!$next_uri) {
|
||||||
} else {
|
$next_uri_path = $this->getRequest()->getPath();
|
||||||
$next_uri = $this->getRequest()->getRequestURI();
|
if ($next_uri_path == '/login/') {
|
||||||
|
$next_uri = '/';
|
||||||
|
} else {
|
||||||
|
$next_uri = $this->getRequest()->getRequestURI();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$request->isFormPost()) {
|
if (!$request->isFormPost()) {
|
||||||
|
@ -139,10 +143,9 @@ final class PhabricatorLoginController
|
||||||
$request->setCookie('phusr', $user->getUsername());
|
$request->setCookie('phusr', $user->getUsername());
|
||||||
$request->setCookie('phsid', $session_key);
|
$request->setCookie('phsid', $session_key);
|
||||||
|
|
||||||
$uri = new PhutilURI('/login/validate/');
|
$uri = id(new PhutilURI('/login/validate/'))
|
||||||
$uri->setQueryParams(
|
->setQueryParams(
|
||||||
array(
|
array('phusr' => $user->getUsername()
|
||||||
'phusr' => $user->getUsername(),
|
|
||||||
));
|
));
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())
|
return id(new AphrontRedirectResponse())
|
||||||
|
|
|
@ -8,6 +8,10 @@ final class PholioMockViewController extends PholioController {
|
||||||
private $id;
|
private $id;
|
||||||
private $imageID;
|
private $imageID;
|
||||||
|
|
||||||
|
public function shouldAllowPublic() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function willProcessRequest(array $data) {
|
public function willProcessRequest(array $data) {
|
||||||
$this->id = $data['id'];
|
$this->id = $data['id'];
|
||||||
$this->imageID = idx($data, 'imageID');
|
$this->imageID = idx($data, 'imageID');
|
||||||
|
@ -67,9 +71,11 @@ final class PholioMockViewController extends PholioController {
|
||||||
require_celerity_resource('pholio-css');
|
require_celerity_resource('pholio-css');
|
||||||
require_celerity_resource('pholio-inline-comments-css');
|
require_celerity_resource('pholio-inline-comments-css');
|
||||||
|
|
||||||
$output = new PholioMockImagesView();
|
$output = id(new PholioMockImagesView())
|
||||||
$output->setMock($mock);
|
->setRequestURI($request->getRequestURI())
|
||||||
$output->setImageID($this->imageID);
|
->setUser($user)
|
||||||
|
->setMock($mock)
|
||||||
|
->setImageID($this->imageID);
|
||||||
|
|
||||||
$xaction_view = id(new PhabricatorApplicationTransactionView())
|
$xaction_view = id(new PhabricatorApplicationTransactionView())
|
||||||
->setUser($this->getRequest()->getUser())
|
->setUser($this->getRequest()->getUser())
|
||||||
|
@ -201,7 +207,8 @@ final class PholioMockViewController extends PholioController {
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setDraft($draft)
|
->setDraft($draft)
|
||||||
->setSubmitButtonName($button_name)
|
->setSubmitButtonName($button_name)
|
||||||
->setAction($this->getApplicationURI('/comment/'.$mock->getID().'/'));
|
->setAction($this->getApplicationURI('/comment/'.$mock->getID().'/'))
|
||||||
|
->setRequestURI($this->getRequest()->getRequestURI());
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
$header,
|
$header,
|
||||||
|
|
|
@ -4,6 +4,15 @@ final class PholioMockImagesView extends AphrontView {
|
||||||
|
|
||||||
private $mock;
|
private $mock;
|
||||||
private $imageID;
|
private $imageID;
|
||||||
|
private $requestURI;
|
||||||
|
|
||||||
|
public function setRequestURI(PhutilURI $request_uri) {
|
||||||
|
$this->requestURI = $request_uri;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function getRequestURI() {
|
||||||
|
return $this->requestURI;
|
||||||
|
}
|
||||||
|
|
||||||
public function setImageID($image_id) {
|
public function setImageID($image_id) {
|
||||||
$this->imageID = $image_id;
|
$this->imageID = $image_id;
|
||||||
|
@ -57,12 +66,16 @@ final class PholioMockImagesView extends AphrontView {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$login_uri = id(new PhutilURI('/login/'))
|
||||||
|
->setQueryParam('next', (string) $this->getRequestURI());
|
||||||
$config = array(
|
$config = array(
|
||||||
'mockID' => $mock->getID(),
|
'mockID' => $mock->getID(),
|
||||||
'panelID' => $panel_id,
|
'panelID' => $panel_id,
|
||||||
'viewportID' => $viewport_id,
|
'viewportID' => $viewport_id,
|
||||||
'images' => $images,
|
'images' => $images,
|
||||||
'selectedID' => $selected_id,
|
'selectedID' => $selected_id,
|
||||||
|
'loggedIn' => $this->getUser()->isLoggedIn(),
|
||||||
|
'logInLink' => (string) $login_uri
|
||||||
);
|
);
|
||||||
Javelin::initBehavior('pholio-mock-view', $config);
|
Javelin::initBehavior('pholio-mock-view', $config);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,15 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView {
|
||||||
private $statusID;
|
private $statusID;
|
||||||
private $commentID;
|
private $commentID;
|
||||||
private $draft;
|
private $draft;
|
||||||
|
private $requestURI;
|
||||||
|
|
||||||
|
public function setRequestURI(PhutilURI $request_uri) {
|
||||||
|
$this->requestURI = $request_uri;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function getRequestURI() {
|
||||||
|
return $this->requestURI;
|
||||||
|
}
|
||||||
|
|
||||||
public function setDraft(PhabricatorDraft $draft) {
|
public function setDraft(PhabricatorDraft $draft) {
|
||||||
$this->draft = $draft;
|
$this->draft = $draft;
|
||||||
|
@ -45,6 +54,26 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView {
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
|
|
||||||
|
$user = $this->getUser();
|
||||||
|
if (!$user->isLoggedIn()) {
|
||||||
|
$uri = id(new PhutilURI('/login/'))
|
||||||
|
->setQueryParam('next', (string) $this->getRequestURI());
|
||||||
|
return self::renderSingleView(
|
||||||
|
phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'login-to-comment'
|
||||||
|
),
|
||||||
|
javelin_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'class' => 'button',
|
||||||
|
'sigil' => 'workflow',
|
||||||
|
'href' => $uri
|
||||||
|
),
|
||||||
|
pht('Login to Comment'))));
|
||||||
|
}
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
$comment = $this->renderCommentPanel();
|
$comment = $this->renderCommentPanel();
|
||||||
|
|
|
@ -363,3 +363,8 @@ table.aphront-form-control-checkbox-layout th {
|
||||||
.picker-open .calendar-button {
|
.picker-open .calendar-button {
|
||||||
border-left: 1px solid white;
|
border-left: 1px solid white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.login-to-comment {
|
||||||
|
padding: 12px;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
|
@ -303,6 +303,11 @@ JX.behavior('pholio-mock-view', function(config) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
is_dragging = false;
|
is_dragging = false;
|
||||||
|
if (!config.loggedIn) {
|
||||||
|
new JX.Workflow(config.logInLink).start();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
drag_end = get_image_xy(JX.$V(e));
|
drag_end = get_image_xy(JX.$V(e));
|
||||||
|
|
||||||
var data = {mockID: config.mockID};
|
var data = {mockID: config.mockID};
|
||||||
|
|
Loading…
Reference in a new issue