1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-17 10:11:10 +01:00

Modernized People Ldap Controller a tiny little bit

Summary: somewhat. de-uglified panels, add dust, etc. you get it.

Test Plan:
Visited, looked at nice new form.
Visited `http://phab.van/people/ldap/?import=true&usernames[]=anh&usernames[]=han&email[anh]=anh%40nhan.com&email[han]=han%40nhan.com&name[anh]=Nhan&name[han]=Nguyen` to hack in a few users. Did not work (CSRF ¬.¬), but saw what I wanted. Beautiful `PhabricatorObjectItemView`s. With color bars
These images where before the diff update. Error messages would appear as attributes (good for you that I did not include them, since it looks horrible)

The looks of it (refuse to take THIS in mobile):
{F36428}
{F36429}

Reviewers: epriestley, chad, btrahan

Reviewed By: btrahan

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5387
This commit is contained in:
Anh Nhan Nguyen 2013-04-02 08:58:52 -07:00 committed by epriestley
parent 70e0deb368
commit f46e3badae

View file

@ -3,8 +3,6 @@
final class PhabricatorPeopleLdapController final class PhabricatorPeopleLdapController
extends PhabricatorPeopleController { extends PhabricatorPeopleController {
private $view;
public function processRequest() { public function processRequest() {
$request = $this->getRequest(); $request = $this->getRequest();
@ -33,30 +31,39 @@ final class PhabricatorPeopleLdapController
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue(pht('Search'))); ->setValue(pht('Search')));
$panel = new AphrontPanelView(); $panel = id(new AphrontPanelView())
$panel->setHeader(pht('Import LDAP Users')); ->setHeader(pht('Import LDAP Users'))
$panel->appendChild($form); ->setNoBackground()
->setWidth(AphrontPanelView::WIDTH_FORM)
->appendChild($form);
$crumbs = $this->buildApplicationCrumbs();
if ($request->getStr('import')) { $crumbs->addCrumb(
$content[] = $this->processImportRequest($request); id(new PhabricatorCrumbView())
} ->setName(pht('Import Ldap Users'))
->setHref($this->getApplicationURI('/ldap/')));
$content[] = $panel;
if ($request->getStr('search')) {
$content[] = $this->processSearchRequest($request);
}
$nav = $this->buildSideNavView(); $nav = $this->buildSideNavView();
$nav->setCrumbs($crumbs);
$nav->selectFilter('ldap'); $nav->selectFilter('ldap');
$nav->appendChild($content); $nav->appendChild($content);
if ($request->getStr('import')) {
$nav->appendChild($this->processImportRequest($request));
}
$nav->appendChild($panel);
if ($request->getStr('search')) {
$nav->appendChild($this->processSearchRequest($request));
}
return $this->buildApplicationPage( return $this->buildApplicationPage(
$nav, $nav,
array( array(
'title' => pht('Import Ldap Users'), 'title' => pht('Import Ldap Users'),
'device' => true, 'device' => true,
'dust' => true,
)); ));
} }
@ -66,11 +73,15 @@ final class PhabricatorPeopleLdapController
$emails = $request->getArr('email'); $emails = $request->getArr('email');
$names = $request->getArr('name'); $names = $request->getArr('name');
$panel = new AphrontErrorView(); $notice_view = new AphrontErrorView();
$panel->setSeverity(AphrontErrorView::SEVERITY_NOTICE); $notice_view->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$panel->setTitle(pht("Import Successful")); $notice_view->setTitle(pht("Import Successful"));
$errors = array(pht("Successfully imported users from LDAP")); $notice_view->setErrors(array(
pht("Successfully imported users from LDAP"),
));
$list = new PhabricatorObjectItemListView();
$list->setNoDataString(pht("No users imported?"));
foreach ($usernames as $username) { foreach ($usernames as $username) {
$user = new PhabricatorUser(); $user = new PhabricatorUser();
@ -89,14 +100,28 @@ final class PhabricatorPeopleLdapController
$ldap_info->setLDAPUsername($username); $ldap_info->setLDAPUsername($username);
$ldap_info->setUserID($user->getID()); $ldap_info->setUserID($user->getID());
$ldap_info->save(); $ldap_info->save();
$errors[] = pht('Successfully added %s', $username);
$header = pht('Successfully added %s', $username);
$attribute = null;
$color = 'green';
} catch (Exception $ex) { } catch (Exception $ex) {
$errors[] = pht('Failed to add %s %s', $username, $ex->getMessage()); $header = pht('Failed to add %s', $username);
$attribute = $ex->getMessage();
$color = 'red';
} }
$item = id(new PhabricatorObjectItemView())
->setHeader($header)
->addAttribute($attribute)
->setBarColor($color);
$list->addItem($item);
} }
$panel->setErrors($errors); return array(
return $panel; $notice_view,
$list,
);
} }