@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 dialogs a little easier to use

Summary:
- Dialog pages currently have no titles or crumbs, and look shoddy. Add titles and crumbs.
- Dialog titles aren't always great for crumbs, add an optional "short title" for crumbs.
- `AphrontDialogResponse` is pure boilerplate. Allow controllers to just return a `DialogView` instead and get the same effect.
- Building dialogs requires a bit of boilerplate, and we generally construct them with no explicit `"action"`, which has some issues with T4593. Provide a convenience method to set the viewer and get a reasonable, explict submit URI.

Test Plan:
- Viewed dialog on its own.
- Viewed dialog as a dialog.

{F132353}

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

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

+57 -19
+5 -8
src/applications/auth/controller/PhabricatorAuthTerminateSessionController.php
··· 36 36 $panel_uri = '/settings/panel/sessions/'; 37 37 38 38 if (!$sessions) { 39 - $dialog = id(new AphrontDialogView()) 40 - ->setUser($viewer) 39 + return $this->newDialog() 41 40 ->setTitle(pht('No Matching Sessions')) 42 41 ->appendParagraph( 43 42 pht('There are no matching sessions to terminate.')) ··· 46 45 '(You can not terminate your current login session. To '. 47 46 'terminate it, log out.)')) 48 47 ->addCancelButton($panel_uri); 49 - 50 - return id(new AphrontDialogResponse())->setDialog($dialog); 51 48 } 52 49 53 50 if ($request->isDialogFormPost()) { ··· 59 56 60 57 if ($is_all) { 61 58 $title = pht('Terminate Sessions?'); 59 + $short = pht('Terminate Sessions'); 62 60 $body = pht( 63 61 'Really terminate all sessions? (Your current login session will '. 64 62 'not be terminated.)'); 65 63 } else { 66 64 $title = pht('Terminate Session?'); 65 + $short = pht('Terminate Session'); 67 66 $body = pht( 68 67 'Really terminate session %s?', 69 68 phutil_tag('strong', array(), substr($session->getSessionKey(), 0, 6))); 70 69 } 71 70 72 - $dialog = id(new AphrontDialogView()) 73 - ->setUser($viewer) 71 + return $this->newDialog() 74 72 ->setTitle($title) 73 + ->setShortTitle($short) 75 74 ->appendParagraph($body) 76 75 ->addSubmitButton(pht('Terminate')) 77 76 ->addCancelButton($panel_uri); 78 - 79 - return id(new AphrontDialogResponse())->setDialog($dialog); 80 77 } 81 78 82 79
+42 -11
src/applications/base/controller/PhabricatorController.php
··· 258 258 } 259 259 260 260 public function didProcessRequest($response) { 261 + // If a bare DialogView is returned, wrap it in a DialogResponse. 262 + if ($response instanceof AphrontDialogView) { 263 + $response = id(new AphrontDialogResponse())->setDialog($response); 264 + } 265 + 261 266 $request = $this->getRequest(); 262 267 $response->setRequest($request); 263 268 ··· 278 283 279 284 if ($response instanceof AphrontDialogResponse) { 280 285 if (!$request->isAjax()) { 281 - $view = new PhabricatorStandardPageView(); 282 - $view->setRequest($request); 283 - $view->setController($this); 284 - $view->appendChild(phutil_tag( 285 - 'div', 286 - array('style' => 'padding: 2em 0;'), 287 - $response->buildResponseString())); 288 - $page_response = new AphrontWebpageResponse(); 289 - $page_response->setContent($view->render()); 290 - $page_response->setHTTPResponseCode($response->getHTTPResponseCode()); 291 - return $page_response; 286 + $dialog = $response->getDialog(); 287 + 288 + $title = $dialog->getTitle(); 289 + $short = $dialog->getShortTitle(); 290 + 291 + $crumbs = $this->buildApplicationCrumbs(); 292 + $crumbs->addTextCrumb(coalesce($short, $title)); 293 + 294 + $page_content = array( 295 + $crumbs, 296 + $response->buildResponseString(), 297 + ); 298 + 299 + $view = id(new PhabricatorStandardPageView()) 300 + ->setRequest($request) 301 + ->setController($this) 302 + ->setTitle($title) 303 + ->appendChild($page_content); 304 + 305 + $response = id(new AphrontWebpageResponse()) 306 + ->setContent($view->render()) 307 + ->setHTTPResponseCode($response->getHTTPResponseCode()); 292 308 } else { 293 309 $response->getDialog()->setIsStandalone(true); 294 310 ··· 306 322 )); 307 323 } 308 324 } 325 + 309 326 return $response; 310 327 } 311 328 ··· 447 464 return 'phabricator'; 448 465 } 449 466 467 + 468 + /** 469 + * Create a new @{class:AphrontDialogView} with defaults filled in. 470 + * 471 + * @return AphrontDialogView New dialog. 472 + */ 473 + protected function newDialog() { 474 + $submit_uri = new PhutilURI($this->getRequest()->getRequestURI()); 475 + $submit_uri = $submit_uri->getPath(); 476 + 477 + return id(new AphrontDialogView()) 478 + ->setUser($this->getRequest()->getUser()) 479 + ->setSubmitURI($submit_uri); 480 + } 450 481 451 482 }
+10
src/view/AphrontDialogView.php
··· 3 3 final class AphrontDialogView extends AphrontView { 4 4 5 5 private $title; 6 + private $shortTitle; 6 7 private $submitButton; 7 8 private $cancelURI; 8 9 private $cancelText = 'Cancel'; ··· 49 50 50 51 public function getTitle() { 51 52 return $this->title; 53 + } 54 + 55 + public function setShortTitle($short_title) { 56 + $this->shortTitle = $short_title; 57 + return $this; 58 + } 59 + 60 + public function getShortTitle() { 61 + return $this->shortTitle; 52 62 } 53 63 54 64 public function addSubmitButton($text = null) {