From 84e57cebc9899d827c31ba46c5833a8a8ec7f53a Mon Sep 17 00:00:00 2001 From: Richard Wei <54336863+WaysonWei@users.noreply.github.com> Date: Thu, 7 Oct 2021 11:06:53 +1300 Subject: [PATCH] fix set namespace to default-namespace (#5820) --- .../helm/helm-templates/helm-templates.controller.js | 5 +++-- .../views/applications/create/createApplicationController.js | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/kubernetes/components/helm/helm-templates/helm-templates.controller.js b/app/kubernetes/components/helm/helm-templates/helm-templates.controller.js index 4a7f3de3d..bbd1c6504 100644 --- a/app/kubernetes/components/helm/helm-templates/helm-templates.controller.js +++ b/app/kubernetes/components/helm/helm-templates/helm-templates.controller.js @@ -1,4 +1,5 @@ import KubernetesNamespaceHelper from 'Kubernetes/helpers/namespaceHelper'; +import _ from 'lodash-es'; export default class HelmTemplatesController { /* @ngInject */ @@ -141,8 +142,8 @@ export default class HelmTemplatesController { const resourcePools = await this.KubernetesResourcePoolService.get(); const nonSystemNamespaces = resourcePools.filter((resourcePool) => !KubernetesNamespaceHelper.isSystemNamespace(resourcePool.Namespace.Name)); - this.state.resourcePools = nonSystemNamespaces; - this.state.resourcePool = nonSystemNamespaces[0]; + this.state.resourcePools = _.sortBy(nonSystemNamespaces, ({ Namespace }) => (Namespace.Name === 'default' ? 0 : 1)); + this.state.resourcePool = this.state.resourcePools[0]; } catch (err) { this.Notifications.error('Failure', err, 'Unable to retrieve initial helm data.'); } finally { diff --git a/app/kubernetes/views/applications/create/createApplicationController.js b/app/kubernetes/views/applications/create/createApplicationController.js index 24578a374..671b17abc 100644 --- a/app/kubernetes/views/applications/create/createApplicationController.js +++ b/app/kubernetes/views/applications/create/createApplicationController.js @@ -1074,7 +1074,10 @@ class KubernetesCreateApplicationController { ]); this.nodesLimits = nodesLimits; - this.resourcePools = _.filter(resourcePools, (resourcePool) => !KubernetesNamespaceHelper.isSystemNamespace(resourcePool.Namespace.Name)); + const nonSystemNamespaces = _.filter(resourcePools, (resourcePool) => !KubernetesNamespaceHelper.isSystemNamespace(resourcePool.Namespace.Name)); + + this.resourcePools = _.sortBy(nonSystemNamespaces, ({ Namespace }) => (Namespace.Name === 'default' ? 0 : 1)); + this.formValues.ResourcePool = this.resourcePools[0]; if (!this.formValues.ResourcePool) { return;