diff --git a/src/applications/auth/storage/PhabricatorAuthProviderConfig.php b/src/applications/auth/storage/PhabricatorAuthProviderConfig.php index 6a8bbe1a0d..876a70c2d0 100644 --- a/src/applications/auth/storage/PhabricatorAuthProviderConfig.php +++ b/src/applications/auth/storage/PhabricatorAuthProviderConfig.php @@ -95,6 +95,15 @@ final class PhabricatorAuthProviderConfig return $this->getProvider()->getProviderName(); } + public function getSortVector() { + return id(new PhutilSortVector()) + ->addString($this->getDisplayName()); + } + + public function newIconView() { + return $this->getProvider()->newIconView(); + } + /* -( PhabricatorApplicationTransactionInterface )------------------------- */ diff --git a/src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php b/src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php index 1215487208..9401cddbef 100644 --- a/src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php +++ b/src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php @@ -105,26 +105,39 @@ final class PhabricatorExternalAccountsSettingsPanel $accounts = mpull($accounts, null, 'getProviderKey'); - $providers = PhabricatorAuthProvider::getAllEnabledProviders(); - $providers = msort($providers, 'getProviderName'); - foreach ($providers as $key => $provider) { - if (isset($accounts[$key])) { - continue; - } + $configs = id(new PhabricatorAuthProviderConfigQuery()) + ->setViewer($viewer) + ->withIsEnabled(true) + ->execute(); + $configs = msort($configs, 'getSortVector'); + + foreach ($configs as $config) { + $provider = $config->getProvider(); if (!$provider->shouldAllowAccountLink()) { continue; } + // Don't show the user providers they already have linked. + $provider_key = $config->getProvider()->getProviderKey(); + if (isset($accounts[$provider_key])) { + continue; + } + $link_uri = '/auth/link/'.$provider->getProviderKey().'/'; - $item = id(new PHUIObjectItemView()) - ->setHeader($provider->getProviderName()) + $link_button = id(new PHUIButtonView()) + ->setTag('a') + ->setIcon('fa-link') ->setHref($link_uri) - ->addAction( - id(new PHUIListItemView()) - ->setIcon('fa-link') - ->setHref($link_uri)); + ->setColor(PHUIButtonView::GREY) + ->setText(pht('Link External Account')); + + $item = id(new PHUIObjectItemView()) + ->setHeader($config->getDisplayName()) + ->setHref($link_uri) + ->setImageIcon($config->newIconView()) + ->setSideColumn($link_button); $linkable->addItem($item); }