Question fixes

This commit is contained in:
Vincent Fiduccia 2021-06-15 11:30:24 -07:00
parent 056c4127e3
commit 1cac475b40
No known key found for this signature in database
GPG Key ID: 2B29AD6BB2BB2582
4 changed files with 44 additions and 24 deletions

View File

@ -165,7 +165,7 @@ export default {
}, },
tabbed: { tabbed: {
type: Boolean, type: [Boolean, String],
default: true, default: true,
}, },
@ -193,7 +193,7 @@ export default {
computed: { computed: {
allQuestions() { allQuestions() {
if ( this.source.questions?.questions ) { if ( this.source.questions?.questions ) {
return this.chartVersion.questions.questions; return this.source.questions.questions;
} else if ( this.source.type === 'schema' && this.source.resourceFields ) { } else if ( this.source.type === 'schema' && this.source.resourceFields ) {
return schemaToQuestions(this.source.resourceFields); return schemaToQuestions(this.source.resourceFields);
} else if ( typeof this.source === 'object' ) { } else if ( typeof this.source === 'object' ) {
@ -266,6 +266,18 @@ export default {
return sortBy(out, 'weight:desc'); return sortBy(out, 'weight:desc');
}, },
asTabs() {
if ( this.tabbed === false || this.tabbed === 'never' ) {
return false;
}
if ( this.tabbed === 'multiple' ) {
return this.groups.length > 1;
}
return true;
},
}, },
watch: { watch: {
@ -287,7 +299,7 @@ export default {
</script> </script>
<template> <template>
<div v-if="tabbed"> <form v-if="asTabs">
<Tab <Tab
v-for="g in groups" v-for="g in groups"
:key="g.name" :key="g.name"
@ -307,8 +319,8 @@ export default {
</div> </div>
</div> </div>
</Tab> </Tab>
</div> </form>
<div v-else> <form v-else>
<div <div
v-for="g in groups" v-for="g in groups"
:key="g.name" :key="g.name"
@ -329,7 +341,7 @@ export default {
</div> </div>
</div> </div>
</div> </div>
</div> </form>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -197,7 +197,7 @@ export default {
</script> </script>
<template> <template>
<div :class="{'side-tabs':!!sideTabs}"> <div :class="{'side-tabs': (!!sideTabs && tabs.length)}">
<ul <ul
ref="tablist" ref="tablist"
role="tablist" role="tablist"
@ -236,7 +236,7 @@ export default {
</li> </li>
</ul> </ul>
</ul> </ul>
<div class="tab-container"> <div :class="{ 'tab-container': !!tabs.length }">
<slot /> <slot />
</div> </div>
</div> </div>

View File

@ -1,6 +1,5 @@
<script> <script>
import difference from 'lodash/difference'; import difference from 'lodash/difference';
import differenceBy from 'lodash/differenceBy';
import throttle from 'lodash/throttle'; import throttle from 'lodash/throttle';
import isArray from 'lodash/isArray'; import isArray from 'lodash/isArray';
import merge from 'lodash/merge'; import merge from 'lodash/merge';
@ -154,10 +153,6 @@ export default {
} }
} }
if ( !this.versionInfo ) {
this.versionInfo = {};
}
for ( const v of this.addonVersions ) { for ( const v of this.addonVersions ) {
if ( this.versionInfo[v.name] ) { if ( this.versionInfo[v.name] ) {
continue; continue;
@ -222,8 +217,8 @@ export default {
rke2Versions: null, rke2Versions: null,
k3sVersions: null, k3sVersions: null,
s3Backup: false, s3Backup: false,
chartValues: clone(this.value.spec.rkeConfig.chartValues),
chartVersionInfo: null, chartVersionInfo: null,
versionInfo: {},
}; };
}, },
@ -234,6 +229,10 @@ export default {
return this.value.spec.rkeConfig; return this.value.spec.rkeConfig;
}, },
chartValues() {
return this.value.spec.rkeConfig.chartValues;
},
serverConfig() { serverConfig() {
return this.value.spec.rkeConfig.controlPlaneConfig; return this.value.spec.rkeConfig.controlPlaneConfig;
}, },
@ -345,7 +344,7 @@ export default {
disableOptions() { disableOptions() {
return this.serverArgs.disable.options.map((value) => { return this.serverArgs.disable.options.map((value) => {
return { return {
label: this.$store.getters['i18n/withFallback'](`cluster.rke2.systemService."${ value }"`, null, value.replace(/^rke2-/, '')), label: this.$store.getters['i18n/withFallback'](`cluster.rke2.systemService."${ value }"`, null, value.replace(/^(rke2|rancher)-/, '')),
value, value,
}; };
}); });
@ -509,21 +508,27 @@ export default {
return !!this.serverArgs.cni; return !!this.serverArgs.cni;
}, },
addonVersions() { addonNames() {
const names = []; const names = [];
const cni = this.serverConfig.cni; const cni = this.serverConfig.cni;
if ( cni ) { if ( cni ) {
const parts = cni.split('+'); const parts = cni.split('+').map(x => `rke2-${ x }`);
names.push(...parts); names.push(...parts);
} }
if ( this.agentConfig['cloud-provider-name'] === 'vsphere' ) { if ( this.agentConfig['cloud-provider-name'] === 'vsphere' ) {
names.push('vsphere-cpi', 'vpshere-csi'); names.push('rancher-vsphere-cpi', 'rancher-vsphere-csi');
} }
return names.map(name => this.chartVersionFor(name)).filter(x => !!x); return names;
},
addonVersions() {
const versions = this.addonNames.map(name => this.chartVersionFor(name));
return versions.filter(x => !!x);
}, },
}, },
@ -540,8 +545,10 @@ export default {
} }
}, },
addonVersions(neu, old) { addonNames(neu, old) {
if (!this.$fetchState.pending && differenceBy(neu, old, 'name').length ) { const diff = difference(neu, old);
if (!this.$fetchState.pending && diff.length ) {
this.$fetch(); this.$fetch();
} }
}, },
@ -723,8 +730,7 @@ export default {
}); });
}, },
chartVersionFor(feature) { chartVersionFor(chartName) {
const chartName = `rke2-${ feature }`;
const entry = this.chartVersions[chartName]; const entry = this.chartVersions[chartName];
if ( !entry ) { if ( !entry ) {
@ -733,7 +739,7 @@ export default {
const out = this.$store.getters['catalog/version']({ const out = this.$store.getters['catalog/version']({
repoType: 'cluster', repoType: 'cluster',
repoName: (feature === 'multus' ? 'rancher-rke2-charts' : entry.repo), // @TODO remove when KDM is fixed repoName: entry.repo,
chartName, chartName,
versionName: entry.version, versionName: entry.version,
}); });
@ -1157,6 +1163,7 @@ export default {
v-if="versionInfo[v.name].questions" v-if="versionInfo[v.name].questions"
v-model="chartValues[v.name]" v-model="chartValues[v.name]"
:mode="mode" :mode="mode"
:tabbed="false"
:source="versionInfo[v.name]" :source="versionInfo[v.name]"
:target-namespace="value.metadata.namespace" :target-namespace="value.metadata.namespace"
/> />

View File

@ -1113,6 +1113,7 @@ export default {
v-model="chartValues" v-model="chartValues"
:mode="mode" :mode="mode"
:source="versionInfo" :source="versionInfo"
tabbed="multiple"
:target-namespace="targetNamespace" :target-namespace="targetNamespace"
/> />
</Tabbed> </Tabbed>