From 6bbba1e3151d6ac6135354d0216a98163cb12804 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Thu, 31 Mar 2016 13:45:02 -0700 Subject: [PATCH] Update Auth for new UI Summary: [WIP] Tossing this up for safety and to read through it. Need to test, update some of the other flows. This updates everything in Auth for new UI and modern conventions. Test Plan: Loooots of random testing, new providers, edit providers, logging out, forgot password... more coming. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D15550 --- .../PhabricatorAuthConfirmLinkController.php | 13 ++-- .../controller/PhabricatorAuthController.php | 8 +-- .../PhabricatorAuthLinkController.php | 13 ++-- .../PhabricatorAuthLoginController.php | 14 ++-- ...PhabricatorAuthNeedsApprovalController.php | 9 ++- ...bricatorAuthNeedsMultiFactorController.php | 19 +++--- .../PhabricatorAuthRegisterController.php | 27 ++++---- .../PhabricatorAuthStartController.php | 21 +++--- .../PhabricatorDisabledUserController.php | 3 +- .../PhabricatorEmailLoginController.php | 14 ++-- ...PhabricatorEmailVerificationController.php | 14 ++-- .../PhabricatorLogoutController.php | 5 +- .../PhabricatorMustVerifyEmailController.php | 17 ++--- .../config/PhabricatorAuthEditController.php | 66 +++++++++---------- .../config/PhabricatorAuthListController.php | 35 +++++----- .../config/PhabricatorAuthNewController.php | 25 +++++-- ...abricatorAuthProviderConfigTransaction.php | 6 +- 17 files changed, 156 insertions(+), 153 deletions(-) diff --git a/src/applications/auth/controller/PhabricatorAuthConfirmLinkController.php b/src/applications/auth/controller/PhabricatorAuthConfirmLinkController.php index 799a8e691e..664a97885f 100644 --- a/src/applications/auth/controller/PhabricatorAuthConfirmLinkController.php +++ b/src/applications/auth/controller/PhabricatorAuthConfirmLinkController.php @@ -66,15 +66,12 @@ final class PhabricatorAuthConfirmLinkController $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Confirm Link'), $panel_uri); $crumbs->addTextCrumb($provider->getProviderName()); + $crumbs->setBorder(true); - return $this->buildApplicationPage( - array( - $crumbs, - $dialog, - ), - array( - 'title' => pht('Confirm External Account Link'), - )); + return $this->newPage() + ->setTitle(pht('Confirm External Account Link')) + ->setCrumbs($crumbs) + ->appendChild($dialog); } diff --git a/src/applications/auth/controller/PhabricatorAuthController.php b/src/applications/auth/controller/PhabricatorAuthController.php index 76161e6c77..ca4b89f571 100644 --- a/src/applications/auth/controller/PhabricatorAuthController.php +++ b/src/applications/auth/controller/PhabricatorAuthController.php @@ -7,11 +7,9 @@ abstract class PhabricatorAuthController extends PhabricatorController { $view->setTitle($title); $view->setErrors($messages); - return $this->buildApplicationPage( - $view, - array( - 'title' => $title, - )); + return $this->newPage() + ->setTitle($title) + ->appendChild($view); } diff --git a/src/applications/auth/controller/PhabricatorAuthLinkController.php b/src/applications/auth/controller/PhabricatorAuthLinkController.php index d50bcf1d8a..44176a278e 100644 --- a/src/applications/auth/controller/PhabricatorAuthLinkController.php +++ b/src/applications/auth/controller/PhabricatorAuthLinkController.php @@ -116,15 +116,12 @@ final class PhabricatorAuthLinkController $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Link Account'), $panel_uri); $crumbs->addTextCrumb($provider->getProviderName($name)); + $crumbs->setBorder(true); - return $this->buildApplicationPage( - array( - $crumbs, - $form, - ), - array( - 'title' => $title, - )); + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($form); } } diff --git a/src/applications/auth/controller/PhabricatorAuthLoginController.php b/src/applications/auth/controller/PhabricatorAuthLoginController.php index be610e223a..b9b2a8d876 100644 --- a/src/applications/auth/controller/PhabricatorAuthLoginController.php +++ b/src/applications/auth/controller/PhabricatorAuthLoginController.php @@ -236,7 +236,6 @@ final class PhabricatorAuthLoginController $content) { $crumbs = $this->buildApplicationCrumbs(); - $crumbs->setBorder(true); if ($this->getRequest()->getUser()->isLoggedIn()) { $crumbs->addTextCrumb(pht('Link Account'), $provider->getSettingsURI()); @@ -245,15 +244,12 @@ final class PhabricatorAuthLoginController } $crumbs->addTextCrumb($provider->getProviderName()); + $crumbs->setBorder(true); - return $this->buildApplicationPage( - array( - $crumbs, - $content, - ), - array( - 'title' => pht('Login'), - )); + return $this->newPage() + ->setTitle(pht('Login')) + ->setCrumbs($crumbs) + ->appendChild($content); } public function buildProviderErrorResponse( diff --git a/src/applications/auth/controller/PhabricatorAuthNeedsApprovalController.php b/src/applications/auth/controller/PhabricatorAuthNeedsApprovalController.php index 0d07470560..ba28816375 100644 --- a/src/applications/auth/controller/PhabricatorAuthNeedsApprovalController.php +++ b/src/applications/auth/controller/PhabricatorAuthNeedsApprovalController.php @@ -28,11 +28,10 @@ final class PhabricatorAuthNeedsApprovalController ->appendChild($wait_for_approval) ->addCancelButton('/', pht('Wait Patiently')); - return $this->buildApplicationPage( - $dialog, - array( - 'title' => pht('Wait For Approval'), - )); + return $this->newPage() + ->setTitle(pht('Wait For Approval')) + ->appendChild($dialog); + } } diff --git a/src/applications/auth/controller/PhabricatorAuthNeedsMultiFactorController.php b/src/applications/auth/controller/PhabricatorAuthNeedsMultiFactorController.php index aaf3864156..f3e2562a1c 100644 --- a/src/applications/auth/controller/PhabricatorAuthNeedsMultiFactorController.php +++ b/src/applications/auth/controller/PhabricatorAuthNeedsMultiFactorController.php @@ -76,15 +76,16 @@ final class PhabricatorAuthNeedsMultiFactorController )); } - return $this->buildApplicationPage( - array( - $crumbs, - $help, - $panel, - ), - array( - 'title' => pht('Add Multi-Factor Authentication'), - )); + $view = array( + $help, + $panel, + ); + + return $this->newPage() + ->setTitle(pht('Add Multi-Factor Authentication')) + ->setCrumbs($crumbs) + ->appendChild($view); + } } diff --git a/src/applications/auth/controller/PhabricatorAuthRegisterController.php b/src/applications/auth/controller/PhabricatorAuthRegisterController.php index 655f63acb9..27d54e4ad6 100644 --- a/src/applications/auth/controller/PhabricatorAuthRegisterController.php +++ b/src/applications/auth/controller/PhabricatorAuthRegisterController.php @@ -497,6 +497,7 @@ final class PhabricatorAuthRegisterController $crumbs->addTextCrumb($provider->getProviderName()); $title = pht('Phabricator Registration'); } + $crumbs->setBorder(true); $welcome_view = null; if ($is_setup) { @@ -511,7 +512,6 @@ final class PhabricatorAuthRegisterController } $object_box = id(new PHUIObjectBoxView()) - ->setHeaderText($title) ->setForm($form) ->setFormErrors($errors); @@ -520,16 +520,21 @@ final class PhabricatorAuthRegisterController $invite_header = $this->renderInviteHeader($invite); } - return $this->buildApplicationPage( - array( - $crumbs, - $welcome_view, - $invite_header, - $object_box, - ), - array( - 'title' => $title, - )); + $header = id(new PHUIHeaderView()) + ->setHeader($title); + + $view = id(new PHUITwoColumnView()) + ->setHeader($header) + ->setFooter(array( + $welcome_view, + $invite_header, + $object_box, + )); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); } private function loadDefaultAccount() { diff --git a/src/applications/auth/controller/PhabricatorAuthStartController.php b/src/applications/auth/controller/PhabricatorAuthStartController.php index 8f4a374241..d591b6313f 100644 --- a/src/applications/auth/controller/PhabricatorAuthStartController.php +++ b/src/applications/auth/controller/PhabricatorAuthStartController.php @@ -189,16 +189,17 @@ final class PhabricatorAuthStartController $crumbs->addTextCrumb(pht('Login')); $crumbs->setBorder(true); - return $this->buildApplicationPage( - array( - $crumbs, - $header, - $invite_message, - $out, - ), - array( - 'title' => pht('Login to Phabricator'), - )); + $title = pht('Login to Phabricator'); + $view = array( + $header, + $invite_message, + $out, + ); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); } diff --git a/src/applications/auth/controller/PhabricatorDisabledUserController.php b/src/applications/auth/controller/PhabricatorDisabledUserController.php index 39e390d44a..26163c3034 100644 --- a/src/applications/auth/controller/PhabricatorDisabledUserController.php +++ b/src/applications/auth/controller/PhabricatorDisabledUserController.php @@ -15,8 +15,7 @@ final class PhabricatorDisabledUserController return new Aphront404Response(); } - return id(new AphrontDialogView()) - ->setUser($viewer) + return $this->newDialog() ->setTitle(pht('Account Disabled')) ->addCancelButton('/logout/', pht('Okay')) ->appendParagraph(pht('Your account has been disabled.')); diff --git a/src/applications/auth/controller/PhabricatorEmailLoginController.php b/src/applications/auth/controller/PhabricatorEmailLoginController.php index 26609133ea..e9cf693514 100644 --- a/src/applications/auth/controller/PhabricatorEmailLoginController.php +++ b/src/applications/auth/controller/PhabricatorEmailLoginController.php @@ -144,6 +144,7 @@ final class PhabricatorEmailLoginController $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Reset Password')); + $crumbs->setBorder(true); $dialog = new AphrontDialogView(); $dialog->setUser($request->getUser()); @@ -152,14 +153,11 @@ final class PhabricatorEmailLoginController $dialog->addSubmitButton(pht('Send Email')); $dialog->setSubmitURI('/login/email/'); - return $this->buildApplicationPage( - array( - $crumbs, - $dialog, - ), - array( - 'title' => pht('Forgot Password'), - )); + return $this->newPage() + ->setTitle(pht('Forgot Password')) + ->setCrumbs($crumbs) + ->appendChild($dialog); + } } diff --git a/src/applications/auth/controller/PhabricatorEmailVerificationController.php b/src/applications/auth/controller/PhabricatorEmailVerificationController.php index 83a370139c..e8138339af 100644 --- a/src/applications/auth/controller/PhabricatorEmailVerificationController.php +++ b/src/applications/auth/controller/PhabricatorEmailVerificationController.php @@ -77,15 +77,13 @@ final class PhabricatorEmailVerificationController $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Verify Email')); + $crumbs->setBorder(true); + + return $this->newPage() + ->setTitle(pht('Verify Email')) + ->setCrumbs($crumbs) + ->appendChild($dialog); - return $this->buildApplicationPage( - array( - $crumbs, - $dialog, - ), - array( - 'title' => pht('Verify Email'), - )); } } diff --git a/src/applications/auth/controller/PhabricatorLogoutController.php b/src/applications/auth/controller/PhabricatorLogoutController.php index de3ac50e5d..2600a08313 100644 --- a/src/applications/auth/controller/PhabricatorLogoutController.php +++ b/src/applications/auth/controller/PhabricatorLogoutController.php @@ -56,14 +56,11 @@ final class PhabricatorLogoutController } if ($viewer->getPHID()) { - $dialog = id(new AphrontDialogView()) - ->setUser($viewer) + return $this->newDialog() ->setTitle(pht('Log out of Phabricator?')) ->appendChild(pht('Are you sure you want to log out?')) ->addSubmitButton(pht('Logout')) ->addCancelButton('/'); - - return id(new AphrontDialogResponse())->setDialog($dialog); } return id(new AphrontRedirectResponse())->setURI('/'); diff --git a/src/applications/auth/controller/PhabricatorMustVerifyEmailController.php b/src/applications/auth/controller/PhabricatorMustVerifyEmailController.php index 779196382d..a944a5b5c8 100644 --- a/src/applications/auth/controller/PhabricatorMustVerifyEmailController.php +++ b/src/applications/auth/controller/PhabricatorMustVerifyEmailController.php @@ -53,14 +53,15 @@ final class PhabricatorMustVerifyEmailController ->appendParagraph($send_again) ->addSubmitButton(pht('Send Another Email')); - return $this->buildApplicationPage( - array( - $sent, - $dialog, - ), - array( - 'title' => pht('Must Verify Email'), - )); + $view = array( + $sent, + $dialog, + ); + + return $this->newPage() + ->setTitle(pht('Must Verify Email')) + ->appendChild($view); + } } diff --git a/src/applications/auth/controller/config/PhabricatorAuthEditController.php b/src/applications/auth/controller/config/PhabricatorAuthEditController.php index 21ba6ef99a..049edfacef 100644 --- a/src/applications/auth/controller/config/PhabricatorAuthEditController.php +++ b/src/applications/auth/controller/config/PhabricatorAuthEditController.php @@ -176,15 +176,33 @@ final class PhabricatorAuthEditController $button = pht('Add Provider'); } $crumb = pht('Add Provider'); - $title = pht('Add Authentication Provider'); + $title = pht('Add Auth Provider'); + $header_icon = 'fa-plus-square'; $cancel_uri = $this->getApplicationURI('/config/new/'); } else { $button = pht('Save'); $crumb = pht('Edit Provider'); - $title = pht('Edit Authentication Provider'); + $title = pht('Edit Auth Provider'); + $header_icon = 'fa-pencil'; $cancel_uri = $this->getApplicationURI(); } + $header = id(new PHUIHeaderView()) + ->setHeader(pht('%s: %s', $title, $provider->getProviderName())) + ->setHeaderIcon($header_icon); + + if ($config->getIsEnabled()) { + $status_name = pht('Enabled'); + $status_color = 'green'; + $status_icon = 'fa-check'; + $header->setStatus($status_icon, $status_color, $status_name); + } else if (!$is_new) { + $status_name = pht('Disabled'); + $status_color = 'indigo'; + $status_icon = 'fa-ban'; + $header->setStatus($status_icon, $status_color, $status_name); + } + $config_name = 'auth.email-domains'; $config_href = '/config/edit/'.$config_name.'/'; @@ -253,32 +271,8 @@ final class PhabricatorAuthEditController 'Phabricator will automatically login with this provider if it is '. 'the only available provider.')); - $status_tag = id(new PHUITagView()) - ->setType(PHUITagView::TYPE_STATE); - if ($is_new) { - $status_tag - ->setName(pht('New Provider')) - ->setBackgroundColor('blue'); - } else if ($config->getIsEnabled()) { - $status_tag - ->setName(pht('Enabled')) - ->setBackgroundColor('green'); - } else { - $status_tag - ->setName(pht('Disabled')) - ->setBackgroundColor('red'); - } - $form = id(new AphrontFormView()) ->setUser($viewer) - ->appendChild( - id(new AphrontFormStaticControl()) - ->setLabel(pht('Provider')) - ->setValue($provider->getProviderName())) - ->appendChild( - id(new AphrontFormStaticControl()) - ->setLabel(pht('Status')) - ->setValue($status_tag)) ->appendChild( id(new AphrontFormCheckboxControl()) ->setLabel(pht('Allow')) @@ -348,6 +342,7 @@ final class PhabricatorAuthEditController $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($crumb); + $crumbs->setBorder(true); $timeline = null; if (!$is_new) { @@ -358,23 +353,28 @@ final class PhabricatorAuthEditController foreach ($xactions as $xaction) { $xaction->setProvider($provider); } + $timeline->setShouldTerminate(true); } $form_box = id(new PHUIObjectBoxView()) - ->setHeaderText($title) + ->setHeaderText(pht('Provider')) ->setFormErrors($errors) + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setForm($form); - return $this->buildApplicationPage( - array( - $crumbs, + $view = id(new PHUITwoColumnView()) + ->setHeader($header) + ->setFooter(array( $form_box, $footer, $timeline, - ), - array( - 'title' => $title, )); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); + } } diff --git a/src/applications/auth/controller/config/PhabricatorAuthListController.php b/src/applications/auth/controller/config/PhabricatorAuthListController.php index 6df32f50a5..cb9c21b35f 100644 --- a/src/applications/auth/controller/config/PhabricatorAuthListController.php +++ b/src/applications/auth/controller/config/PhabricatorAuthListController.php @@ -3,9 +3,8 @@ final class PhabricatorAuthListController extends PhabricatorAuthProviderConfigController { - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $this->getViewer(); $configs = id(new PhabricatorAuthProviderConfigQuery()) ->setViewer($viewer) @@ -93,6 +92,7 @@ final class PhabricatorAuthListController $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Auth Providers')); + $crumbs->setBorder(true); $domains_key = 'auth.email-domains'; $domains_link = $this->renderConfigLink($domains_key); @@ -155,24 +155,29 @@ final class PhabricatorAuthListController ->setDisabled(!$can_manage) ->setText(pht('Add Provider')); - $header = id(new PHUIHeaderView()) - ->setHeader(pht('Authentication Providers')) - ->addActionLink($button); - $list->setFlush(true); $list = id(new PHUIObjectBoxView()) - ->setHeader($header) - ->setInfoView($warning) + ->setHeaderText(pht('Providers')) + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->appendChild($list); - return $this->buildApplicationPage( - array( - $crumbs, + $title = pht('Auth Providers'); + $header = id(new PHUIHeaderView()) + ->setHeader($title) + ->setHeaderIcon('fa-key') + ->addActionLink($button); + + $view = id(new PHUITwoColumnView()) + ->setHeader($header) + ->setFooter(array( + $warning, $list, - ), - array( - 'title' => pht('Authentication Providers'), )); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); } private function renderConfigLink($key) { diff --git a/src/applications/auth/controller/config/PhabricatorAuthNewController.php b/src/applications/auth/controller/config/PhabricatorAuthNewController.php index 18b4429ea9..dbd43f9ea8 100644 --- a/src/applications/auth/controller/config/PhabricatorAuthNewController.php +++ b/src/applications/auth/controller/config/PhabricatorAuthNewController.php @@ -80,21 +80,32 @@ final class PhabricatorAuthNewController ->setValue(pht('Continue'))); $form_box = id(new PHUIObjectBoxView()) - ->setHeaderText(pht('Add Authentication Provider')) + ->setHeaderText(pht('Provider')) ->setFormErrors($errors) + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setForm($form); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Add Provider')); + $crumbs->setBorder(true); - return $this->buildApplicationPage( - array( - $crumbs, + $title = pht('Add Auth Provider'); + + $header = id(new PHUIHeaderView()) + ->setHeader($title) + ->setHeaderIcon('fa-plus-square'); + + $view = id(new PHUITwoColumnView()) + ->setHeader($header) + ->setFooter(array( $form_box, - ), - array( - 'title' => pht('Add Authentication Provider'), )); + + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild($view); + } } diff --git a/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php b/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php index 8314b652ce..e1453b4383 100644 --- a/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php +++ b/src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php @@ -44,9 +44,9 @@ final class PhabricatorAuthProviderConfigTransaction switch ($this->getTransactionType()) { case self::TYPE_ENABLE: if ($new) { - return 'fa-play'; + return 'fa-check'; } else { - return 'fa-pause'; + return 'fa-ban'; } } @@ -62,7 +62,7 @@ final class PhabricatorAuthProviderConfigTransaction if ($new) { return 'green'; } else { - return 'red'; + return 'indigo'; } }