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

Move the Auth Provider edit flow toward a more modern layout

Summary:
Depends on D20095. Ref T13244. Currently, auth providers have a list item view and a single gigantic edit screen complete with a timeline, piles of instructions, supplemental information, etc.

As a step toward making this stuff easier to use and more modern, give them a separate view UI with normal actions, similar to basically every other type of object. Move the timeline and "Disable/Enable" to the view page (from the edit page and the list page, respectively).

Test Plan: Created, edited, and viewed auth providers.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13244

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

+171 -67
+2
src/__phutil_library_map__.php
··· 2335 2335 'PhabricatorAuthProviderConfigTransaction' => 'applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php', 2336 2336 'PhabricatorAuthProviderConfigTransactionQuery' => 'applications/auth/query/PhabricatorAuthProviderConfigTransactionQuery.php', 2337 2337 'PhabricatorAuthProviderController' => 'applications/auth/controller/config/PhabricatorAuthProviderController.php', 2338 + 'PhabricatorAuthProviderViewController' => 'applications/auth/controller/config/PhabricatorAuthProviderViewController.php', 2338 2339 'PhabricatorAuthProvidersGuidanceContext' => 'applications/auth/guidance/PhabricatorAuthProvidersGuidanceContext.php', 2339 2340 'PhabricatorAuthProvidersGuidanceEngineExtension' => 'applications/auth/guidance/PhabricatorAuthProvidersGuidanceEngineExtension.php', 2340 2341 'PhabricatorAuthQueryPublicKeysConduitAPIMethod' => 'applications/auth/conduit/PhabricatorAuthQueryPublicKeysConduitAPIMethod.php', ··· 8094 8095 'PhabricatorAuthProviderConfigTransaction' => 'PhabricatorApplicationTransaction', 8095 8096 'PhabricatorAuthProviderConfigTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 8096 8097 'PhabricatorAuthProviderController' => 'PhabricatorAuthController', 8098 + 'PhabricatorAuthProviderViewController' => 'PhabricatorAuthProviderConfigController', 8097 8099 'PhabricatorAuthProvidersGuidanceContext' => 'PhabricatorGuidanceContext', 8098 8100 'PhabricatorAuthProvidersGuidanceEngineExtension' => 'PhabricatorGuidanceEngineExtension', 8099 8101 'PhabricatorAuthQueryPublicKeysConduitAPIMethod' => 'PhabricatorAuthConduitAPIMethod',
+1
src/applications/auth/application/PhabricatorAuthApplication.php
··· 51 51 'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorAuthEditController', 52 52 '(?P<action>enable|disable)/(?P<id>\d+)/' 53 53 => 'PhabricatorAuthDisableController', 54 + 'view/(?P<id>\d+)/' => 'PhabricatorAuthProviderViewController', 54 55 ), 55 56 'login/(?P<pkey>[^/]+)/(?:(?P<extra>[^/]+)/)?' 56 57 => 'PhabricatorAuthLoginController',
+9 -10
src/applications/auth/controller/config/PhabricatorAuthDisableController.php
··· 6 6 public function handleRequest(AphrontRequest $request) { 7 7 $this->requireApplicationCapability( 8 8 AuthManageProvidersCapability::CAPABILITY); 9 - $viewer = $request->getUser(); 9 + 10 + $viewer = $this->getViewer(); 10 11 $config_id = $request->getURIData('id'); 11 12 $action = $request->getURIData('action'); 12 13 ··· 24 25 } 25 26 26 27 $is_enable = ($action === 'enable'); 28 + $done_uri = $config->getURI(); 27 29 28 30 if ($request->isDialogFormPost()) { 29 31 $xactions = array(); ··· 39 41 ->setContinueOnNoEffect(true) 40 42 ->applyTransactions($config, $xactions); 41 43 42 - return id(new AphrontRedirectResponse())->setURI( 43 - $this->getApplicationURI()); 44 + return id(new AphrontRedirectResponse())->setURI($done_uri); 44 45 } 45 46 46 47 if ($is_enable) { ··· 64 65 // account and pop a warning like "YOU WILL NO LONGER BE ABLE TO LOGIN 65 66 // YOU GOOF, YOU PROBABLY DO NOT MEAN TO DO THIS". None of this is 66 67 // critical and we can wait to see how users manage to shoot themselves 67 - // in the feet. Shortly, `bin/auth` will be able to recover from these 68 - // types of mistakes. 68 + // in the feet. 69 + 70 + // `bin/auth` can recover from these types of mistakes. 69 71 70 72 $title = pht('Disable Provider?'); 71 73 $body = pht( ··· 77 79 $button = pht('Disable Provider'); 78 80 } 79 81 80 - $dialog = id(new AphrontDialogView()) 81 - ->setUser($viewer) 82 + return $this->newDialog() 82 83 ->setTitle($title) 83 84 ->appendChild($body) 84 - ->addCancelButton($this->getApplicationURI()) 85 + ->addCancelButton($done_uri) 85 86 ->addSubmitButton($button); 86 - 87 - return id(new AphrontDialogResponse())->setDialog($dialog); 88 87 } 89 88 90 89 }
+2 -20
src/applications/auth/controller/config/PhabricatorAuthEditController.php
··· 156 156 ->setContinueOnNoEffect(true) 157 157 ->applyTransactions($config, $xactions); 158 158 159 - if ($provider->hasSetupStep() && $is_new) { 160 - $id = $config->getID(); 161 - $next_uri = $this->getApplicationURI('config/edit/'.$id.'/'); 162 - } else { 163 - $next_uri = $this->getApplicationURI(); 164 - } 159 + $next_uri = $config->getURI(); 165 160 166 161 return id(new AphrontRedirectResponse())->setURI($next_uri); 167 162 } ··· 185 180 $crumb = pht('Edit Provider'); 186 181 $title = pht('Edit Auth Provider'); 187 182 $header_icon = 'fa-pencil'; 188 - $cancel_uri = $this->getApplicationURI(); 183 + $cancel_uri = $config->getURI(); 189 184 } 190 185 191 186 $header = id(new PHUIHeaderView()) ··· 348 343 $crumbs->addTextCrumb($crumb); 349 344 $crumbs->setBorder(true); 350 345 351 - $timeline = null; 352 - if (!$is_new) { 353 - $timeline = $this->buildTransactionTimeline( 354 - $config, 355 - new PhabricatorAuthProviderConfigTransactionQuery()); 356 - $xactions = $timeline->getTransactions(); 357 - foreach ($xactions as $xaction) { 358 - $xaction->setProvider($provider); 359 - } 360 - $timeline->setShouldTerminate(true); 361 - } 362 - 363 346 $form_box = id(new PHUIObjectBoxView()) 364 347 ->setHeaderText(pht('Provider')) 365 348 ->setFormErrors($errors) ··· 371 354 ->setFooter(array( 372 355 $form_box, 373 356 $footer, 374 - $timeline, 375 357 )); 376 358 377 359 return $this->newPage()
+13 -37
src/applications/auth/controller/config/PhabricatorAuthListController.php
··· 19 19 20 20 $id = $config->getID(); 21 21 22 - $edit_uri = $this->getApplicationURI('config/edit/'.$id.'/'); 23 - $enable_uri = $this->getApplicationURI('config/enable/'.$id.'/'); 24 - $disable_uri = $this->getApplicationURI('config/disable/'.$id.'/'); 22 + $view_uri = $config->getURI(); 25 23 26 24 $provider = $config->getProvider(); 27 - if ($provider) { 28 - $name = $provider->getProviderName(); 29 - } else { 30 - $name = $config->getProviderType().' ('.$config->getProviderClass().')'; 31 - } 25 + $name = $provider->getProviderName(); 32 26 33 - $item->setHeader($name); 27 + $item 28 + ->setHeader($name) 29 + ->setHref($view_uri); 34 30 35 - if ($provider) { 36 - $item->setHref($edit_uri); 37 - } else { 38 - $item->addAttribute(pht('Provider Implementation Missing!')); 39 - } 40 - 41 - $domain = null; 42 - if ($provider) { 43 - $domain = $provider->getProviderDomain(); 44 - if ($domain !== 'self') { 45 - $item->addAttribute($domain); 46 - } 31 + $domain = $provider->getProviderDomain(); 32 + if ($domain !== 'self') { 33 + $item->addAttribute($domain); 47 34 } 48 35 49 36 if ($config->getShouldAllowRegistration()) { ··· 54 41 55 42 if ($config->getIsEnabled()) { 56 43 $item->setStatusIcon('fa-check-circle green'); 57 - $item->addAction( 58 - id(new PHUIListItemView()) 59 - ->setIcon('fa-times') 60 - ->setHref($disable_uri) 61 - ->setDisabled(!$can_manage) 62 - ->addSigil('workflow')); 63 44 } else { 64 45 $item->setStatusIcon('fa-ban red'); 65 46 $item->addIcon('fa-ban grey', pht('Disabled')); 66 - $item->addAction( 67 - id(new PHUIListItemView()) 68 - ->setIcon('fa-plus') 69 - ->setHref($enable_uri) 70 - ->setDisabled(!$can_manage) 71 - ->addSigil('workflow')); 72 47 } 73 48 74 49 $list->addItem($item); ··· 123 98 124 99 $view = id(new PHUITwoColumnView()) 125 100 ->setHeader($header) 126 - ->setFooter(array( 127 - $guidance, 128 - $list, 129 - )); 101 + ->setFooter( 102 + array( 103 + $guidance, 104 + $list, 105 + )); 130 106 131 107 $nav = $this->newNavigation() 132 108 ->setCrumbs($crumbs)
+119
src/applications/auth/controller/config/PhabricatorAuthProviderViewController.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthProviderViewController 4 + extends PhabricatorAuthProviderConfigController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $this->requireApplicationCapability( 8 + AuthManageProvidersCapability::CAPABILITY); 9 + 10 + $viewer = $this->getViewer(); 11 + $id = $request->getURIData('id'); 12 + 13 + $config = id(new PhabricatorAuthProviderConfigQuery()) 14 + ->setViewer($viewer) 15 + ->requireCapabilities( 16 + array( 17 + PhabricatorPolicyCapability::CAN_VIEW, 18 + PhabricatorPolicyCapability::CAN_EDIT, 19 + )) 20 + ->withIDs(array($id)) 21 + ->executeOne(); 22 + if (!$config) { 23 + return new Aphront404Response(); 24 + } 25 + 26 + $header = $this->buildHeaderView($config); 27 + $properties = $this->buildPropertiesView($config); 28 + $curtain = $this->buildCurtain($config); 29 + 30 + $timeline = $this->buildTransactionTimeline( 31 + $config, 32 + new PhabricatorAuthProviderConfigTransactionQuery()); 33 + $timeline->setShouldTerminate(true); 34 + 35 + $view = id(new PHUITwoColumnView()) 36 + ->setHeader($header) 37 + ->setCurtain($curtain) 38 + ->addPropertySection(pht('Details'), $properties) 39 + ->setMainColumn($timeline); 40 + 41 + $crumbs = $this->buildApplicationCrumbs() 42 + ->addTextCrumb($config->getObjectName()) 43 + ->setBorder(true); 44 + 45 + return $this->newPage() 46 + ->setTitle(pht('Auth Provider: %s', $config->getDisplayName())) 47 + ->setCrumbs($crumbs) 48 + ->appendChild($view); 49 + } 50 + 51 + private function buildHeaderView(PhabricatorAuthProviderConfig $config) { 52 + $viewer = $this->getViewer(); 53 + 54 + $view = id(new PHUIHeaderView()) 55 + ->setViewer($viewer) 56 + ->setHeader($config->getDisplayName()); 57 + 58 + if ($config->getIsEnabled()) { 59 + $view->setStatus('fa-check', 'bluegrey', pht('Enabled')); 60 + } else { 61 + $view->setStatus('fa-ban', 'red', pht('Disabled')); 62 + } 63 + 64 + return $view; 65 + } 66 + 67 + private function buildCurtain(PhabricatorAuthProviderConfig $config) { 68 + $viewer = $this->getViewer(); 69 + $id = $config->getID(); 70 + 71 + $can_edit = PhabricatorPolicyFilter::hasCapability( 72 + $viewer, 73 + $config, 74 + PhabricatorPolicyCapability::CAN_EDIT); 75 + 76 + $curtain = $this->newCurtainView($config); 77 + 78 + $curtain->addAction( 79 + id(new PhabricatorActionView()) 80 + ->setName(pht('Edit Auth Provider')) 81 + ->setIcon('fa-pencil') 82 + ->setHref($this->getApplicationURI("config/edit/{$id}/")) 83 + ->setDisabled(!$can_edit) 84 + ->setWorkflow(!$can_edit)); 85 + 86 + if ($config->getIsEnabled()) { 87 + $disable_uri = $this->getApplicationURI('config/disable/'.$id.'/'); 88 + $disable_icon = 'fa-ban'; 89 + $disable_text = pht('Disable Provider'); 90 + } else { 91 + $disable_uri = $this->getApplicationURI('config/enable/'.$id.'/'); 92 + $disable_icon = 'fa-check'; 93 + $disable_text = pht('Enable Provider'); 94 + } 95 + 96 + $curtain->addAction( 97 + id(new PhabricatorActionView()) 98 + ->setName($disable_text) 99 + ->setIcon($disable_icon) 100 + ->setHref($disable_uri) 101 + ->setDisabled(!$can_edit) 102 + ->setWorkflow(true)); 103 + 104 + return $curtain; 105 + } 106 + 107 + private function buildPropertiesView(PhabricatorAuthProviderConfig $config) { 108 + $viewer = $this->getViewer(); 109 + 110 + $view = id(new PHUIPropertyListView()) 111 + ->setViewer($viewer); 112 + 113 + $view->addProperty( 114 + pht('Provider Type'), 115 + $config->getProvider()->getProviderName()); 116 + 117 + return $view; 118 + } 119 + }
+13
src/applications/auth/query/PhabricatorAuthProviderConfigQuery.php
··· 70 70 return $where; 71 71 } 72 72 73 + protected function willFilterPage(array $configs) { 74 + 75 + foreach ($configs as $key => $config) { 76 + $provider = $config->getProvider(); 77 + if (!$provider) { 78 + unset($configs[$key]); 79 + continue; 80 + } 81 + } 82 + 83 + return $configs; 84 + } 85 + 73 86 public function getQueryApplicationClass() { 74 87 return 'PhabricatorAuthApplication'; 75 88 }
+12
src/applications/auth/storage/PhabricatorAuthProviderConfig.php
··· 83 83 return $this->provider; 84 84 } 85 85 86 + public function getURI() { 87 + return '/auth/config/view/'.$this->getID().'/'; 88 + } 89 + 90 + public function getObjectName() { 91 + return pht('Auth Provider %d', $this->getID()); 92 + } 93 + 94 + public function getDisplayName() { 95 + return $this->getProvider()->getProviderName(); 96 + } 97 + 86 98 87 99 /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 88 100