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

Add List/ApplicationSearch to AuthProviderConfig

Summary: Ref T1536. Adds a list controller and ApplicationSearch integration for listing providers.

Test Plan: {F46308}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1536

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

+167 -4
+10
src/__phutil_library_map__.php
··· 819 819 'PhabricatorAuthController' => 'applications/auth/controller/PhabricatorAuthController.php', 820 820 'PhabricatorAuthDAO' => 'applications/auth/storage/PhabricatorAuthDAO.php', 821 821 'PhabricatorAuthLinkController' => 'applications/auth/controller/PhabricatorAuthLinkController.php', 822 + 'PhabricatorAuthListController' => 'applications/auth/controller/config/PhabricatorAuthListController.php', 822 823 'PhabricatorAuthLoginController' => 'applications/auth/controller/PhabricatorAuthLoginController.php', 823 824 'PhabricatorAuthProvider' => 'applications/auth/provider/PhabricatorAuthProvider.php', 824 825 'PhabricatorAuthProviderConfig' => 'applications/auth/storage/PhabricatorAuthProviderConfig.php', 826 + 'PhabricatorAuthProviderConfigController' => 'applications/auth/controller/config/PhabricatorAuthProviderConfigController.php', 825 827 'PhabricatorAuthProviderConfigQuery' => 'applications/auth/query/PhabricatorAuthProviderConfigQuery.php', 828 + 'PhabricatorAuthProviderConfigSearchEngine' => 'applications/auth/query/PhabricatorAuthProviderConfigSearchEngine.php', 826 829 'PhabricatorAuthProviderConfigTransaction' => 'applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php', 827 830 'PhabricatorAuthProviderConfigTransactionQuery' => 'applications/auth/query/PhabricatorAuthProviderConfigTransactionQuery.php', 828 831 'PhabricatorAuthProviderLDAP' => 'applications/auth/provider/PhabricatorAuthProviderLDAP.php', ··· 2689 2692 'PhabricatorAuthController' => 'PhabricatorController', 2690 2693 'PhabricatorAuthDAO' => 'PhabricatorLiskDAO', 2691 2694 'PhabricatorAuthLinkController' => 'PhabricatorAuthController', 2695 + 'PhabricatorAuthListController' => 2696 + array( 2697 + 0 => 'PhabricatorAuthProviderConfigController', 2698 + 1 => 'PhabricatorApplicationSearchResultsControllerInterface', 2699 + ), 2692 2700 'PhabricatorAuthLoginController' => 'PhabricatorAuthController', 2693 2701 'PhabricatorAuthProviderConfig' => 2694 2702 array( 2695 2703 0 => 'PhabricatorAuthDAO', 2696 2704 1 => 'PhabricatorPolicyInterface', 2697 2705 ), 2706 + 'PhabricatorAuthProviderConfigController' => 'PhabricatorAuthController', 2698 2707 'PhabricatorAuthProviderConfigQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 2708 + 'PhabricatorAuthProviderConfigSearchEngine' => 'PhabricatorApplicationSearchEngine', 2699 2709 'PhabricatorAuthProviderConfigTransaction' => 'PhabricatorApplicationTransaction', 2700 2710 'PhabricatorAuthProviderConfigTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 2701 2711 'PhabricatorAuthProviderLDAP' => 'PhabricatorAuthProvider',
+10 -4
src/applications/auth/application/PhabricatorApplicationAuth.php
··· 2 2 3 3 final class PhabricatorApplicationAuth extends PhabricatorApplication { 4 4 5 - public function shouldAppearInLaunchView() { 6 - return false; 7 - } 8 - 9 5 public function canUninstall() { 10 6 return false; 11 7 } ··· 33 29 return $items; 34 30 } 35 31 32 + public function shouldAppearInLaunchView() { 33 + return false; 34 + } 35 + 36 36 public function getRoutes() { 37 37 return array( 38 38 '/auth/' => array( 39 + /* 40 + 41 + '(query/(?P<key>[^/]+)/)?' => 42 + 'PhabricatorAuthListController', 43 + 44 + */ 39 45 'login/(?P<pkey>[^/]+)/' => 'PhabricatorAuthLoginController', 40 46 'register/(?:(?P<akey>[^/]+)/)?' => 'PhabricatorAuthRegisterController', 41 47 'start/' => 'PhabricatorAuthStartController',
+37
src/applications/auth/controller/config/PhabricatorAuthListController.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthListController 4 + extends PhabricatorAuthProviderConfigController 5 + implements PhabricatorApplicationSearchResultsControllerInterface { 6 + 7 + private $key; 8 + 9 + public function willProcessRequest(array $data) { 10 + $this->key = idx($data, 'key'); 11 + } 12 + 13 + public function processRequest() { 14 + $request = $this->getRequest(); 15 + $controller = id(new PhabricatorApplicationSearchController($request)) 16 + ->setQueryKey($this->key) 17 + ->setSearchEngine(new PhabricatorAuthProviderConfigSearchEngine()) 18 + ->setNavigation($this->buildSideNavView()); 19 + 20 + return $this->delegateToController($controller); 21 + } 22 + 23 + public function renderResultsList(array $configs) { 24 + assert_instances_of($configs, 'PhabricatorAuthProviderConfig'); 25 + $viewer = $this->getRequest()->getUser(); 26 + 27 + $list = new PhabricatorObjectItemListView(); 28 + foreach ($configs as $config) { 29 + $item = new PHUIListItemView(); 30 + 31 + $list->addItem($item); 32 + } 33 + 34 + return $list; 35 + } 36 + 37 + }
+44
src/applications/auth/controller/config/PhabricatorAuthProviderConfigController.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorAuthProviderConfigController 4 + extends PhabricatorAuthController { 5 + 6 + public function shouldRequireAdmin() { 7 + return true; 8 + } 9 + 10 + protected function buildSideNavView($for_app = false) { 11 + $nav = new AphrontSideNavFilterView(); 12 + $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); 13 + 14 + if ($for_app) { 15 + $nav->addLabel(pht('Create')); 16 + $nav->addFilter('', 17 + pht('Add Authentication Provider'), 18 + $this->getApplicationURI('/config/new/')); 19 + } 20 + 21 + id(new PhabricatorAuthProviderConfigSearchEngine()) 22 + ->setViewer($this->getRequest()->getUser()) 23 + ->addNavigationItems($nav->getMenu()); 24 + 25 + return $nav; 26 + } 27 + 28 + public function buildApplicationMenu() { 29 + return $this->buildSideNavView($for_app = true)->getMenu(); 30 + } 31 + 32 + protected function buildApplicationCrumbs() { 33 + $crumbs = parent::buildApplicationCrumbs(); 34 + 35 + $crumbs->addAction( 36 + id(new PHUIListItemView()) 37 + ->setName(pht('Add Authentication Provider')) 38 + ->setHref($this->getApplicationURI('/config/new/')) 39 + ->setIcon('create')); 40 + 41 + return $crumbs; 42 + } 43 + 44 + }
+66
src/applications/auth/query/PhabricatorAuthProviderConfigSearchEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthProviderConfigSearchEngine 4 + extends PhabricatorApplicationSearchEngine { 5 + 6 + public function buildSavedQueryFromRequest(AphrontRequest $request) { 7 + $saved = new PhabricatorSavedQuery(); 8 + $saved->setParameter('status', $request->getStr('status')); 9 + return $saved; 10 + } 11 + 12 + public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 13 + $query = new PhabricatorAuthProviderConfigQuery(); 14 + 15 + $status = $saved->getParameter('status'); 16 + $options = PhabricatorAuthProviderConfigQuery::getStatusOptions(); 17 + if (empty($options[$status])) { 18 + $status = head_key($options); 19 + } 20 + $query->withStatus($status); 21 + 22 + return $query; 23 + } 24 + 25 + public function buildSearchForm( 26 + AphrontFormView $form, 27 + PhabricatorSavedQuery $saved_query) { 28 + 29 + $status = $saved_query->getParameter('status'); 30 + 31 + $form 32 + ->appendChild( 33 + id(new AphrontFormSelectControl()) 34 + ->setName('status') 35 + ->setLabel(pht('Status')) 36 + ->setOptions(PhabricatorAuthProviderConfigQuery::getStatusOptions()) 37 + ->setValue($status)); 38 + } 39 + 40 + protected function getURI($path) { 41 + return '/auth/'.$path; 42 + } 43 + 44 + public function getBuiltinQueryNames() { 45 + $names = array( 46 + 'all' => pht('All'), 47 + ); 48 + 49 + return $names; 50 + } 51 + 52 + public function buildSavedQueryFromBuiltin($query_key) { 53 + $query = $this->newSavedQuery(); 54 + $query->setQueryKey($query_key); 55 + 56 + switch ($query_key) { 57 + case 'all': 58 + return $query->setParameter( 59 + 'status', 60 + PhabricatorAuthProviderConfigQuery::STATUS_ALL); 61 + } 62 + 63 + return parent::buildSavedQueryFromBuiltin($query_key); 64 + } 65 + 66 + }