fix form-secrets

This commit is contained in:
Westly Wright 2018-04-04 21:16:42 -07:00
parent 0907e6c5ad
commit e9b5c5123b
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
4 changed files with 27 additions and 16 deletions

View File

@ -65,17 +65,17 @@ export default Component.extend({
return out; return out;
}, },
}), }),
selectedSecret: null,
prefixOrKeys: computed('allSecrets.[]', 'secret.sourceName', function() { prefixOrKeys: computed('allSecrets.[]', 'secret.sourceName', function() {
let prefix = { id: 'prefix', label: 'All'}; let prefix = { id: 'prefix', label: 'All'};
let selectedSecret = get(this, 'secret.sourceName'); let secretSourceName = get(this, 'secret.sourceName');
let out = [prefix]; let out = [prefix];
let secret = get(this, 'selectedSecret');
if (selectedSecret) { if (secretSourceName) {
let secret = get(this, 'secrets').findBy('name', selectedSecret); if (get(secret, 'data')) {
let secretKeys = Object.keys(get(secret, 'data')); let secretKeys = Object.keys(get(secret, 'data'));
set(this, 'sourceKey', 'prefix');
if (secretKeys) { if (secretKeys) {
secretKeys.forEach((sk) => { secretKeys.forEach((sk) => {
@ -83,6 +83,8 @@ export default Component.extend({
}) })
} }
} }
set(this, 'sourceKey', 'prefix');
}
return out; return out;
}), }),

View File

@ -20,6 +20,7 @@
namespace=namespace namespace=namespace
value=secret.sourceName value=secret.sourceName
valueKey='name' valueKey='name'
selectedSecret=(action (mut selectedSecret))
}} }}
{{else}} {{else}}
{{#if secret}} {{#if secret}}

View File

@ -9,6 +9,7 @@ export default Component.extend({
intl: service(), intl: service(),
// Inputs // Inputs
value: null,
namespace: null, namespace: null,
selectClass: 'form-control', selectClass: 'form-control',
valueKey: 'name', // What to set the value as.. 'name' or 'id' valueKey: 'name', // What to set the value as.. 'name' or 'id'
@ -21,6 +22,10 @@ export default Component.extend({
projectSecrets: null, projectSecrets: null,
namespaceSecrets: null, namespaceSecrets: null,
findSecret() {
},
init() { init() {
this._super(...arguments); this._super(...arguments);
@ -89,9 +94,12 @@ export default Component.extend({
let str = null; let str = null;
if ( id ) { if ( id ) {
let secret = get(this,'store').getById('secret',id); let secret = get(this, 'projectSecrets').findBy('id', id) || get(this, 'namespaceSecrets').findBy('id', id);
if ( secret ) { if ( secret ) {
get(this, 'selectedSecret')(secret);
str = get(secret,get(this,'valueKey')); str = get(secret,get(this,'valueKey'));
} else {
get(this, 'selectedSecret')(null);
} }
} }

View File

@ -3,5 +3,5 @@
content=filtered content=filtered
prompt="schema.inputSecret.prompt" prompt="schema.inputSecret.prompt"
localizedPrompt=true localizedPrompt=true
value=seleted value=selected
}} }}