1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 01:10:58 +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
extends PhabricatorPeopleController {
private $view;
public function processRequest() {
$request = $this->getRequest();
@ -33,30 +31,39 @@ final class PhabricatorPeopleLdapController
id(new AphrontFormSubmitControl())
->setValue(pht('Search')));
$panel = new AphrontPanelView();
$panel->setHeader(pht('Import LDAP Users'));
$panel->appendChild($form);
$panel = id(new AphrontPanelView())
->setHeader(pht('Import LDAP Users'))
->setNoBackground()
->setWidth(AphrontPanelView::WIDTH_FORM)
->appendChild($form);
if ($request->getStr('import')) {
$content[] = $this->processImportRequest($request);
}
$content[] = $panel;
if ($request->getStr('search')) {
$content[] = $this->processSearchRequest($request);
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht('Import Ldap Users'))
->setHref($this->getApplicationURI('/ldap/')));
$nav = $this->buildSideNavView();
$nav->setCrumbs($crumbs);
$nav->selectFilter('ldap');
$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(
$nav,
array(
'title' => pht('Import Ldap Users'),
'title' => pht('Import Ldap Users'),
'device' => true,
'dust' => true,
));
}
@ -66,11 +73,15 @@ final class PhabricatorPeopleLdapController
$emails = $request->getArr('email');
$names = $request->getArr('name');
$panel = new AphrontErrorView();
$panel->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$panel->setTitle(pht("Import Successful"));
$errors = array(pht("Successfully imported users from LDAP"));
$notice_view = new AphrontErrorView();
$notice_view->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$notice_view->setTitle(pht("Import Successful"));
$notice_view->setErrors(array(
pht("Successfully imported users from LDAP"),
));
$list = new PhabricatorObjectItemListView();
$list->setNoDataString(pht("No users imported?"));
foreach ($usernames as $username) {
$user = new PhabricatorUser();
@ -89,14 +100,28 @@ final class PhabricatorPeopleLdapController
$ldap_info->setLDAPUsername($username);
$ldap_info->setUserID($user->getID());
$ldap_info->save();
$errors[] = pht('Successfully added %s', $username);
$header = pht('Successfully added %s', $username);
$attribute = null;
$color = 'green';
} 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 $panel;
return array(
$notice_view,
$list,
);
}