mirror of https://github.com/rancher/ui.git
Fix initial answers not loading for helm charts without questions
This commit is contained in:
parent
0b176aa116
commit
281df1ea1b
|
|
@ -584,8 +584,10 @@ export default Component.extend(NewOrEdit, CatalogApp, {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( get(this, 'actuallySave') && get(this, 'selectedTemplateModel.questions')) {
|
if ( get(this, 'actuallySave') ) {
|
||||||
|
if ( get(this, 'selectedTemplateModel.questions') ) {
|
||||||
primaryResource.set('answers', this.buildAnswerMap())
|
primaryResource.set('answers', this.buildAnswerMap())
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,10 @@
|
||||||
showHeader=false
|
showHeader=false
|
||||||
}}
|
}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{input-custom-answers app=primaryResource}}
|
{{input-custom-answers
|
||||||
|
app=multiClusterApp
|
||||||
|
isMultiClusterApp=true
|
||||||
|
}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
|
|
@ -66,9 +66,16 @@ export default Route.extend({
|
||||||
neuApp = results.app;
|
neuApp = results.app;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
let defaultAnswwer = store.createRecord({
|
||||||
|
clusterId: null,
|
||||||
|
projectId: null,
|
||||||
|
type: 'answer',
|
||||||
|
values: []
|
||||||
|
});
|
||||||
|
|
||||||
neuApp = store.createRecord({
|
neuApp = store.createRecord({
|
||||||
type: 'multiclusterapp',
|
type: 'multiclusterapp',
|
||||||
answers: [],
|
answers: [defaultAnswwer],
|
||||||
catalogId: results.tpl.catalogId,
|
catalogId: results.tpl.catalogId,
|
||||||
targets: [],
|
targets: [],
|
||||||
members: [],
|
members: [],
|
||||||
|
|
|
||||||
|
|
@ -33,16 +33,14 @@ export default Component.extend({
|
||||||
showInput: true,
|
showInput: true,
|
||||||
accept: '.yml, .yaml',
|
accept: '.yml, .yaml',
|
||||||
app: null,
|
app: null,
|
||||||
|
isMultiClusterApp: false,
|
||||||
|
intialAnswerMap: null,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
|
this.initLazyModules();
|
||||||
if (!dotObject) {
|
this.initInitialAnswerMap();
|
||||||
import('dot-object').then( (module) => {
|
|
||||||
dotObject = module.default;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
@ -56,8 +54,18 @@ export default Component.extend({
|
||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
set(this, 'pasteOrUpload', false);
|
set(this, 'pasteOrUpload', false);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateAnswers(answers) {
|
||||||
|
const { isMultiClusterApp } = this;
|
||||||
|
|
||||||
|
if (isMultiClusterApp) {
|
||||||
|
set(this, 'app.answers.firstObject.values', answers);
|
||||||
|
} else {
|
||||||
|
set(this, 'app.answers', answers);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
actualAccept: computed('accept', function() {
|
actualAccept: computed('accept', function() {
|
||||||
if ( isSafari ) {
|
if ( isSafari ) {
|
||||||
|
|
@ -156,4 +164,33 @@ export default Component.extend({
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initInitialAnswerMap() {
|
||||||
|
const { isMultiClusterApp } = this;
|
||||||
|
let answers;
|
||||||
|
|
||||||
|
if (isMultiClusterApp) {
|
||||||
|
answers = this.getInitialMultiClusterAnswerMap();
|
||||||
|
} else {
|
||||||
|
answers = this.getInitialMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
set(this, 'intialAnswerMap', answers);
|
||||||
|
},
|
||||||
|
|
||||||
|
getInitialMultiClusterAnswerMap() {
|
||||||
|
return get(this, 'app.answers.firstObject.values');
|
||||||
|
},
|
||||||
|
|
||||||
|
getInitialMap() {
|
||||||
|
return get(this, 'app.answers');
|
||||||
|
},
|
||||||
|
|
||||||
|
initLazyModules() {
|
||||||
|
if (!dotObject) {
|
||||||
|
import('dot-object').then( (module) => {
|
||||||
|
dotObject = module.default;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,34 @@
|
||||||
<div class="btn-group pull-right">
|
<div class="btn-group pull-right">
|
||||||
{{#if pasteOrUpload}}
|
{{#if pasteOrUpload}}
|
||||||
<button class="btn btn-sm" {{action 'cancel'}}>{{t 'inputAnswers.editAsForm'}}</button>
|
<button
|
||||||
|
class="btn btn-sm"
|
||||||
|
{{action "cancel"}}
|
||||||
|
>
|
||||||
|
{{t "inputAnswers.editAsForm"}}
|
||||||
|
</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
<button class="btn btn-sm bg-primary" {{action 'showPaste'}}>{{t 'inputAnswers.yaml'}} <span class="icon icon-copy"></span></button>
|
<button
|
||||||
|
class="btn btn-sm bg-primary"
|
||||||
|
{{action "showPaste"}}
|
||||||
|
>
|
||||||
|
{{t "inputAnswers.yaml"}}
|
||||||
|
<i class="icon icon-copy"></i>
|
||||||
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<button class="btn btn-sm bg-primary" {{action 'upload'}}>{{t 'uploadFile.label'}} <span class="icon icon-upload"></span></button>
|
<button
|
||||||
|
class="btn btn-sm bg-primary"
|
||||||
|
{{action "upload"}}
|
||||||
|
>
|
||||||
|
{{t "uploadFile.label"}}
|
||||||
|
<i class="icon icon-upload"></i>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-25">
|
<div class="mt-25">
|
||||||
{{#if pasteOrUpload}}
|
{{#if pasteOrUpload}}
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<label class="acc-label">{{t 'inputAnswers.yamlConfig'}}</label>
|
<label class="acc-label">
|
||||||
|
{{t "inputAnswers.yamlConfig"}}
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="p-20">
|
<div class="p-20">
|
||||||
{{input-yaml
|
{{input-yaml
|
||||||
|
|
@ -24,12 +43,12 @@
|
||||||
{{top-errors errors=yamlErrors}}
|
{{top-errors errors=yamlErrors}}
|
||||||
{{else if showInput}}
|
{{else if showInput}}
|
||||||
{{form-key-value
|
{{form-key-value
|
||||||
initialMap=app.answers
|
initialMap=intialAnswerMap
|
||||||
changed=(action (mut app.answers))
|
changed="updateAnswers"
|
||||||
allowEmptyValue=true
|
allowEmptyValue=true
|
||||||
addInitialEmptyRow=true
|
addInitialEmptyRow=true
|
||||||
editing=true
|
editing=true
|
||||||
header=(t 'newCatalog.answers.label')
|
header=(t "newCatalog.answers.label")
|
||||||
addActionLabel="newCatalog.answers.addAction"
|
addActionLabel="newCatalog.answers.addAction"
|
||||||
keyLabel="newContainer.environment.keyLabel"
|
keyLabel="newContainer.environment.keyLabel"
|
||||||
keyPlaceholder="newContainer.environment.keyPlaceholder"
|
keyPlaceholder="newContainer.environment.keyPlaceholder"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue