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
This commit is contained in:
@@ -4,6 +4,18 @@ final class PassphraseCredentialControl extends AphrontFormControl {
|
||||
|
||||
private $options;
|
||||
private $credentialType;
|
||||
private $defaultUsername;
|
||||
private $allowNull;
|
||||
|
||||
public function setAllowNull($allow_null) {
|
||||
$this->allowNull = $allow_null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDefaultUsername($default_username) {
|
||||
$this->defaultUsername = $default_username;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCredentialType($credential_type) {
|
||||
$this->credentialType = $credential_type;
|
||||
@@ -35,9 +47,13 @@ final class PassphraseCredentialControl extends AphrontFormControl {
|
||||
}
|
||||
|
||||
$disabled = $this->getDisabled();
|
||||
if (!$options_map) {
|
||||
$options_map[''] = pht('(No Existing Credentials)');
|
||||
$disabled = true;
|
||||
if ($this->allowNull) {
|
||||
$options_map = array('' => pht('(No Credentials)')) + $options_map;
|
||||
} else {
|
||||
if (!$options_map) {
|
||||
$options_map[''] = pht('(No Existing Credentials)');
|
||||
$disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
Javelin::initBehavior('passphrase-credential-control');
|
||||
@@ -68,6 +84,8 @@ final class PassphraseCredentialControl extends AphrontFormControl {
|
||||
'sigil' => 'passphrase-credential-control',
|
||||
'meta' => array(
|
||||
'type' => $this->getCredentialType(),
|
||||
'username' => $this->defaultUsername,
|
||||
'allowNull' => $this->allowNull,
|
||||
),
|
||||
),
|
||||
array(
|
||||
|
||||
Reference in New Issue
Block a user