diff --git a/shell/edit/workload/mixins/workload.js b/shell/edit/workload/mixins/workload.js index e5b4ada41e..cc448238c7 100644 --- a/shell/edit/workload/mixins/workload.js +++ b/shell/edit/workload/mixins/workload.js @@ -148,7 +148,6 @@ export default { }, data() { - let defaultTab; let type = this.$route.params.resource; const createSidecar = !!this.$route.query.sidecar; const isInitContainer = !!this.$route.query.init; @@ -165,18 +164,12 @@ export default { name: `container-0`, }]; - defaultTab = 'container-0'; - const podSpec = { template: { spec: { containers: podContainers, initContainers: [] } } }; this.$set(this.value, 'spec', podSpec); } } - if (this.mode === _CREATE) { - defaultTab = 'container-0'; - } - if ((this.mode === _EDIT || this.mode === _VIEW ) && this.value.type === 'pod' ) { const podSpec = { ...this.value.spec }; @@ -214,7 +207,6 @@ export default { imagePullPolicy: 'Always', name: `container-${ allContainers.length }`, }); - defaultTab = 'container-0'; containers = podTemplateSpec.initContainers; } @@ -224,8 +216,6 @@ export default { name: `container-${ allContainers.length }`, }; - defaultTab = 'container-0'; - containers.push(container); } else { container = containers[0]; @@ -261,7 +251,6 @@ export default { path: 'image', rootObject: this.container, rules: ['required'], translationKey: 'workload.container.image' }], fvReportedValidationPaths: ['spec'], - defaultTab }; }, @@ -271,6 +260,14 @@ export default { return { general: this.fvGetPathErrors(['image'])?.length > 0 }; }, + defaultTab() { + if (!!this.$route.query.sidecar || this.$route.query.init || this.mode === _CREATE) { + return 'container-0'; + } + + return this.allContainers.length ? this.allContainers[0].name : ''; + }, + isEdit() { return this.mode === _EDIT; },