From f46e3badae6a3f30788c709886c6ee442dbd4e17 Mon Sep 17 00:00:00 2001 From: Anh Nhan Nguyen Date: Tue, 2 Apr 2013 08:58:52 -0700 Subject: [PATCH] Modernized People Ldap Controller a tiny little bit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../PhabricatorPeopleLdapController.php | 73 +++++++++++++------ 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/src/applications/people/controller/PhabricatorPeopleLdapController.php b/src/applications/people/controller/PhabricatorPeopleLdapController.php index 48ed98d904..f5a2903f32 100644 --- a/src/applications/people/controller/PhabricatorPeopleLdapController.php +++ b/src/applications/people/controller/PhabricatorPeopleLdapController.php @@ -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, + ); }