@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.

Add login buttons for button logins, fix LDAP form

Summary: Ref T1536.

Test Plan:
{F46555}

{F46556}

Reviewers: chad, btrahan

Reviewed By: chad

CC: aran

Maniphest Tasks: T1536

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

+204 -88
+54 -45
src/__celerity_resource_map__.php
··· 921 921 ), 922 922 'disk' => '/rsrc/css/aphront/typeahead.css', 923 923 ), 924 + 'auth-css' => 925 + array( 926 + 'uri' => '/res/8a95bad7/rsrc/css/application/auth/auth.css', 927 + 'type' => 'css', 928 + 'requires' => 929 + array( 930 + ), 931 + 'disk' => '/rsrc/css/application/auth/auth.css', 932 + ), 924 933 'config-options-css' => 925 934 array( 926 935 'uri' => '/res/be77d5a6/rsrc/css/application/config/config-options.css', ··· 3687 3696 ), 3688 3697 'phui-button-css' => 3689 3698 array( 3690 - 'uri' => '/res/8fc82931/rsrc/css/phui/phui-button.css', 3699 + 'uri' => '/res/458ea66c/rsrc/css/phui/phui-button.css', 3691 3700 'type' => 'css', 3692 3701 'requires' => 3693 3702 array( ··· 4048 4057 ), array( 4049 4058 'packages' => 4050 4059 array( 4051 - '1cdd0caf' => 4060 + '116c8dcd' => 4052 4061 array( 4053 4062 'name' => 'core.pkg.css', 4054 4063 'symbols' => ··· 4096 4105 40 => 'phabricator-property-list-view-css', 4097 4106 41 => 'phabricator-tag-view-css', 4098 4107 ), 4099 - 'uri' => '/res/pkg/1cdd0caf/core.pkg.css', 4108 + 'uri' => '/res/pkg/116c8dcd/core.pkg.css', 4100 4109 'type' => 'css', 4101 4110 ), 4102 4111 'f2ad0683' => ··· 4290 4299 'reverse' => 4291 4300 array( 4292 4301 'aphront-attached-file-view-css' => 'a7ca34a9', 4293 - 'aphront-dialog-view-css' => '1cdd0caf', 4294 - 'aphront-error-view-css' => '1cdd0caf', 4295 - 'aphront-form-view-css' => '1cdd0caf', 4296 - 'aphront-list-filter-view-css' => '1cdd0caf', 4297 - 'aphront-pager-view-css' => '1cdd0caf', 4298 - 'aphront-panel-view-css' => '1cdd0caf', 4299 - 'aphront-table-view-css' => '1cdd0caf', 4300 - 'aphront-tokenizer-control-css' => '1cdd0caf', 4301 - 'aphront-tooltip-css' => '1cdd0caf', 4302 - 'aphront-typeahead-control-css' => '1cdd0caf', 4302 + 'aphront-dialog-view-css' => '116c8dcd', 4303 + 'aphront-error-view-css' => '116c8dcd', 4304 + 'aphront-form-view-css' => '116c8dcd', 4305 + 'aphront-list-filter-view-css' => '116c8dcd', 4306 + 'aphront-pager-view-css' => '116c8dcd', 4307 + 'aphront-panel-view-css' => '116c8dcd', 4308 + 'aphront-table-view-css' => '116c8dcd', 4309 + 'aphront-tokenizer-control-css' => '116c8dcd', 4310 + 'aphront-tooltip-css' => '116c8dcd', 4311 + 'aphront-typeahead-control-css' => '116c8dcd', 4303 4312 'differential-changeset-view-css' => 'dd27a69b', 4304 4313 'differential-core-view-css' => 'dd27a69b', 4305 4314 'differential-inline-comment-editor' => '9488bb69', ··· 4313 4322 'differential-table-of-contents-css' => 'dd27a69b', 4314 4323 'diffusion-commit-view-css' => 'c8ce2d88', 4315 4324 'diffusion-icons-css' => 'c8ce2d88', 4316 - 'global-drag-and-drop-css' => '1cdd0caf', 4325 + 'global-drag-and-drop-css' => '116c8dcd', 4317 4326 'inline-comment-summary-css' => 'dd27a69b', 4318 4327 'javelin-aphlict' => 'f2ad0683', 4319 4328 'javelin-behavior' => 'a9f14d76', ··· 4387 4396 'javelin-util' => 'a9f14d76', 4388 4397 'javelin-vector' => 'a9f14d76', 4389 4398 'javelin-workflow' => 'a9f14d76', 4390 - 'lightbox-attachment-css' => '1cdd0caf', 4399 + 'lightbox-attachment-css' => '116c8dcd', 4391 4400 'maniphest-task-summary-css' => 'a7ca34a9', 4392 4401 'maniphest-transaction-detail-css' => 'a7ca34a9', 4393 - 'phabricator-action-list-view-css' => '1cdd0caf', 4394 - 'phabricator-application-launch-view-css' => '1cdd0caf', 4402 + 'phabricator-action-list-view-css' => '116c8dcd', 4403 + 'phabricator-application-launch-view-css' => '116c8dcd', 4395 4404 'phabricator-busy' => 'f2ad0683', 4396 4405 'phabricator-content-source-view-css' => 'dd27a69b', 4397 - 'phabricator-core-css' => '1cdd0caf', 4398 - 'phabricator-crumbs-view-css' => '1cdd0caf', 4406 + 'phabricator-core-css' => '116c8dcd', 4407 + 'phabricator-crumbs-view-css' => '116c8dcd', 4399 4408 'phabricator-drag-and-drop-file-upload' => '9488bb69', 4400 4409 'phabricator-dropdown-menu' => 'f2ad0683', 4401 4410 'phabricator-file-upload' => 'f2ad0683', 4402 - 'phabricator-filetree-view-css' => '1cdd0caf', 4403 - 'phabricator-flag-css' => '1cdd0caf', 4404 - 'phabricator-form-view-css' => '1cdd0caf', 4405 - 'phabricator-header-view-css' => '1cdd0caf', 4411 + 'phabricator-filetree-view-css' => '116c8dcd', 4412 + 'phabricator-flag-css' => '116c8dcd', 4413 + 'phabricator-form-view-css' => '116c8dcd', 4414 + 'phabricator-header-view-css' => '116c8dcd', 4406 4415 'phabricator-hovercard' => 'f2ad0683', 4407 - 'phabricator-jump-nav' => '1cdd0caf', 4416 + 'phabricator-jump-nav' => '116c8dcd', 4408 4417 'phabricator-keyboard-shortcut' => 'f2ad0683', 4409 4418 'phabricator-keyboard-shortcut-manager' => 'f2ad0683', 4410 - 'phabricator-main-menu-view' => '1cdd0caf', 4419 + 'phabricator-main-menu-view' => '116c8dcd', 4411 4420 'phabricator-menu-item' => 'f2ad0683', 4412 - 'phabricator-nav-view-css' => '1cdd0caf', 4421 + 'phabricator-nav-view-css' => '116c8dcd', 4413 4422 'phabricator-notification' => 'f2ad0683', 4414 - 'phabricator-notification-css' => '1cdd0caf', 4415 - 'phabricator-notification-menu-css' => '1cdd0caf', 4416 - 'phabricator-object-item-list-view-css' => '1cdd0caf', 4423 + 'phabricator-notification-css' => '116c8dcd', 4424 + 'phabricator-notification-menu-css' => '116c8dcd', 4425 + 'phabricator-object-item-list-view-css' => '116c8dcd', 4417 4426 'phabricator-object-selector-css' => 'dd27a69b', 4418 4427 'phabricator-phtize' => 'f2ad0683', 4419 4428 'phabricator-prefab' => 'f2ad0683', 4420 4429 'phabricator-project-tag-css' => 'a7ca34a9', 4421 - 'phabricator-property-list-view-css' => '1cdd0caf', 4422 - 'phabricator-remarkup-css' => '1cdd0caf', 4430 + 'phabricator-property-list-view-css' => '116c8dcd', 4431 + 'phabricator-remarkup-css' => '116c8dcd', 4423 4432 'phabricator-shaped-request' => '9488bb69', 4424 - 'phabricator-side-menu-view-css' => '1cdd0caf', 4425 - 'phabricator-standard-page-view' => '1cdd0caf', 4426 - 'phabricator-tag-view-css' => '1cdd0caf', 4433 + 'phabricator-side-menu-view-css' => '116c8dcd', 4434 + 'phabricator-standard-page-view' => '116c8dcd', 4435 + 'phabricator-tag-view-css' => '116c8dcd', 4427 4436 'phabricator-textareautils' => 'f2ad0683', 4428 4437 'phabricator-tooltip' => 'f2ad0683', 4429 - 'phabricator-transaction-view-css' => '1cdd0caf', 4430 - 'phabricator-zindex-css' => '1cdd0caf', 4431 - 'phui-button-css' => '1cdd0caf', 4432 - 'phui-form-css' => '1cdd0caf', 4433 - 'phui-icon-view-css' => '1cdd0caf', 4434 - 'phui-spacing-css' => '1cdd0caf', 4435 - 'sprite-apps-large-css' => '1cdd0caf', 4436 - 'sprite-gradient-css' => '1cdd0caf', 4437 - 'sprite-icons-css' => '1cdd0caf', 4438 - 'sprite-menu-css' => '1cdd0caf', 4439 - 'syntax-highlighting-css' => '1cdd0caf', 4438 + 'phabricator-transaction-view-css' => '116c8dcd', 4439 + 'phabricator-zindex-css' => '116c8dcd', 4440 + 'phui-button-css' => '116c8dcd', 4441 + 'phui-form-css' => '116c8dcd', 4442 + 'phui-icon-view-css' => '116c8dcd', 4443 + 'phui-spacing-css' => '116c8dcd', 4444 + 'sprite-apps-large-css' => '116c8dcd', 4445 + 'sprite-gradient-css' => '116c8dcd', 4446 + 'sprite-icons-css' => '116c8dcd', 4447 + 'sprite-menu-css' => '116c8dcd', 4448 + 'syntax-highlighting-css' => '116c8dcd', 4440 4449 ), 4441 4450 ));
+44 -2
src/applications/auth/controller/PhabricatorAuthStartController.php
··· 65 65 $request->setCookie('phcid', Filesystem::readRandomCharacters(16)); 66 66 } 67 67 68 + $not_buttons = array(); 69 + $are_buttons = array(); 70 + $providers = msort($providers, 'getLoginOrder'); 71 + foreach ($providers as $provider) { 72 + if ($provider->isLoginFormAButton()) { 73 + $are_buttons[] = $provider->buildLoginForm($this); 74 + } else { 75 + $not_buttons[] = $provider->buildLoginForm($this); 76 + } 77 + } 78 + 68 79 $out = array(); 69 - foreach ($providers as $provider) { 70 - $out[] = $provider->buildLoginForm($this); 80 + $out[] = $not_buttons; 81 + if ($are_buttons) { 82 + require_celerity_resource('auth-css'); 83 + 84 + foreach ($are_buttons as $key => $button) { 85 + $are_buttons[$key] = phutil_tag( 86 + 'div', 87 + array( 88 + 'class' => 'phabricator-login-button mmb', 89 + ), 90 + $button); 91 + } 92 + 93 + // If we only have one button, add a second pretend button so that we 94 + // always have two columns. This makes it easier to get the alignments 95 + // looking reasonable. 96 + if (count($are_buttons) == 1) { 97 + $are_buttons[] = null; 98 + } 99 + 100 + $button_columns = id(new AphrontMultiColumnView()) 101 + ->setFluidLayout(true); 102 + $are_buttons = array_chunk($are_buttons, ceil(count($are_buttons) / 2)); 103 + foreach ($are_buttons as $column) { 104 + $button_columns->addColumn($column); 105 + } 106 + 107 + $out[] = phutil_tag( 108 + 'div', 109 + array( 110 + 'class' => 'phabricator-login-buttons', 111 + ), 112 + $button_columns); 71 113 } 72 114 73 115 $login_message = PhabricatorEnv::getEnvConfig('auth.login-message');
+12
src/applications/auth/provider/PhabricatorAuthProvider.php
··· 167 167 throw new Exception("Not implemented!"); 168 168 } 169 169 170 + public function getLoginOrder() { 171 + return '500-'.$this->getProviderName(); 172 + } 173 + 174 + protected function getLoginIcon() { 175 + return 'Generic'; 176 + } 177 + 178 + public function isLoginFormAButton() { 179 + return false; 180 + } 181 + 170 182 }
+18 -14
src/applications/auth/provider/PhabricatorAuthProviderLDAP.php
··· 67 67 68 68 $viewer = $request->getUser(); 69 69 70 - $submit = id(new AphrontFormSubmitControl()) 71 - ->setValue(pht('Login or Register')); 70 + $dialog = id(new AphrontDialogView()) 71 + ->setSubmitURI($this->getLoginURI()) 72 + ->setUser($viewer); 72 73 73 - $header = id(new PhabricatorHeaderView()) 74 - ->setHeader(pht('Login with LDAP')); 74 + if ($this->shouldAllowRegistration()) { 75 + $dialog->setTitle(pht('Login or Register with LDAP')); 76 + $dialog->addSubmitButton(pht('Login or Register')); 77 + } else { 78 + $dialog->setTitle(pht('Login with LDAP')); 79 + $dialog->addSubmitButton(pht('Login')); 80 + } 75 81 76 82 $v_user = $request->getStr('ldap_username'); 77 83 ··· 87 93 $errors[] = pht('Username or password are incorrect.'); 88 94 } 89 95 90 - $form = id(new AphrontFormView()) 91 - ->setAction($this->getLoginURI()) 96 + $form = id(new AphrontFormLayoutView()) 92 97 ->setUser($viewer) 93 - ->setFlexible(true) 98 + ->setFullWidth(true) 94 99 ->appendChild( 95 100 id(new AphrontFormTextControl()) 96 101 ->setLabel('LDAP Username') ··· 101 106 id(new AphrontFormPasswordControl()) 102 107 ->setLabel('LDAP Password') 103 108 ->setName('ldap_password') 104 - ->setError($e_pass)) 105 - ->appendChild($submit); 109 + ->setError($e_pass)); 106 110 107 111 if ($errors) { 108 112 $errors = id(new AphrontErrorView())->setErrors($errors); 109 113 } 110 114 111 - return array( 112 - $errors, 113 - $header, 114 - $form, 115 - ); 115 + $dialog->appendChild($errors); 116 + $dialog->appendChild($form); 117 + 118 + 119 + return $dialog; 116 120 } 117 121 118 122 public function processLoginRequest(
+32 -23
src/applications/auth/provider/PhabricatorAuthProviderOAuth.php
··· 36 36 return $adapter; 37 37 } 38 38 39 + public function isLoginFormAButton() { 40 + return true; 41 + } 42 + 39 43 public function buildLoginForm( 40 44 PhabricatorAuthStartController $controller) { 41 45 42 46 $request = $controller->getRequest(); 43 47 $viewer = $request->getUser(); 44 48 45 - $form = id(new AphrontFormView()) 46 - ->setUser($viewer); 47 - 48 - $submit = new AphrontFormSubmitControl(); 49 - 50 49 if ($this->shouldAllowRegistration()) { 51 - $submit->setValue( 52 - pht("Login or Register with %s \xC2\xBB", $this->getProviderName())); 53 - $header = pht("Login or Register with %s", $this->getProviderName()); 50 + $button_text = pht('Login or Register'); 54 51 } else { 55 - $submit->setValue( 56 - pht("Login with %s \xC2\xBB", $this->getProviderName())); 57 - $header = pht("Login with %s", $this->getProviderName()); 52 + $button_text = pht('Login'); 58 53 } 59 54 60 - $form->appendChild($submit); 55 + $icon = id(new PHUIIconView()) 56 + ->setSpriteSheet(PHUIIconView::SPRITE_LOGIN) 57 + ->setSpriteIcon($this->getLoginIcon()); 61 58 62 - // TODO: This is pretty hideous. 63 - $panel = new AphrontPanelView(); 64 - $panel->setHeader($header); 65 - $panel->setWidth(AphrontPanelView::WIDTH_FORM); 66 - $panel->setNoBackground(true); 67 - $panel->appendChild($form); 59 + $button = id(new PHUIButtonView()) 60 + ->setTag('a') 61 + ->setSize(PHUIButtonView::BIG) 62 + ->setColor(PHUIButtonView::GREY) 63 + ->setIcon($icon) 64 + ->setText($button_text) 65 + ->setSubtext($this->getProviderName()); 68 66 69 67 $adapter = $this->getAdapter(); 70 68 $adapter->setState(PhabricatorHash::digest($request->getCookie('phcid'))); ··· 73 71 $params = $uri->getQueryParams(); 74 72 $uri->setQueryParams(array()); 75 73 76 - $form->setAction((string)$uri); 74 + $content = array($button); 75 + 77 76 foreach ($params as $key => $value) { 78 - $form->addHiddenInput($key, $value); 77 + $content[] = phutil_tag( 78 + 'input', 79 + array( 80 + 'type' => 'hidden', 81 + 'name' => $key, 82 + 'value' => $value, 83 + )); 79 84 } 80 85 81 - $form->setMethod('GET'); 82 - 83 - return $panel; 86 + return phabricator_form( 87 + $viewer, 88 + array( 89 + 'method' => 'GET', 90 + 'action' => (string)$uri, 91 + ), 92 + $content); 84 93 } 85 94 86 95 public function processLoginRequest(
+4
src/applications/auth/provider/PhabricatorAuthProviderOAuthDisqus.php
··· 11 11 return new PhutilAuthAdapterOAuthDisqus(); 12 12 } 13 13 14 + protected function getLoginIcon() { 15 + return 'Disqus'; 16 + } 17 + 14 18 public function isEnabled() { 15 19 return parent::isEnabled() && 16 20 PhabricatorEnv::getEnvConfig('disqus.auth-enabled');
+4
src/applications/auth/provider/PhabricatorAuthProviderOAuthFacebook.php
··· 11 11 return new PhutilAuthAdapterOAuthFacebook(); 12 12 } 13 13 14 + protected function getLoginIcon() { 15 + return 'Facebook'; 16 + } 17 + 14 18 public function isEnabled() { 15 19 return parent::isEnabled() && 16 20 PhabricatorEnv::getEnvConfig('facebook.auth-enabled');
+4
src/applications/auth/provider/PhabricatorAuthProviderOAuthGitHub.php
··· 11 11 return new PhutilAuthAdapterOAuthGitHub(); 12 12 } 13 13 14 + protected function getLoginIcon() { 15 + return 'Github'; 16 + } 17 + 14 18 public function isEnabled() { 15 19 return parent::isEnabled() && 16 20 PhabricatorEnv::getEnvConfig('github.auth-enabled');
+4
src/applications/auth/provider/PhabricatorAuthProviderOAuthGoogle.php
··· 11 11 return new PhutilAuthAdapterOAuthGoogle(); 12 12 } 13 13 14 + protected function getLoginIcon() { 15 + return 'Google'; 16 + } 17 + 14 18 public function isEnabled() { 15 19 return parent::isEnabled() && 16 20 PhabricatorEnv::getEnvConfig('google.auth-enabled');
+5
src/applications/auth/provider/PhabricatorAuthProviderPassword.php
··· 24 24 return $this->adapter; 25 25 } 26 26 27 + public function getLoginOrder() { 28 + // Make sure username/password appears first if it is enabled. 29 + return '100-'.$this->getProviderName(); 30 + } 31 + 27 32 public function shouldAllowLogin() { 28 33 return true; 29 34 }
+1 -2
src/view/phui/PHUIButtonView.php
··· 93 93 $subtext = null; 94 94 if ($this->subtext) { 95 95 $subtext = phutil_tag( 96 - 'span', array('class' => 'phui-button-subtext'), $this->subtext); 97 - $subtext = hsprintf('<br />%s', $subtext); 96 + 'div', array('class' => 'phui-button-subtext'), $this->subtext); 98 97 } 99 98 $text = phutil_tag( 100 99 'div', array('class' => 'phui-button-text'), array($text, $subtext));
+20
webroot/rsrc/css/application/auth/auth.css
··· 1 + /** 2 + * @provides auth-css 3 + */ 4 + 5 + .phabricator-login-buttons { 6 + max-width: 450px; 7 + margin: auto; 8 + } 9 + 10 + .phabricator-login-buttons .phabricator-login-button .button { 11 + width: 180px; 12 + } 13 + 14 + .device-desktop .phabricator-login-buttons .aphront-multi-column-column-last { 15 + text-align: right; 16 + } 17 + 18 + .device .phabricator-login-buttons { 19 + text-align: center; 20 + }
+2 -2
webroot/rsrc/css/phui/phui-button.css
··· 246 246 .button.big.has-icon { 247 247 padding: 6px 20px 6px 12px; 248 248 border-radius: 4px; 249 + text-align: left; 249 250 } 250 251 251 252 .button.big.has-icon .phui-button-text { ··· 257 258 .button.big.has-icon .phui-button-subtext { 258 259 color: #888; 259 260 font-size: 12px; 260 - line-height: 16px; 261 + line-height: 14px; 261 262 font-weight: normal; 262 - float: left; 263 263 }