mirror of https://github.com/rancher/ui.git
fix broken azure cloud provider inputs
This commit is contained in:
parent
e227ba4e6e
commit
0abb2bdb4e
|
|
@ -9,6 +9,7 @@ import { isEmpty } from '@ember/utils';
|
|||
import C from 'ui/utils/constants';
|
||||
import { azure as AzureInfo } from './cloud-provider-info';
|
||||
import { next } from '@ember/runloop';
|
||||
import { debouncedObserver } from 'ui/utils/debounce';
|
||||
|
||||
const azureDefaults = C.AZURE_DEFAULTS;
|
||||
const GENERIC_PATH = 'cluster.rancherKubernetesEngineConfig.cloudProvider.cloudConfig';
|
||||
|
|
@ -81,29 +82,34 @@ export default Component.extend({
|
|||
}
|
||||
}),
|
||||
|
||||
configAnswersDidChange: observer('configAnswers', function() {
|
||||
const configAnswers = get(this, 'configAnswers');
|
||||
configAnswersDidChange: debouncedObserver('mappedConfigAnswers.@each.{key,value}', function() {
|
||||
const mappedAnswers = get(this, 'mappedConfigAnswers');
|
||||
const selectedCloudProvider = get(this, 'selectedCloudProvider');
|
||||
const configAnswersOut = {};
|
||||
let pathForSet;
|
||||
|
||||
switch (selectedCloudProvider) {
|
||||
case 'azure':
|
||||
|
||||
set(this, AZURE_PATH, configAnswers);
|
||||
pathForSet = AZURE_PATH;
|
||||
|
||||
break;
|
||||
|
||||
case 'amazonec2':
|
||||
|
||||
set(this, AWS_PATH, configAnswers);
|
||||
pathForSet = AWS_PATH;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
set(this, GENERIC_PATH, configAnswers);
|
||||
pathForSet = GENERIC_PATH;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
mappedAnswers.forEach((answer) => {
|
||||
set(configAnswersOut, answer.key, answer.value);
|
||||
});
|
||||
|
||||
set(this, pathForSet, configAnswersOut);
|
||||
}),
|
||||
|
||||
selectedCloudProviderOverrideAvailable: computed(
|
||||
|
|
@ -158,6 +164,20 @@ export default Component.extend({
|
|||
}
|
||||
}),
|
||||
|
||||
mappedConfigAnswers: computed('configAnswers', function() {
|
||||
const configAnswers = (get(this, 'configAnswers') || {});
|
||||
const out = [];
|
||||
|
||||
Object.keys(configAnswers).forEach((answerKey) => {
|
||||
out.push({
|
||||
key: answerKey,
|
||||
value: configAnswers[answerKey]
|
||||
});
|
||||
});
|
||||
|
||||
return out;
|
||||
}),
|
||||
|
||||
checkDefaults(record) {
|
||||
get(this, 'azureDefaults').forEach((def) => {
|
||||
if (isEmpty(record[def])) {
|
||||
|
|
|
|||
|
|
@ -146,20 +146,20 @@
|
|||
</div>
|
||||
|
||||
{{#if (eq selectedCloudProvider "azure")}}
|
||||
{{#each-in configAnswers as |key value|}}
|
||||
{{#each mappedConfigAnswers as |answer|}}
|
||||
<div class="row">
|
||||
<div class="col span-6">
|
||||
<label class="acc-label pb-0">{{key}}
|
||||
{{#if (get (get azureDescriptions key) "required")}}
|
||||
<label class="acc-label pb-0">{{answer.key}}
|
||||
{{#if (get (get azureDescriptions answer.key) "required")}}
|
||||
{{#if (eq mode "new")}}
|
||||
{{field-required}}
|
||||
{{else if (and (eq mode "edit") (or (not-eq key "aadClientSecret") clusterTemplateCreate))}}
|
||||
{{else if (and (eq mode "edit") (or (not-eq answer.key "aadClientSecret") clusterTemplateCreate))}}
|
||||
{{field-required}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if clusterTemplateCreate}}
|
||||
<ClusterTemplateOverrideToggle
|
||||
@path={{concat "rancherKubernetesEngineConfig.cloudProvider.azureCloudProvider." key}}
|
||||
@path={{concat "rancherKubernetesEngineConfig.cloudProvider.azureCloudProvider." answer.key}}
|
||||
@configVariable={{configVariable}}
|
||||
@addOverride={{addOverride}}
|
||||
@questions={{questions}}
|
||||
|
|
@ -167,33 +167,33 @@
|
|||
{{/if}}
|
||||
</label>
|
||||
<p class="help-block mt-0">
|
||||
{{t (get (get azureDescriptions key) "description") htmlSafe=true}}
|
||||
{{t (get (get azureDescriptions answer.key) "description") htmlSafe=true}}
|
||||
</p>
|
||||
</div>
|
||||
<div class="col span-6">
|
||||
<CheckOverrideAllowed
|
||||
@applyClusterTemplate={{applyClusterTemplate}}
|
||||
@clusterTemplateRevision={{clusterTemplateRevision.clusterConfig}}
|
||||
@paramName={{concat "rancherKubernetesEngineConfig.cloudProvider.azureCloudProvider." key}}
|
||||
@paramName={{concat "rancherKubernetesEngineConfig.cloudProvider.azureCloudProvider." answer.key}}
|
||||
@questions={{questions}}
|
||||
>
|
||||
{{#input-or-display
|
||||
editable=(not-eq mode "view")
|
||||
value=(get configAnswers key)
|
||||
obfuscate=(if (eq (get (get azureDescriptions key) "type") "password") true false)
|
||||
value=(get configAnswers answer.key)
|
||||
obfuscate=(if (eq (get (get azureDescriptions answer.key) "type") "password") true false)
|
||||
}}
|
||||
{{input
|
||||
class="form-control input-sm value"
|
||||
spellcheck="false"
|
||||
type=(or (get (get azureDescriptions key) "type") "text")
|
||||
value=(mut (get configAnswers key))
|
||||
type=(or (get (get azureDescriptions answer.key) "type") "text")
|
||||
value=answer.value
|
||||
placeholder=(t "generic.value")
|
||||
}}
|
||||
{{/input-or-display}}
|
||||
</CheckOverrideAllowed>
|
||||
</div>
|
||||
</div>
|
||||
{{/each-in}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
|
||||
{{#if (not-eq mode "view")}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue