1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-11 16:16:14 +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:
Bob Trahan 2013-03-07 13:02:36 -08:00
parent e6c73a8396
commit e3181fcbe7
6 changed files with 75 additions and 13 deletions

View file

@ -70,12 +70,16 @@ final class PhabricatorLoginController
));
}
$next_uri = $request->getStr('next');
if (!$next_uri) {
$next_uri_path = $this->getRequest()->getPath();
if ($next_uri_path == '/login/') {
$next_uri = '/';
} else {
$next_uri = $this->getRequest()->getRequestURI();
}
}
if (!$request->isFormPost()) {
$request->setCookie('next_uri', $next_uri);
@ -139,10 +143,9 @@ final class PhabricatorLoginController
$request->setCookie('phusr', $user->getUsername());
$request->setCookie('phsid', $session_key);
$uri = new PhutilURI('/login/validate/');
$uri->setQueryParams(
array(
'phusr' => $user->getUsername(),
$uri = id(new PhutilURI('/login/validate/'))
->setQueryParams(
array('phusr' => $user->getUsername()
));
return id(new AphrontRedirectResponse())

View file

@ -8,6 +8,10 @@ final class PholioMockViewController extends PholioController {
private $id;
private $imageID;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->id = $data['id'];
$this->imageID = idx($data, 'imageID');
@ -67,9 +71,11 @@ final class PholioMockViewController extends PholioController {
require_celerity_resource('pholio-css');
require_celerity_resource('pholio-inline-comments-css');
$output = new PholioMockImagesView();
$output->setMock($mock);
$output->setImageID($this->imageID);
$output = id(new PholioMockImagesView())
->setRequestURI($request->getRequestURI())
->setUser($user)
->setMock($mock)
->setImageID($this->imageID);
$xaction_view = id(new PhabricatorApplicationTransactionView())
->setUser($this->getRequest()->getUser())
@ -201,7 +207,8 @@ final class PholioMockViewController extends PholioController {
->setUser($user)
->setDraft($draft)
->setSubmitButtonName($button_name)
->setAction($this->getApplicationURI('/comment/'.$mock->getID().'/'));
->setAction($this->getApplicationURI('/comment/'.$mock->getID().'/'))
->setRequestURI($this->getRequest()->getRequestURI());
return array(
$header,

View file

@ -4,6 +4,15 @@ final class PholioMockImagesView extends AphrontView {
private $mock;
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) {
$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(
'mockID' => $mock->getID(),
'panelID' => $panel_id,
'viewportID' => $viewport_id,
'images' => $images,
'selectedID' => $selected_id,
'loggedIn' => $this->getUser()->isLoggedIn(),
'logInLink' => (string) $login_uri
);
Javelin::initBehavior('pholio-mock-view', $config);

View file

@ -15,6 +15,15 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView {
private $statusID;
private $commentID;
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) {
$this->draft = $draft;
@ -45,6 +54,26 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView {
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();
$comment = $this->renderCommentPanel();

View file

@ -363,3 +363,8 @@ table.aphront-form-control-checkbox-layout th {
.picker-open .calendar-button {
border-left: 1px solid white;
}
.login-to-comment {
padding: 12px;
float: right;
}

View file

@ -303,6 +303,11 @@ JX.behavior('pholio-mock-view', function(config) {
return;
}
is_dragging = false;
if (!config.loggedIn) {
new JX.Workflow(config.logInLink).start();
return;
}
drag_end = get_image_xy(JX.$V(e));
var data = {mockID: config.mockID};