1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Build out Auth UI a little bit

Summary: Ref T1536. Make this UI a bit more human-friendly.

Test Plan: {F46873}

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T1536

Differential Revision: https://secure.phabricator.com/D6237
This commit is contained in:
epriestley 2013-06-19 15:00:37 -07:00
parent f7a09efc7e
commit 6b1f15ac54
5 changed files with 56 additions and 100 deletions

View file

@ -834,7 +834,6 @@ phutil_register_library_map(array(
'PhabricatorAuthProviderConfigController' => 'applications/auth/controller/config/PhabricatorAuthProviderConfigController.php',
'PhabricatorAuthProviderConfigEditor' => 'applications/auth/editor/PhabricatorAuthProviderConfigEditor.php',
'PhabricatorAuthProviderConfigQuery' => 'applications/auth/query/PhabricatorAuthProviderConfigQuery.php',
'PhabricatorAuthProviderConfigSearchEngine' => 'applications/auth/query/PhabricatorAuthProviderConfigSearchEngine.php',
'PhabricatorAuthProviderConfigTransaction' => 'applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php',
'PhabricatorAuthProviderConfigTransactionQuery' => 'applications/auth/query/PhabricatorAuthProviderConfigTransactionQuery.php',
'PhabricatorAuthProviderLDAP' => 'applications/auth/provider/PhabricatorAuthProviderLDAP.php',
@ -2689,11 +2688,7 @@ phutil_register_library_map(array(
'PhabricatorAuthDisableController' => 'PhabricatorAuthProviderConfigController',
'PhabricatorAuthEditController' => 'PhabricatorAuthProviderConfigController',
'PhabricatorAuthLinkController' => 'PhabricatorAuthController',
'PhabricatorAuthListController' =>
array(
0 => 'PhabricatorAuthProviderConfigController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'PhabricatorAuthListController' => 'PhabricatorAuthProviderConfigController',
'PhabricatorAuthLoginController' => 'PhabricatorAuthController',
'PhabricatorAuthManagementLDAPWorkflow' => 'PhabricatorAuthManagementWorkflow',
'PhabricatorAuthManagementRecoverWorkflow' => 'PhabricatorAuthManagementWorkflow',
@ -2708,7 +2703,6 @@ phutil_register_library_map(array(
'PhabricatorAuthProviderConfigController' => 'PhabricatorAuthController',
'PhabricatorAuthProviderConfigEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorAuthProviderConfigQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorAuthProviderConfigSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorAuthProviderConfigTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorAuthProviderConfigTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorAuthProviderLDAP' => 'PhabricatorAuthProvider',

View file

@ -43,7 +43,7 @@ final class PhabricatorApplicationAuth extends PhabricatorApplication {
'/auth/' => array(
/*
'(query/(?P<key>[^/]+)/)?' => 'PhabricatorAuthListController',
'' => 'PhabricatorAuthListController',
'config/' => array(
'new/' => 'PhabricatorAuthNewController',
'new/(?P<className>[^/]+)/' => 'PhabricatorAuthEditController',

View file

@ -1,28 +1,15 @@
<?php
final class PhabricatorAuthListController
extends PhabricatorAuthProviderConfigController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $key;
public function willProcessRequest(array $data) {
$this->key = idx($data, 'key');
}
extends PhabricatorAuthProviderConfigController {
public function processRequest() {
$request = $this->getRequest();
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->key)
->setSearchEngine(new PhabricatorAuthProviderConfigSearchEngine())
->setNavigation($this->buildSideNavView());
$viewer = $request->getUser();
return $this->delegateToController($controller);
}
public function renderResultsList(array $configs) {
assert_instances_of($configs, 'PhabricatorAuthProviderConfig');
$viewer = $this->getRequest()->getUser();
$configs = id(new PhabricatorAuthProviderConfigQuery())
->setViewer($viewer)
->execute();
$list = new PhabricatorObjectItemListView();
foreach ($configs as $config) {
@ -34,12 +21,28 @@ final class PhabricatorAuthListController
$enable_uri = $this->getApplicationURI('config/enable/'.$id.'/');
$disable_uri = $this->getApplicationURI('config/disable/'.$id.'/');
// TODO: Needs to be built out.
$provider = $config->getProvider();
if ($provider) {
$name = $provider->getProviderName();
} else {
$name = $config->getProviderType();
}
$item
->setHeader($config->getProviderType())
->setHeader($name)
->setHref($edit_uri);
$domain = $provider->getProviderDomain();
if ($domain !== 'self') {
$item->addAttribute($domain);
}
if ($config->getShouldAllowRegistration()) {
$item->addAttribute(pht('Allows Registration'));
}
if ($config->getIsEnabled()) {
$item->setBarColor('green');
$item->addAction(
id(new PHUIListItemView())
->setIcon('delete')
@ -58,7 +61,37 @@ final class PhabricatorAuthListController
$list->addItem($item);
}
return $list;
$list->setNoDataString(
pht(
'%s You have not added authentication providers yet. Use "%s" to add '.
'a provider, which will let users register new Phabricator accounts '.
'and log in.',
phutil_tag(
'strong',
array(),
pht('No Providers Configured:')),
phutil_tag(
'a',
array(
'href' => $this->getApplicationURI('config/new/'),
),
pht('Add Authentication Provider'))));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht('Auth Providers')));
return $this->buildApplicationPage(
array(
$crumbs,
$list,
),
array(
'title' => pht('Authentication Providers'),
'dust' => true,
'device' => true,
));
}
}

View file

@ -17,11 +17,6 @@ abstract class PhabricatorAuthProviderConfigController
pht('Add Authentication Provider'),
$this->getApplicationURI('/config/new/'));
}
id(new PhabricatorAuthProviderConfigSearchEngine())
->setViewer($this->getRequest()->getUser())
->addNavigationItems($nav->getMenu());
return $nav;
}

View file

@ -1,66 +0,0 @@
<?php
final class PhabricatorAuthProviderConfigSearchEngine
extends PhabricatorApplicationSearchEngine {
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
$saved->setParameter('status', $request->getStr('status'));
return $saved;
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = new PhabricatorAuthProviderConfigQuery();
$status = $saved->getParameter('status');
$options = PhabricatorAuthProviderConfigQuery::getStatusOptions();
if (empty($options[$status])) {
$status = head_key($options);
}
$query->withStatus($status);
return $query;
}
public function buildSearchForm(
AphrontFormView $form,
PhabricatorSavedQuery $saved_query) {
$status = $saved_query->getParameter('status');
$form
->appendChild(
id(new AphrontFormSelectControl())
->setName('status')
->setLabel(pht('Status'))
->setOptions(PhabricatorAuthProviderConfigQuery::getStatusOptions())
->setValue($status));
}
protected function getURI($path) {
return '/auth/'.$path;
}
public function getBuiltinQueryNames() {
$names = array(
'all' => pht('All'),
);
return $names;
}
public function buildSavedQueryFromBuiltin($query_key) {
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
switch ($query_key) {
case 'all':
return $query->setParameter(
'status',
PhabricatorAuthProviderConfigQuery::STATUS_ALL);
}
return parent::buildSavedQueryFromBuiltin($query_key);
}
}