@@ -23,7 +23,8 @@ import {
2323 getClusters ,
2424 getInstalledHelmDetails ,
2525 inferClusterRepoForChart ,
26- listClusterRepos
26+ listClusterRepos ,
27+ listNamespaces
2728} from ' ../../services/rancher-apps' ;
2829import { getRepoAuthForClusterRepo } from ' ../../services/repo-auth' ;
2930import { persistLoad , persistSave , persistClear } from ' ../../services/ui-persist' ;
@@ -67,6 +68,7 @@ const versionInfo = ref<any | null>(null);
6768const questionsLoading = ref (false );
6869const versionInfoKey = ref (' ' );
6970const defaultValuesSnapshot = ref <Record <string , any >>({});
71+ const namespaceOptions = ref <{label: string , value: string }[]>([]);
7072
7173// Multi-cluster install progress state
7274const showProgressModal = ref (false );
@@ -93,6 +95,52 @@ const versionOptions = computed(() =>
9395 (versions .value || []).map (v => ({ label: v , value: v }))
9496);
9597
98+ // Fetch all namespaces from all clusters and filter out system namespaces
99+ async function fetchAllNamespaces() {
100+ if (! store ) {
101+ return ;
102+ }
103+
104+ try {
105+ const clusters = await getClusters (store );
106+ console .log (' [SUSE-AI] All available clusters:' , clusters );
107+
108+ const allNamespaces = new Set <string >();
109+
110+ await Promise .all (clusters .map (async (cluster ) => {
111+ console .log (' [SUSE-AI] Trying to get namespaces for cluster:' , cluster );
112+ try {
113+ const namespaces = await listNamespaces (store , cluster .id );
114+ namespaces .forEach (ns => allNamespaces .add (ns ));
115+ } catch (e ) {
116+ console .warn (` [SUSE-AI] Failed to fetch namespaces for cluster ${cluster .id }: ` , e );
117+ }
118+ }));
119+
120+ console .log (' [SUSE-AI] Found all unique namespaces:' , allNamespaces );
121+
122+ const systemPrefixes = [' c-' , ' p-' , ' kube-' , ' cattle-' , ' rancher' , ' longhorn-' , ' fleet-' , ' cluster-fleet-' , ' system-' , ' istio-' , ' neuvector' , ' ingress-' , ' cert-manager' ];
123+ const userNamespaces = Array .from (allNamespaces ).filter (name =>
124+ ! systemPrefixes .some (prefix => name .startsWith (prefix ))
125+ );
126+
127+ const desiredDefault = ` ${props .slug }-system ` ;
128+ if (! userNamespaces .includes (desiredDefault )) {
129+ userNamespaces .push (desiredDefault );
130+ }
131+
132+ const sortedNamespaces = userNamespaces .sort ();
133+ namespaceOptions .value = sortedNamespaces .map (ns => ({ label: ns , value: ns }));
134+
135+ if (isInstallMode .value ) {
136+ form .value .namespace = desiredDefault ;
137+ }
138+
139+ } catch (e ) {
140+ console .warn (` [SUSE-AI] Failed to fetch all namespaces: ` , e );
141+ }
142+ }
143+
96144// Wizard step configuration for Rancher Wizard component
97145const wizardSteps = computed (() => [
98146 {
@@ -184,6 +232,7 @@ const basicInfoForm = computed({
184232onMounted (async () => {
185233 try {
186234 await initializeWizard ();
235+ await fetchAllNamespaces ();
187236 } catch (e ) {
188237 error .value = ` Failed to initialize: ${e .message || ' Unknown error' } ` ;
189238 } finally {
@@ -969,6 +1018,7 @@ function previousStep() {
9691018 v-model:form =" basicInfoForm"
9701019 :version-options =" versionOptions"
9711020 :loading-versions =" loadingVersions"
1021+ :namespace-options =" namespaceOptions"
9721022 />
9731023
9741024 <!-- Step: Target Cluster -->
0 commit comments