1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

In "External Accounts", replace hard-to-find tiny "link" icon with a nice button with text on it

Summary:
Ref T6703. Replaces the small "link" icon with a more obvious "Link External Account" button.

Moves us toward operating against `$config` objects instead of against `$provider` objects, which is more modern and will some day allow us to resolve T6703.

Test Plan: Viewed page, saw a more obvious button. Linked an external account.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T6703

Differential Revision: https://secure.phabricator.com/D20105
This commit is contained in:
epriestley 2019-02-06 07:23:59 -08:00
parent 55286d49e8
commit d6f691cf5d
2 changed files with 34 additions and 12 deletions

View file

@ -95,6 +95,15 @@ final class PhabricatorAuthProviderConfig
return $this->getProvider()->getProviderName(); return $this->getProvider()->getProviderName();
} }
public function getSortVector() {
return id(new PhutilSortVector())
->addString($this->getDisplayName());
}
public function newIconView() {
return $this->getProvider()->newIconView();
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */ /* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -105,26 +105,39 @@ final class PhabricatorExternalAccountsSettingsPanel
$accounts = mpull($accounts, null, 'getProviderKey'); $accounts = mpull($accounts, null, 'getProviderKey');
$providers = PhabricatorAuthProvider::getAllEnabledProviders(); $configs = id(new PhabricatorAuthProviderConfigQuery())
$providers = msort($providers, 'getProviderName'); ->setViewer($viewer)
foreach ($providers as $key => $provider) { ->withIsEnabled(true)
if (isset($accounts[$key])) { ->execute();
continue; $configs = msort($configs, 'getSortVector');
}
foreach ($configs as $config) {
$provider = $config->getProvider();
if (!$provider->shouldAllowAccountLink()) { if (!$provider->shouldAllowAccountLink()) {
continue; 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().'/'; $link_uri = '/auth/link/'.$provider->getProviderKey().'/';
$item = id(new PHUIObjectItemView()) $link_button = id(new PHUIButtonView())
->setHeader($provider->getProviderName()) ->setTag('a')
->setIcon('fa-link')
->setHref($link_uri) ->setHref($link_uri)
->addAction( ->setColor(PHUIButtonView::GREY)
id(new PHUIListItemView()) ->setText(pht('Link External Account'));
->setIcon('fa-link')
->setHref($link_uri)); $item = id(new PHUIObjectItemView())
->setHeader($config->getDisplayName())
->setHref($link_uri)
->setImageIcon($config->newIconView())
->setSideColumn($link_button);
$linkable->addItem($item); $linkable->addItem($item);
} }