From 2c435433e0db993e18d00f7fbdde26027c7e3f78 Mon Sep 17 00:00:00 2001 From: Austin McKinley Date: Wed, 10 Jul 2019 09:26:15 -0700 Subject: [PATCH] Start fleshing out PhabricatorAuthProviderViewController Summary: Ref D20645. Start making this view a little more useful: {F6573605} Test Plan: Mk. 1 eyeball Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D20646 --- .../PhabricatorAuthProviderViewController.php | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/src/applications/auth/controller/config/PhabricatorAuthProviderViewController.php b/src/applications/auth/controller/config/PhabricatorAuthProviderViewController.php index 532744001c..abf9bf8eff 100644 --- a/src/applications/auth/controller/config/PhabricatorAuthProviderViewController.php +++ b/src/applications/auth/controller/config/PhabricatorAuthProviderViewController.php @@ -114,6 +114,86 @@ final class PhabricatorAuthProviderViewController pht('Provider Type'), $config->getProvider()->getProviderName()); + $status = $this->buildStatus($config); + $view->addProperty(pht('Status'), $status); + return $view; } + + private function buildStatus(PhabricatorAuthProviderConfig $config) { + $viewer = $this->getViewer(); + $view = id(new PHUIStatusListView()) + ->setViewer($viewer); + + $icon_enabled = PHUIStatusItemView::ICON_ACCEPT; + $icon_disabled = PHUIStatusItemView::ICON_REJECT; + + $icon_map = array( + true => $icon_enabled, + false => $icon_disabled, + ); + + $color_map = array( + true => 'green', + false => 'red', + ); + + $provider = $config->getProvider(); + + $view->addItem( + id(new PHUIStatusItemView()) + ->setIcon( + $icon_map[$config->getIsEnabled()], + $color_map[$config->getIsEnabled()]) + ->setTarget(pht('Provider Enabled'))); + + $view->addItem( + id(new PHUIStatusItemView()) + ->setIcon( + $icon_map[$config->getShouldAllowLogin()], + $color_map[$config->getShouldAllowLogin()]) + ->setTarget(pht('Allow Logins'))); + + $view->addItem( + id(new PHUIStatusItemView()) + ->setIcon( + $icon_map[$config->getShouldAllowRegistration()], + $color_map[$config->getShouldAllowRegistration()]) + ->setTarget(pht('Allow Registration'))); + + $view->addItem( + id(new PHUIStatusItemView()) + ->setIcon( + $icon_map[$config->getShouldAllowLink()], + $color_map[$config->getShouldAllowLink()]) + ->setTarget(pht('Allow Account Linking'))); + + $view->addItem( + id(new PHUIStatusItemView()) + ->setIcon( + $icon_map[$config->getShouldAllowUnlink()], + $color_map[$config->getShouldAllowUnlink()]) + ->setTarget(pht('Allow Account Unlinking'))); + + if ($provider->shouldAllowEmailTrustConfiguration()) { + $view->addItem( + id(new PHUIStatusItemView()) + ->setIcon( + $icon_map[$config->getShouldTrustEmails()], + $color_map[$config->getShouldTrustEmails()]) + ->setTarget(pht('Trust Email Addresses'))); + } + + if ($provider->supportsAutoLogin()) { + $view->addItem( + id(new PHUIStatusItemView()) + ->setIcon( + $icon_map[$config->getShouldAutoLogin()], + $color_map[$config->getShouldAutoLogin()]) + ->setTarget(pht('Allow Auto Login'))); + } + + return $view; + } + }