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,23 +65,25 @@ export default Component.extend({
return out;
},
}),
selectedSecret: null,
prefixOrKeys: computed('allSecrets.[]', 'secret.sourceName', function() {
let prefix = { id: 'prefix', label: 'All'};
let selectedSecret = get(this, 'secret.sourceName');
let secretSourceName = get(this, 'secret.sourceName');
let out = [prefix];
let secret = get(this, 'selectedSecret');
if (selectedSecret) {
let secret = get(this, 'secrets').findBy('name', selectedSecret);
let secretKeys = Object.keys(get(secret, 'data'));
if (secretSourceName) {
if (get(secret, 'data')) {
let secretKeys = Object.keys(get(secret, 'data'));
set(this, 'sourceKey', 'prefix');
if (secretKeys) {
secretKeys.forEach((sk) => {
out.addObject({id: sk, label: sk});
})
if (secretKeys) {
secretKeys.forEach((sk) => {
out.addObject({id: sk, label: sk});
})
}
}
set(this, 'sourceKey', 'prefix');
}
return out;

View File

@ -17,9 +17,10 @@
<td data-title="{{t 'formSecrets.kind.label'}}">
{{#if editing}}
{{schema/input-secret
namespace=namespace
value=secret.sourceName
valueKey='name'
namespace=namespace
value=secret.sourceName
valueKey='name'
selectedSecret=(action (mut selectedSecret))
}}
{{else}}
{{#if secret}}
@ -59,4 +60,4 @@
<i class="icon icon-minus"/><span class="sr-only">{{t 'generic.remove'}}</span>
</button>
{{/if}}
</td>
</td>

View File

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

View File

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