Page MenuHomePhabricator

D8577.id20353.diff
No OneTemporary

D8577.id20353.diff

diff --git a/src/applications/auth/controller/PhabricatorAuthTerminateSessionController.php b/src/applications/auth/controller/PhabricatorAuthTerminateSessionController.php
--- a/src/applications/auth/controller/PhabricatorAuthTerminateSessionController.php
+++ b/src/applications/auth/controller/PhabricatorAuthTerminateSessionController.php
@@ -36,8 +36,7 @@
$panel_uri = '/settings/panel/sessions/';
if (!$sessions) {
- $dialog = id(new AphrontDialogView())
- ->setUser($viewer)
+ return $this->newDialog()
->setTitle(pht('No Matching Sessions'))
->appendParagraph(
pht('There are no matching sessions to terminate.'))
@@ -46,8 +45,6 @@
'(You can not terminate your current login session. To '.
'terminate it, log out.)'))
->addCancelButton($panel_uri);
-
- return id(new AphrontDialogResponse())->setDialog($dialog);
}
if ($request->isDialogFormPost()) {
@@ -59,24 +56,24 @@
if ($is_all) {
$title = pht('Terminate Sessions?');
+ $short = pht('Terminate Sessions');
$body = pht(
'Really terminate all sessions? (Your current login session will '.
'not be terminated.)');
} else {
$title = pht('Terminate Session?');
+ $short = pht('Terminate Session');
$body = pht(
'Really terminate session %s?',
phutil_tag('strong', array(), substr($session->getSessionKey(), 0, 6)));
}
- $dialog = id(new AphrontDialogView())
- ->setUser($viewer)
+ return $this->newDialog()
->setTitle($title)
+ ->setShortTitle($short)
->appendParagraph($body)
->addSubmitButton(pht('Terminate'))
->addCancelButton($panel_uri);
-
- return id(new AphrontDialogResponse())->setDialog($dialog);
}
diff --git a/src/applications/base/controller/PhabricatorController.php b/src/applications/base/controller/PhabricatorController.php
--- a/src/applications/base/controller/PhabricatorController.php
+++ b/src/applications/base/controller/PhabricatorController.php
@@ -258,6 +258,11 @@
}
public function didProcessRequest($response) {
+ // If a bare DialogView is returned, wrap it in a DialogResponse.
+ if ($response instanceof AphrontDialogView) {
+ $response = id(new AphrontDialogResponse())->setDialog($response);
+ }
+
$request = $this->getRequest();
$response->setRequest($request);
@@ -278,17 +283,28 @@
if ($response instanceof AphrontDialogResponse) {
if (!$request->isAjax()) {
- $view = new PhabricatorStandardPageView();
- $view->setRequest($request);
- $view->setController($this);
- $view->appendChild(phutil_tag(
- 'div',
- array('style' => 'padding: 2em 0;'),
- $response->buildResponseString()));
- $page_response = new AphrontWebpageResponse();
- $page_response->setContent($view->render());
- $page_response->setHTTPResponseCode($response->getHTTPResponseCode());
- return $page_response;
+ $dialog = $response->getDialog();
+
+ $title = $dialog->getTitle();
+ $short = $dialog->getShortTitle();
+
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addTextCrumb(coalesce($short, $title));
+
+ $page_content = array(
+ $crumbs,
+ $response->buildResponseString(),
+ );
+
+ $view = id(new PhabricatorStandardPageView())
+ ->setRequest($request)
+ ->setController($this)
+ ->setTitle($title)
+ ->appendChild($page_content);
+
+ $response = id(new AphrontWebpageResponse())
+ ->setContent($view->render())
+ ->setHTTPResponseCode($response->getHTTPResponseCode());
} else {
$response->getDialog()->setIsStandalone(true);
@@ -306,6 +322,7 @@
));
}
}
+
return $response;
}
@@ -448,4 +465,18 @@
}
+ /**
+ * Create a new @{class:AphrontDialogView} with defaults filled in.
+ *
+ * @return AphrontDialogView New dialog.
+ */
+ protected function newDialog() {
+ $submit_uri = new PhutilURI($this->getRequest()->getRequestURI());
+ $submit_uri = $submit_uri->getPath();
+
+ return id(new AphrontDialogView())
+ ->setUser($this->getRequest()->getUser())
+ ->setSubmitURI($submit_uri);
+ }
+
}
diff --git a/src/view/AphrontDialogView.php b/src/view/AphrontDialogView.php
--- a/src/view/AphrontDialogView.php
+++ b/src/view/AphrontDialogView.php
@@ -3,6 +3,7 @@
final class AphrontDialogView extends AphrontView {
private $title;
+ private $shortTitle;
private $submitButton;
private $cancelURI;
private $cancelText = 'Cancel';
@@ -51,6 +52,15 @@
return $this->title;
}
+ public function setShortTitle($short_title) {
+ $this->shortTitle = $short_title;
+ return $this;
+ }
+
+ public function getShortTitle() {
+ return $this->shortTitle;
+ }
+
public function addSubmitButton($text = null) {
if (!$text) {
$text = pht('Okay');

File Metadata

Mime Type
text/plain
Expires
Mon, Oct 28, 5:14 PM (3 w, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6732763
Default Alt Text
D8577.id20353.diff (4 KB)

Event Timeline