@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 "allow null" and username hinting to the Passphrase credential control

Summary:
Ref T4122.

- For Diffusion, we need "allow null" (permits selection of "No Credential") for anonymous HTTP repositories.
- For Diffusion, we can make things a little easier to configure by prefilling the username.

Test Plan: Used UIExample form. These featuers are used in a future revision.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4122

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

+48 -7
+2 -1
src/__celerity_resource_map__.php
··· 1982 1982 ), 1983 1983 'javelin-behavior-passphrase-credential-control' => 1984 1984 array( 1985 - 'uri' => '/res/e606ad52/rsrc/js/application/passphrase/phame-credential-control.js', 1985 + 'uri' => '/res/70823662/rsrc/js/application/passphrase/phame-credential-control.js', 1986 1986 'type' => 'js', 1987 1987 'requires' => 1988 1988 array( ··· 1991 1991 2 => 'javelin-stratcom', 1992 1992 3 => 'javelin-workflow', 1993 1993 4 => 'javelin-util', 1994 + 5 => 'javelin-uri', 1994 1995 ), 1995 1996 'disk' => '/rsrc/js/application/passphrase/phame-credential-control.js', 1996 1997 ),
+3
src/applications/passphrase/controller/PassphraseCredentialEditController.php
··· 45 45 ->setProvidesType($type->getProvidesType()); 46 46 47 47 $is_new = true; 48 + 49 + // Prefill username if provided. 50 + $credential->setUsername($request->getStr('username')); 48 51 } 49 52 50 53 $errors = array();
+21 -3
src/applications/passphrase/view/PassphraseCredentialControl.php
··· 4 4 5 5 private $options; 6 6 private $credentialType; 7 + private $defaultUsername; 8 + private $allowNull; 9 + 10 + public function setAllowNull($allow_null) { 11 + $this->allowNull = $allow_null; 12 + return $this; 13 + } 14 + 15 + public function setDefaultUsername($default_username) { 16 + $this->defaultUsername = $default_username; 17 + return $this; 18 + } 7 19 8 20 public function setCredentialType($credential_type) { 9 21 $this->credentialType = $credential_type; ··· 35 47 } 36 48 37 49 $disabled = $this->getDisabled(); 38 - if (!$options_map) { 39 - $options_map[''] = pht('(No Existing Credentials)'); 40 - $disabled = true; 50 + if ($this->allowNull) { 51 + $options_map = array('' => pht('(No Credentials)')) + $options_map; 52 + } else { 53 + if (!$options_map) { 54 + $options_map[''] = pht('(No Existing Credentials)'); 55 + $disabled = true; 56 + } 41 57 } 42 58 43 59 Javelin::initBehavior('passphrase-credential-control'); ··· 68 84 'sigil' => 'passphrase-credential-control', 69 85 'meta' => array( 70 86 'type' => $this->getCredentialType(), 87 + 'username' => $this->defaultUsername, 88 + 'allowNull' => $this->allowNull, 71 89 ), 72 90 ), 73 91 array(
+22 -3
webroot/rsrc/js/application/passphrase/phame-credential-control.js
··· 5 5 * javelin-stratcom 6 6 * javelin-workflow 7 7 * javelin-util 8 + * javelin-uri 9 + * @javelin 8 10 */ 9 11 10 12 JX.behavior('passphrase-credential-control', function(config) { ··· 16 18 var control = e.getNode('passphrase-credential-control'); 17 19 var data = e.getNodeData('passphrase-credential-control'); 18 20 19 - new JX.Workflow('/passphrase/edit/?type=' + data.type) 21 + var uri = JX.$U('/passphrase/edit/'); 22 + uri.setQueryParam('type', data.type); 23 + uri.setQueryParam('username', data.username); 24 + 25 + new JX.Workflow(uri) 20 26 .setHandler(JX.bind(null, onadd, control)) 21 27 .start(); 22 28 ··· 26 32 function onadd(control, response) { 27 33 var select = JX.DOM.find(control, 'select', 'passphrase-credential-select'); 28 34 35 + var data = JX.Stratcom.getData(control); 36 + 37 + // If this allows the user to select "No Credential" (`allowNull`), 38 + // put the new credential in the menu below the "No Credential" option. 39 + 40 + // Otherwise, remove the "(No Existing Credentials)" if it exists and 41 + // put the new credential at the top. 42 + 43 + var target = 0; 29 44 for (var ii = 0; ii < select.options.length; ii++) { 30 45 if (!select.options[ii].value) { 31 - select.remove(ii); 46 + if (!data.allowNull) { 47 + select.remove(ii); 48 + } else { 49 + target = ii + 1; 50 + } 32 51 break; 33 52 } 34 53 } 35 54 36 55 select.add( 37 56 JX.$N('option', {value: response.phid}, response.name), 38 - select.options[0] || null); 57 + select.options[target] || null); 39 58 40 59 select.value = response.phid; 41 60 select.disabled = null;