Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13990027
D20095.id48004.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D20095.id48004.diff
View Options
diff --git a/src/applications/auth/application/PhabricatorAuthApplication.php b/src/applications/auth/application/PhabricatorAuthApplication.php
--- a/src/applications/auth/application/PhabricatorAuthApplication.php
+++ b/src/applications/auth/application/PhabricatorAuthApplication.php
@@ -48,8 +48,7 @@
'' => 'PhabricatorAuthListController',
'config/' => array(
'new/' => 'PhabricatorAuthNewController',
- 'new/(?P<className>[^/]+)/' => 'PhabricatorAuthEditController',
- 'edit/(?P<id>\d+)/' => 'PhabricatorAuthEditController',
+ 'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorAuthEditController',
'(?P<action>enable|disable)/(?P<id>\d+)/'
=> 'PhabricatorAuthDisableController',
),
diff --git a/src/applications/auth/controller/config/PhabricatorAuthEditController.php b/src/applications/auth/controller/config/PhabricatorAuthEditController.php
--- a/src/applications/auth/controller/config/PhabricatorAuthEditController.php
+++ b/src/applications/auth/controller/config/PhabricatorAuthEditController.php
@@ -6,8 +6,9 @@
public function handleRequest(AphrontRequest $request) {
$this->requireApplicationCapability(
AuthManageProvidersCapability::CAPABILITY);
- $viewer = $request->getUser();
- $provider_class = $request->getURIData('className');
+
+ $viewer = $this->getViewer();
+ $provider_class = $request->getStr('provider');
$config_id = $request->getURIData('id');
if ($config_id) {
@@ -275,6 +276,7 @@
$form = id(new AphrontFormView())
->setUser($viewer)
+ ->addHiddenInput('provider', $provider_class)
->appendChild(
id(new AphrontFormCheckboxControl())
->setLabel(pht('Allow'))
diff --git a/src/applications/auth/controller/config/PhabricatorAuthNewController.php b/src/applications/auth/controller/config/PhabricatorAuthNewController.php
--- a/src/applications/auth/controller/config/PhabricatorAuthNewController.php
+++ b/src/applications/auth/controller/config/PhabricatorAuthNewController.php
@@ -6,43 +6,11 @@
public function handleRequest(AphrontRequest $request) {
$this->requireApplicationCapability(
AuthManageProvidersCapability::CAPABILITY);
- $request = $this->getRequest();
- $viewer = $request->getUser();
- $providers = PhabricatorAuthProvider::getAllBaseProviders();
-
- $e_provider = null;
- $errors = array();
-
- if ($request->isFormPost()) {
- $provider_string = $request->getStr('provider');
- if (!strlen($provider_string)) {
- $e_provider = pht('Required');
- $errors[] = pht('You must select an authentication provider.');
- } else {
- $found = false;
- foreach ($providers as $provider) {
- if (get_class($provider) === $provider_string) {
- $found = true;
- break;
- }
- }
- if (!$found) {
- $e_provider = pht('Invalid');
- $errors[] = pht('You must select a valid provider.');
- }
- }
+ $viewer = $this->getViewer();
+ $cancel_uri = $this->getApplicationURI();
- if (!$errors) {
- return id(new AphrontRedirectResponse())->setURI(
- $this->getApplicationURI('/config/new/'.$provider_string.'/'));
- }
- }
-
- $options = id(new AphrontFormRadioButtonControl())
- ->setLabel(pht('Provider'))
- ->setName('provider')
- ->setError($e_provider);
+ $providers = PhabricatorAuthProvider::getAllBaseProviders();
$configured = PhabricatorAuthProvider::getAllProviders();
$configured_classes = array();
@@ -55,57 +23,52 @@
$providers = msort($providers, 'getLoginOrder');
$providers = array_diff_key($providers, $configured_classes) + $providers;
- foreach ($providers as $provider) {
- if (isset($configured_classes[get_class($provider)])) {
- $disabled = true;
- $description = pht('This provider is already configured.');
+ $menu = id(new PHUIObjectItemListView())
+ ->setViewer($viewer)
+ ->setBig(true)
+ ->setFlush(true);
+
+ foreach ($providers as $provider_key => $provider) {
+ $provider_class = get_class($provider);
+
+ $provider_uri = id(new PhutilURI('/config/edit/'))
+ ->setQueryParam('provider', $provider_class);
+ $provider_uri = $this->getApplicationURI($provider_uri);
+
+ $already_exists = isset($configured_classes[get_class($provider)]);
+
+ $item = id(new PHUIObjectItemView())
+ ->setHeader($provider->getNameForCreate())
+ ->setImageIcon($provider->newIconView())
+ ->addAttribute($provider->getDescriptionForCreate());
+
+ if (!$already_exists) {
+ $item
+ ->setHref($provider_uri)
+ ->setClickable(true);
} else {
- $disabled = false;
- $description = $provider->getDescriptionForCreate();
+ $item->setDisabled(true);
}
- $options->addButton(
- get_class($provider),
- $provider->getNameForCreate(),
- $description,
- $disabled ? 'disabled' : null,
- $disabled);
- }
- $form = id(new AphrontFormView())
- ->setUser($viewer)
- ->appendChild($options)
- ->appendChild(
- id(new AphrontFormSubmitControl())
- ->addCancelButton($this->getApplicationURI())
- ->setValue(pht('Continue')));
-
- $form_box = id(new PHUIObjectBoxView())
- ->setHeaderText(pht('Provider'))
- ->setFormErrors($errors)
- ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
- ->setForm($form);
-
- $crumbs = $this->buildApplicationCrumbs();
- $crumbs->addTextCrumb(pht('Add Provider'));
- $crumbs->setBorder(true);
-
- $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,
- ));
-
- return $this->newPage()
- ->setTitle($title)
- ->setCrumbs($crumbs)
- ->appendChild($view);
+ if ($already_exists) {
+ $messages = array();
+ $messages[] = pht('You already have a provider of this type.');
+
+ $info = id(new PHUIInfoView())
+ ->setSeverity(PHUIInfoView::SEVERITY_WARNING)
+ ->setErrors($messages);
+
+ $item->appendChild($info);
+ }
+
+ $menu->addItem($item);
+ }
+ return $this->newDialog()
+ ->setTitle(pht('Add Auth Provider'))
+ ->setWidth(AphrontDialogView::WIDTH_FORM)
+ ->appendChild($menu)
+ ->addCancelButton($cancel_uri);
}
}
diff --git a/src/applications/auth/provider/PhabricatorAuthProvider.php b/src/applications/auth/provider/PhabricatorAuthProvider.php
--- a/src/applications/auth/provider/PhabricatorAuthProvider.php
+++ b/src/applications/auth/provider/PhabricatorAuthProvider.php
@@ -311,6 +311,12 @@
return 'Generic';
}
+ public function newIconView() {
+ return id(new PHUIIconView())
+ ->setSpriteSheet(PHUIIconView::SPRITE_LOGIN)
+ ->setSpriteIcon($this->getLoginIcon());
+ }
+
public function isLoginFormAButton() {
return false;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 23, 12:33 AM (4 w, 3 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6737296
Default Alt Text
D20095.id48004.diff (7 KB)
Attached To
Mode
D20095: Replace "Add Auth Provider" radio buttons with a more modern "click to select" UI
Attached
Detach File
Event Timeline
Log In to Comment