1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +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();
}
public function getSortVector() {
return id(new PhutilSortVector())
->addString($this->getDisplayName());
}
public function newIconView() {
return $this->getProvider()->newIconView();
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -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);
}