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

Replace "Add Auth Provider" radio buttons with a more modern "click to select" UI

Summary:
Depends on D20094. Ref T13244. Ref T6703. See PHI774. Currently, we use an older-style radio-button UI to choose an auth provider type (Google, Password, LDAP, etc).

Instead, use a more modern click-to-select UI.

Test Plan: {F6184343}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13244, T6703

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

+52 -82
+1 -2
src/applications/auth/application/PhabricatorAuthApplication.php
··· 48 48 '' => 'PhabricatorAuthListController', 49 49 'config/' => array( 50 50 'new/' => 'PhabricatorAuthNewController', 51 - 'new/(?P<className>[^/]+)/' => 'PhabricatorAuthEditController', 52 - 'edit/(?P<id>\d+)/' => 'PhabricatorAuthEditController', 51 + 'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorAuthEditController', 53 52 '(?P<action>enable|disable)/(?P<id>\d+)/' 54 53 => 'PhabricatorAuthDisableController', 55 54 ),
+4 -2
src/applications/auth/controller/config/PhabricatorAuthEditController.php
··· 6 6 public function handleRequest(AphrontRequest $request) { 7 7 $this->requireApplicationCapability( 8 8 AuthManageProvidersCapability::CAPABILITY); 9 - $viewer = $request->getUser(); 10 - $provider_class = $request->getURIData('className'); 9 + 10 + $viewer = $this->getViewer(); 11 + $provider_class = $request->getStr('provider'); 11 12 $config_id = $request->getURIData('id'); 12 13 13 14 if ($config_id) { ··· 275 276 276 277 $form = id(new AphrontFormView()) 277 278 ->setUser($viewer) 279 + ->addHiddenInput('provider', $provider_class) 278 280 ->appendChild( 279 281 id(new AphrontFormCheckboxControl()) 280 282 ->setLabel(pht('Allow'))
+41 -78
src/applications/auth/controller/config/PhabricatorAuthNewController.php
··· 6 6 public function handleRequest(AphrontRequest $request) { 7 7 $this->requireApplicationCapability( 8 8 AuthManageProvidersCapability::CAPABILITY); 9 - $request = $this->getRequest(); 10 - $viewer = $request->getUser(); 11 9 12 - $providers = PhabricatorAuthProvider::getAllBaseProviders(); 13 - 14 - $e_provider = null; 15 - $errors = array(); 16 - 17 - if ($request->isFormPost()) { 18 - $provider_string = $request->getStr('provider'); 19 - if (!strlen($provider_string)) { 20 - $e_provider = pht('Required'); 21 - $errors[] = pht('You must select an authentication provider.'); 22 - } else { 23 - $found = false; 24 - foreach ($providers as $provider) { 25 - if (get_class($provider) === $provider_string) { 26 - $found = true; 27 - break; 28 - } 29 - } 30 - if (!$found) { 31 - $e_provider = pht('Invalid'); 32 - $errors[] = pht('You must select a valid provider.'); 33 - } 34 - } 35 - 36 - if (!$errors) { 37 - return id(new AphrontRedirectResponse())->setURI( 38 - $this->getApplicationURI('/config/new/'.$provider_string.'/')); 39 - } 40 - } 10 + $viewer = $this->getViewer(); 11 + $cancel_uri = $this->getApplicationURI(); 41 12 42 - $options = id(new AphrontFormRadioButtonControl()) 43 - ->setLabel(pht('Provider')) 44 - ->setName('provider') 45 - ->setError($e_provider); 13 + $providers = PhabricatorAuthProvider::getAllBaseProviders(); 46 14 47 15 $configured = PhabricatorAuthProvider::getAllProviders(); 48 16 $configured_classes = array(); ··· 55 23 $providers = msort($providers, 'getLoginOrder'); 56 24 $providers = array_diff_key($providers, $configured_classes) + $providers; 57 25 58 - foreach ($providers as $provider) { 59 - if (isset($configured_classes[get_class($provider)])) { 60 - $disabled = true; 61 - $description = pht('This provider is already configured.'); 62 - } else { 63 - $disabled = false; 64 - $description = $provider->getDescriptionForCreate(); 65 - } 66 - $options->addButton( 67 - get_class($provider), 68 - $provider->getNameForCreate(), 69 - $description, 70 - $disabled ? 'disabled' : null, 71 - $disabled); 72 - } 26 + $menu = id(new PHUIObjectItemListView()) 27 + ->setViewer($viewer) 28 + ->setBig(true) 29 + ->setFlush(true); 30 + 31 + foreach ($providers as $provider_key => $provider) { 32 + $provider_class = get_class($provider); 33 + 34 + $provider_uri = id(new PhutilURI('/config/edit/')) 35 + ->setQueryParam('provider', $provider_class); 36 + $provider_uri = $this->getApplicationURI($provider_uri); 73 37 74 - $form = id(new AphrontFormView()) 75 - ->setUser($viewer) 76 - ->appendChild($options) 77 - ->appendChild( 78 - id(new AphrontFormSubmitControl()) 79 - ->addCancelButton($this->getApplicationURI()) 80 - ->setValue(pht('Continue'))); 38 + $already_exists = isset($configured_classes[get_class($provider)]); 81 39 82 - $form_box = id(new PHUIObjectBoxView()) 83 - ->setHeaderText(pht('Provider')) 84 - ->setFormErrors($errors) 85 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 86 - ->setForm($form); 40 + $item = id(new PHUIObjectItemView()) 41 + ->setHeader($provider->getNameForCreate()) 42 + ->setImageIcon($provider->newIconView()) 43 + ->addAttribute($provider->getDescriptionForCreate()); 87 44 88 - $crumbs = $this->buildApplicationCrumbs(); 89 - $crumbs->addTextCrumb(pht('Add Provider')); 90 - $crumbs->setBorder(true); 45 + if (!$already_exists) { 46 + $item 47 + ->setHref($provider_uri) 48 + ->setClickable(true); 49 + } else { 50 + $item->setDisabled(true); 51 + } 91 52 92 - $title = pht('Add Auth Provider'); 53 + if ($already_exists) { 54 + $messages = array(); 55 + $messages[] = pht('You already have a provider of this type.'); 93 56 94 - $header = id(new PHUIHeaderView()) 95 - ->setHeader($title) 96 - ->setHeaderIcon('fa-plus-square'); 57 + $info = id(new PHUIInfoView()) 58 + ->setSeverity(PHUIInfoView::SEVERITY_WARNING) 59 + ->setErrors($messages); 97 60 98 - $view = id(new PHUITwoColumnView()) 99 - ->setHeader($header) 100 - ->setFooter(array( 101 - $form_box, 102 - )); 61 + $item->appendChild($info); 62 + } 103 63 104 - return $this->newPage() 105 - ->setTitle($title) 106 - ->setCrumbs($crumbs) 107 - ->appendChild($view); 64 + $menu->addItem($item); 65 + } 108 66 67 + return $this->newDialog() 68 + ->setTitle(pht('Add Auth Provider')) 69 + ->setWidth(AphrontDialogView::WIDTH_FORM) 70 + ->appendChild($menu) 71 + ->addCancelButton($cancel_uri); 109 72 } 110 73 111 74 }
+6
src/applications/auth/provider/PhabricatorAuthProvider.php
··· 311 311 return 'Generic'; 312 312 } 313 313 314 + public function newIconView() { 315 + return id(new PHUIIconView()) 316 + ->setSpriteSheet(PHUIIconView::SPRITE_LOGIN) 317 + ->setSpriteIcon($this->getLoginIcon()); 318 + } 319 + 314 320 public function isLoginFormAButton() { 315 321 return false; 316 322 }