Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15400359
D7624.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D7624.diff
View Options
Index: src/__celerity_resource_map__.php
===================================================================
--- src/__celerity_resource_map__.php
+++ src/__celerity_resource_map__.php
@@ -1982,7 +1982,7 @@
),
'javelin-behavior-passphrase-credential-control' =>
array(
- 'uri' => '/res/e606ad52/rsrc/js/application/passphrase/phame-credential-control.js',
+ 'uri' => '/res/70823662/rsrc/js/application/passphrase/phame-credential-control.js',
'type' => 'js',
'requires' =>
array(
@@ -1991,6 +1991,7 @@
2 => 'javelin-stratcom',
3 => 'javelin-workflow',
4 => 'javelin-util',
+ 5 => 'javelin-uri',
),
'disk' => '/rsrc/js/application/passphrase/phame-credential-control.js',
),
Index: src/applications/passphrase/controller/PassphraseCredentialEditController.php
===================================================================
--- src/applications/passphrase/controller/PassphraseCredentialEditController.php
+++ src/applications/passphrase/controller/PassphraseCredentialEditController.php
@@ -45,6 +45,9 @@
->setProvidesType($type->getProvidesType());
$is_new = true;
+
+ // Prefill username if provided.
+ $credential->setUsername($request->getStr('username'));
}
$errors = array();
Index: src/applications/passphrase/view/PassphraseCredentialControl.php
===================================================================
--- src/applications/passphrase/view/PassphraseCredentialControl.php
+++ src/applications/passphrase/view/PassphraseCredentialControl.php
@@ -4,6 +4,18 @@
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 @@
}
$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 @@
'sigil' => 'passphrase-credential-control',
'meta' => array(
'type' => $this->getCredentialType(),
+ 'username' => $this->defaultUsername,
+ 'allowNull' => $this->allowNull,
),
),
array(
Index: webroot/rsrc/js/application/passphrase/phame-credential-control.js
===================================================================
--- webroot/rsrc/js/application/passphrase/phame-credential-control.js
+++ webroot/rsrc/js/application/passphrase/phame-credential-control.js
@@ -5,6 +5,8 @@
* javelin-stratcom
* javelin-workflow
* javelin-util
+ * javelin-uri
+ * @javelin
*/
JX.behavior('passphrase-credential-control', function(config) {
@@ -16,7 +18,11 @@
var control = e.getNode('passphrase-credential-control');
var data = e.getNodeData('passphrase-credential-control');
- new JX.Workflow('/passphrase/edit/?type=' + data.type)
+ var uri = JX.$U('/passphrase/edit/');
+ uri.setQueryParam('type', data.type);
+ uri.setQueryParam('username', data.username);
+
+ new JX.Workflow(uri)
.setHandler(JX.bind(null, onadd, control))
.start();
@@ -26,16 +32,29 @@
function onadd(control, response) {
var select = JX.DOM.find(control, 'select', 'passphrase-credential-select');
+ var data = JX.Stratcom.getData(control);
+
+ // If this allows the user to select "No Credential" (`allowNull`),
+ // put the new credential in the menu below the "No Credential" option.
+
+ // Otherwise, remove the "(No Existing Credentials)" if it exists and
+ // put the new credential at the top.
+
+ var target = 0;
for (var ii = 0; ii < select.options.length; ii++) {
if (!select.options[ii].value) {
- select.remove(ii);
+ if (!data.allowNull) {
+ select.remove(ii);
+ } else {
+ target = ii + 1;
+ }
break;
}
}
select.add(
JX.$N('option', {value: response.phid}, response.name),
- select.options[0] || null);
+ select.options[target] || null);
select.value = response.phid;
select.disabled = null;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 18, 11:14 AM (4 d, 12 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7709727
Default Alt Text
D7624.diff (4 KB)
Attached To
Mode
D7624: Add "allow null" and username hinting to the Passphrase credential control
Attached
Detach File
Event Timeline
Log In to Comment