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;
|
||||
}
|
||||
|
||||
if ( get(this, 'actuallySave') && get(this, 'selectedTemplateModel.questions')) {
|
||||
primaryResource.set('answers', this.buildAnswerMap())
|
||||
if ( get(this, 'actuallySave') ) {
|
||||
if ( get(this, 'selectedTemplateModel.questions') ) {
|
||||
primaryResource.set('answers', this.buildAnswerMap())
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -245,7 +245,10 @@
|
|||
showHeader=false
|
||||
}}
|
||||
{{else}}
|
||||
{{input-custom-answers app=primaryResource}}
|
||||
{{input-custom-answers
|
||||
app=multiClusterApp
|
||||
isMultiClusterApp=true
|
||||
}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -66,9 +66,16 @@ export default Route.extend({
|
|||
neuApp = results.app;
|
||||
}
|
||||
} else {
|
||||
let defaultAnswwer = store.createRecord({
|
||||
clusterId: null,
|
||||
projectId: null,
|
||||
type: 'answer',
|
||||
values: []
|
||||
});
|
||||
|
||||
neuApp = store.createRecord({
|
||||
type: 'multiclusterapp',
|
||||
answers: [],
|
||||
answers: [defaultAnswwer],
|
||||
catalogId: results.tpl.catalogId,
|
||||
targets: [],
|
||||
members: [],
|
||||
|
|
|
|||
|
|
@ -29,20 +29,18 @@ export default Component.extend({
|
|||
growl: service(),
|
||||
|
||||
layout,
|
||||
pasteOrUpload: false,
|
||||
showInput: true,
|
||||
accept: '.yml, .yaml',
|
||||
app: null,
|
||||
pasteOrUpload: false,
|
||||
showInput: true,
|
||||
accept: '.yml, .yaml',
|
||||
app: null,
|
||||
isMultiClusterApp: false,
|
||||
intialAnswerMap: null,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
|
||||
if (!dotObject) {
|
||||
import('dot-object').then( (module) => {
|
||||
dotObject = module.default;
|
||||
});
|
||||
}
|
||||
this.initLazyModules();
|
||||
this.initInitialAnswerMap();
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
|
@ -56,7 +54,17 @@ export default Component.extend({
|
|||
|
||||
cancel() {
|
||||
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() {
|
||||
|
|
@ -156,4 +164,33 @@ export default Component.extend({
|
|||
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">
|
||||
{{#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}}
|
||||
<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}}
|
||||
<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 class="mt-25">
|
||||
{{#if pasteOrUpload}}
|
||||
<div class="clearfix">
|
||||
<label class="acc-label">{{t 'inputAnswers.yamlConfig'}}</label>
|
||||
<label class="acc-label">
|
||||
{{t "inputAnswers.yamlConfig"}}
|
||||
</label>
|
||||
</div>
|
||||
<div class="p-20">
|
||||
{{input-yaml
|
||||
|
|
@ -24,12 +43,12 @@
|
|||
{{top-errors errors=yamlErrors}}
|
||||
{{else if showInput}}
|
||||
{{form-key-value
|
||||
initialMap=app.answers
|
||||
changed=(action (mut app.answers))
|
||||
initialMap=intialAnswerMap
|
||||
changed="updateAnswers"
|
||||
allowEmptyValue=true
|
||||
addInitialEmptyRow=true
|
||||
editing=true
|
||||
header=(t 'newCatalog.answers.label')
|
||||
header=(t "newCatalog.answers.label")
|
||||
addActionLabel="newCatalog.answers.addAction"
|
||||
keyLabel="newContainer.environment.keyLabel"
|
||||
keyPlaceholder="newContainer.environment.keyPlaceholder"
|
||||
|
|
|
|||
Loading…
Reference in New Issue