1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

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
This commit is contained in:
Chad Little 2016-03-31 13:45:02 -07:00
parent 2386705873
commit 6bbba1e315
17 changed files with 156 additions and 153 deletions

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}
}

View file

@ -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(

View file

@ -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);
}
}

View file

@ -76,15 +76,16 @@ final class PhabricatorAuthNeedsMultiFactorController
));
}
return $this->buildApplicationPage(
array(
$crumbs,
$view = array(
$help,
$panel,
),
array(
'title' => pht('Add Multi-Factor Authentication'),
));
);
return $this->newPage()
->setTitle(pht('Add Multi-Factor Authentication'))
->setCrumbs($crumbs)
->appendChild($view);
}
}

View file

@ -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,
$header = id(new PHUIHeaderView())
->setHeader($title);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$welcome_view,
$invite_header,
$object_box,
),
array(
'title' => $title,
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild($view);
}
private function loadDefaultAccount() {

View file

@ -189,16 +189,17 @@ final class PhabricatorAuthStartController
$crumbs->addTextCrumb(pht('Login'));
$crumbs->setBorder(true);
return $this->buildApplicationPage(
array(
$crumbs,
$title = pht('Login to Phabricator');
$view = array(
$header,
$invite_message,
$out,
),
array(
'title' => pht('Login to Phabricator'),
));
);
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild($view);
}

View file

@ -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.'));

View file

@ -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);
}
}

View file

@ -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'),
));
}
}

View file

@ -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('/');

View file

@ -53,14 +53,15 @@ final class PhabricatorMustVerifyEmailController
->appendParagraph($send_again)
->addSubmitButton(pht('Send Another Email'));
return $this->buildApplicationPage(
array(
$view = array(
$sent,
$dialog,
),
array(
'title' => pht('Must Verify Email'),
));
);
return $this->newPage()
->setTitle(pht('Must Verify Email'))
->appendChild($view);
}
}

View file

@ -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);
}
}

View file

@ -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) {

View file

@ -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);
}
}

View file

@ -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';
}
}