From bb7c59c1f3ad7933bc8bbb96e313b85ccb9f9514 Mon Sep 17 00:00:00 2001 From: testA113 Date: Tue, 1 Oct 2024 15:47:00 +1300 Subject: [PATCH] fix(applications): update ns options for non admin users [r8s-99] --- .../create/createApplicationController.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/kubernetes/views/applications/create/createApplicationController.js b/app/kubernetes/views/applications/create/createApplicationController.js index 5d5994dc5..bd6f2d05e 100644 --- a/app/kubernetes/views/applications/create/createApplicationController.js +++ b/app/kubernetes/views/applications/create/createApplicationController.js @@ -29,6 +29,7 @@ import { confirm, confirmUpdate, confirmWebEditorDiscard } from '@@/modals/confi import { buildConfirmButton } from '@@/modals/utils'; import { ModalType } from '@@/modals'; import { KUBE_STACK_NAME_VALIDATION_REGEX } from '@/react/kubernetes/DeployView/StackName/constants'; +import { getNamespaces } from '@/react/kubernetes/namespaces/queries/useNamespacesQuery'; class KubernetesCreateApplicationController { /* #region CONSTRUCTOR */ @@ -1022,16 +1023,14 @@ class KubernetesCreateApplicationController { this.deploymentOptions = await getGlobalDeploymentOptions(); - const [resourcePools, nodes, nodesLimits] = await Promise.all([ - this.KubernetesResourcePoolService.get(), - this.KubernetesNodeService.get(), - this.KubernetesNodesLimitsService.get(), - ]); + const [namespaces, nodes, nodesLimits] = await Promise.all([getNamespaces(this.endpoint.Id), this.KubernetesNodeService.get(), this.KubernetesNodesLimitsService.get()]); this.nodesLimits = nodesLimits; + // transform the namespaces to resource pools to conform to legacy code ( this.KubernetesResourcePoolService.get() ) + const resourcePools = namespaces.map((namespace) => ({ Namespace: namespace })); const nonSystemNamespaces = _.filter( resourcePools, - (resourcePool) => !KubernetesNamespaceHelper.isSystemNamespace(resourcePool.Namespace.Name) && resourcePool.Namespace.Status === 'Active' + (resourcePool) => !KubernetesNamespaceHelper.isSystemNamespace(resourcePool.Name) && resourcePool.Namespace.Status.phase === 'Active' ); this.allNamespaces = resourcePools.map(({ Namespace }) => Namespace.Name);