From 1fd42916308aa0f1b1957a2afa856dd750d61f1a Mon Sep 17 00:00:00 2001 From: Prabhat Khera <91852476+prabhat-org@users.noreply.github.com> Date: Mon, 12 Feb 2024 10:54:24 +1300 Subject: [PATCH] fix(ui): stackname auto fill on create from manifest screen [EE-6688] (#11100) * fix(ui): stackname auto fill on create from manifest screen [EE-6688] * address review comment --- app/kubernetes/views/deploy/deploy.html | 2 ++ app/kubernetes/views/deploy/deployController.js | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/kubernetes/views/deploy/deploy.html b/app/kubernetes/views/deploy/deploy.html index 076930a7f..7a9a6ec7d 100644 --- a/app/kubernetes/views/deploy/deploy.html +++ b/app/kubernetes/views/deploy/deploy.html @@ -47,6 +47,7 @@ ng-disabled="ctrl.formValues.namespace_toggle && ctrl.state.BuildMethod !== ctrl.BuildMethods.HELM" class="form-control" ng-model="ctrl.formValues.Namespace" + ng-change="ctrl.onChangeNamespace()" ng-options="namespace.Name as namespace.Name for namespace in ctrl.namespaces" > diff --git a/app/kubernetes/views/deploy/deployController.js b/app/kubernetes/views/deploy/deployController.js index d6eb84474..fb792b709 100644 --- a/app/kubernetes/views/deploy/deployController.js +++ b/app/kubernetes/views/deploy/deployController.js @@ -15,7 +15,7 @@ import { getVariablesFieldDefaultValues } from '@/react/portainer/custom-templat class KubernetesDeployController { /* @ngInject */ - constructor($async, $state, $window, Authentication, Notifications, KubernetesResourcePoolService, StackService, CustomTemplateService) { + constructor($async, $state, $window, Authentication, Notifications, KubernetesResourcePoolService, StackService, CustomTemplateService, KubernetesApplicationService) { this.$async = $async; this.$state = $state; this.$window = $window; @@ -24,6 +24,7 @@ class KubernetesDeployController { this.KubernetesResourcePoolService = KubernetesResourcePoolService; this.StackService = StackService; this.CustomTemplateService = CustomTemplateService; + this.KubernetesApplicationService = KubernetesApplicationService; this.isTemplateVariablesEnabled = isTemplateVariablesEnabled; @@ -78,6 +79,8 @@ class KubernetesDeployController { Name: '', }; + this.stacks = []; + this.ManifestDeployTypes = KubernetesDeployManifestTypes; this.BuildMethods = KubernetesDeployBuildMethods; @@ -92,6 +95,15 @@ class KubernetesDeployController { this.onChangeDeployType = this.onChangeDeployType.bind(this); this.onChangeTemplateVariables = this.onChangeTemplateVariables.bind(this); this.setStackName = this.setStackName.bind(this); + this.onChangeNamespace = this.onChangeNamespace.bind(this); + } + + onChangeNamespace() { + return this.$async(async () => { + const applications = await this.KubernetesApplicationService.get(this.formValues.Namespace); + const stacks = _.map(applications, (item) => item.StackName).filter((item) => item !== ''); + this.stacks = _.uniq(stacks); + }); } onSelectHelmChart(chart) { @@ -377,6 +389,7 @@ class KubernetesDeployController { } } + this.onChangeNamespace(); this.state.viewReady = true; this.$window.onbeforeunload = () => {