@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Show account cards for external accounts on "linked accounts" screen and "link new account"

Summary: Ref T1536. These can probably use some design tweaking and there's a bit of a bug with profile images for some providers, but generally seems to be in the right ballpark.

Test Plan:
{F46604}

{F46605}

Reviewers: chad, btrahan

Reviewed By: chad

CC: aran

Maniphest Tasks: T1536

Differential Revision: https://secure.phabricator.com/D6210

+166 -2
+1 -1
src/__celerity_resource_map__.php
··· 923 923 ), 924 924 'auth-css' => 925 925 array( 926 - 'uri' => '/res/81f72bfa/rsrc/css/application/auth/auth.css', 926 + 'uri' => '/res/2ed0846e/rsrc/css/application/auth/auth.css', 927 927 'type' => 'css', 928 928 'requires' => 929 929 array(
+2
src/__phutil_library_map__.php
··· 814 814 'PhabricatorAuditQuery' => 'applications/audit/query/PhabricatorAuditQuery.php', 815 815 'PhabricatorAuditReplyHandler' => 'applications/audit/mail/PhabricatorAuditReplyHandler.php', 816 816 'PhabricatorAuditStatusConstants' => 'applications/audit/constants/PhabricatorAuditStatusConstants.php', 817 + 'PhabricatorAuthAccountView' => 'applications/auth/view/PhabricatorAuthAccountView.php', 817 818 'PhabricatorAuthConfirmLinkController' => 'applications/auth/controller/PhabricatorAuthConfirmLinkController.php', 818 819 'PhabricatorAuthController' => 'applications/auth/controller/PhabricatorAuthController.php', 819 820 'PhabricatorAuthLinkController' => 'applications/auth/controller/PhabricatorAuthLinkController.php', ··· 2678 2679 'PhabricatorAuditMailReceiver' => 'PhabricatorObjectMailReceiver', 2679 2680 'PhabricatorAuditPreviewController' => 'PhabricatorAuditController', 2680 2681 'PhabricatorAuditReplyHandler' => 'PhabricatorMailReplyHandler', 2682 + 'PhabricatorAuthAccountView' => 'AphrontView', 2681 2683 'PhabricatorAuthConfirmLinkController' => 'PhabricatorAuthController', 2682 2684 'PhabricatorAuthController' => 'PhabricatorController', 2683 2685 'PhabricatorAuthLinkController' => 'PhabricatorAuthController',
+6 -1
src/applications/auth/controller/PhabricatorAuthConfirmLinkController.php
··· 60 60 pht( 61 61 "Confirm the link with this %s account. This account will be ". 62 62 "able to log in to your Phabricator account.", 63 - $provider->getProviderName()))); 63 + $provider->getProviderName()))) 64 + ->appendChild( 65 + id(new PhabricatorAuthAccountView()) 66 + ->setUser($viewer) 67 + ->setExternalAccount($account) 68 + ->setAuthProvider($provider)); 64 69 65 70 $dialog->appendChild($form); 66 71
+115
src/applications/auth/view/PhabricatorAuthAccountView.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthAccountView extends AphrontView { 4 + 5 + private $externalAccount; 6 + private $provider; 7 + 8 + public function setExternalAccount( 9 + PhabricatorExternalAccount $external_account) { 10 + $this->externalAccount = $external_account; 11 + return $this; 12 + } 13 + 14 + public function setAuthProvider(PhabricatorAuthProvider $provider) { 15 + $this->provider = $provider; 16 + return $this; 17 + } 18 + 19 + public function render() { 20 + $account = $this->externalAccount; 21 + $provider = $this->provider; 22 + 23 + require_celerity_resource('auth-css'); 24 + 25 + $content = array(); 26 + 27 + $dispname = $account->getDisplayName(); 28 + $username = $account->getUsername(); 29 + $realname = $account->getRealName(); 30 + 31 + $use_name = null; 32 + if (strlen($dispname)) { 33 + $use_name = $dispname; 34 + } else if (strlen($username) && strlen($realname)) { 35 + $use_name = $username.' ('.$realname.')'; 36 + } else if (strlen($username)) { 37 + $use_name = $username; 38 + } else if (strlen($realname)) { 39 + $use_name = $realname; 40 + } else { 41 + $use_name = $account->getAccountID(); 42 + } 43 + 44 + $content[] = phutil_tag( 45 + 'div', 46 + array( 47 + 'class' => 'auth-account-view-name', 48 + ), 49 + $use_name); 50 + 51 + if ($provider) { 52 + $prov_name = pht('%s Account', $provider->getProviderName()); 53 + } else { 54 + $prov_name = pht('"%s" Account', $account->getProviderType()); 55 + } 56 + 57 + $content[] = phutil_tag( 58 + 'div', 59 + array( 60 + 'class' => 'auth-account-view-provider-name', 61 + ), 62 + array( 63 + $prov_name, 64 + " \xC2\xB7 ", 65 + $account->getAccountID(), 66 + )); 67 + 68 + $account_uri = $account->getAccountURI(); 69 + if (strlen($account_uri)) { 70 + 71 + // Make sure we don't link a "javascript:" URI if a user somehow 72 + // managed to get one here. 73 + 74 + if (PhabricatorEnv::isValidRemoteWebResource($account_uri)) { 75 + $account_uri = phutil_tag( 76 + 'a', 77 + array( 78 + 'href' => $account_uri, 79 + 'target' => '_blank', 80 + ), 81 + $account_uri); 82 + } 83 + 84 + $content[] = phutil_tag( 85 + 'div', 86 + array( 87 + 'class' => 'auth-account-view-account-uri', 88 + ), 89 + $account_uri); 90 + } 91 + 92 + // TODO: This fetch is sketchy. We should probably build 93 + // ExternalAccountQuery and move the logic there. 94 + 95 + $image_uri = PhabricatorUser::getDefaultProfileImageURI(); 96 + if ($account->getProfileImagePHID()) { 97 + $image = id(new PhabricatorFileQuery()) 98 + ->setUser(PhabricatorUser::getOmnipotentUser()) 99 + ->withPHIDs(array($account->getProfileImagePHID())) 100 + ->executeOne(); 101 + if ($image) { 102 + $image_uri = $image->getProfileThumbURI(); 103 + } 104 + } 105 + 106 + return phutil_tag( 107 + 'div', 108 + array( 109 + 'class' => 'auth-account-view', 110 + 'style' => 'background-image: url('.$image_uri.')', 111 + ), 112 + $content); 113 + } 114 + 115 + }
+3
src/applications/files/controller/PhabricatorFileTransformController.php
··· 49 49 $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); 50 50 51 51 switch ($this->transform) { 52 + case 'thumb-profile': 53 + $xformed_file = $this->executeThumbTransform($file, 50, 50); 54 + break; 52 55 case 'thumb-280x210': 53 56 $xformed_file = $this->executeThumbTransform($file, 280, 210); 54 57 break;
+6
src/applications/files/storage/PhabricatorFile.php
··· 491 491 return (string) $uri; 492 492 } 493 493 494 + public function getProfileThumbURI() { 495 + $path = '/file/xform/thumb-profile/'.$this->getPHID().'/' 496 + .$this->getSecretKey().'/'; 497 + return PhabricatorEnv::getCDNURI($path); 498 + } 499 + 494 500 public function getThumb60x45URI() { 495 501 $path = '/file/xform/thumb-60x45/'.$this->getPHID().'/' 496 502 .$this->getSecretKey().'/';
+15
src/applications/settings/panel/PhabricatorSettingsPanelExternalAccounts.php
··· 74 74 ->setDisabled(!$can_unlink) 75 75 ->setHref('/auth/unlink/'.$account->getProviderKey().'/')); 76 76 77 + $account_view = id(new PhabricatorAuthAccountView()) 78 + ->setExternalAccount($account); 79 + 80 + if ($provider) { 81 + $account_view->setAuthProvider($provider); 82 + } 83 + 84 + $item->appendChild( 85 + phutil_tag( 86 + 'div', 87 + array( 88 + 'class' => 'mmr mml mst mmb', 89 + ), 90 + $account_view)); 91 + 77 92 $linked->addItem($item); 78 93 } 79 94
+18
webroot/rsrc/css/application/auth/auth.css
··· 22 22 .phabricator-link-button { 23 23 text-align: center; 24 24 } 25 + 26 + .auth-account-view { 27 + border: 1px solid #aaaaaa; 28 + background-repeat: no-repeat; 29 + background-position: 4px 4px; 30 + padding: 4px 4px 4px 62px; 31 + min-height: 50px; 32 + border-radius: 2px; 33 + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); 34 + } 35 + 36 + .auth-account-view-name { 37 + font-weight: bold; 38 + } 39 + 40 + .auth-account-view-provider-name { 41 + color: #888888; 42 + }