fix(kubernetes): sync active kubeconfig to store's selectedClusterId
All checks were successful
PR Review Automation / review (pull_request) Successful in 3m31s
Test / frontend-tests (pull_request) Successful in 1m34s
Test / frontend-typecheck (pull_request) Successful in 1m37s
Test / rust-fmt-check (pull_request) Successful in 11m55s
Test / rust-clippy (pull_request) Successful in 12m56s
Test / rust-tests (pull_request) Successful in 13m59s
All checks were successful
PR Review Automation / review (pull_request) Successful in 3m31s
Test / frontend-tests (pull_request) Successful in 1m34s
Test / frontend-typecheck (pull_request) Successful in 1m37s
Test / rust-fmt-check (pull_request) Successful in 11m55s
Test / rust-clippy (pull_request) Successful in 12m56s
Test / rust-tests (pull_request) Successful in 13m59s
- Update handleActivateKubeconfig to call setSelectedCluster after activation - ResourceBrowser now loads resources for the activated kubeconfig's cluster - All tests passing, build successful
This commit is contained in:
parent
e928011839
commit
5b85480608
@ -15,7 +15,7 @@ import {
|
|||||||
} from "@/lib/tauriCommands";
|
} from "@/lib/tauriCommands";
|
||||||
|
|
||||||
export function KubernetesPage() {
|
export function KubernetesPage() {
|
||||||
const { selectedClusterId } = useKubernetesStore();
|
const { selectedClusterId, setSelectedCluster } = useKubernetesStore();
|
||||||
const [kubeconfigs, setKubeconfigs] = useState<KubeconfigInfo[]>([]);
|
const [kubeconfigs, setKubeconfigs] = useState<KubeconfigInfo[]>([]);
|
||||||
const [portForwards, setPortForwards] = useState<PortForwardResponse[]>([]);
|
const [portForwards, setPortForwards] = useState<PortForwardResponse[]>([]);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@ -44,7 +44,14 @@ export function KubernetesPage() {
|
|||||||
const handleActivateKubeconfig = async (id: string) => {
|
const handleActivateKubeconfig = async (id: string) => {
|
||||||
try {
|
try {
|
||||||
await activateKubeconfigCmd(id);
|
await activateKubeconfigCmd(id);
|
||||||
await loadData();
|
const [kubeconfigsData] = await Promise.all([listKubeconfigsCmd()]);
|
||||||
|
setKubeconfigs(kubeconfigsData);
|
||||||
|
|
||||||
|
// Select the active cluster from the activated kubeconfig
|
||||||
|
const activeConfig = kubeconfigsData.find((c) => c.is_active);
|
||||||
|
if (activeConfig) {
|
||||||
|
setSelectedCluster(activeConfig.id);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Failed to activate kubeconfig:", err);
|
console.error("Failed to activate kubeconfig:", err);
|
||||||
alert("Failed to activate kubeconfig");
|
alert("Failed to activate kubeconfig");
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import type { ClusterInfo, ContextInfo, ResourceInfo } from "@/lib/tauriCommands";
|
import type { ClusterInfo, ContextInfo, ResourceInfo, KubeconfigInfo } from "@/lib/tauriCommands";
|
||||||
|
|
||||||
export type ResourceType =
|
export type ResourceType =
|
||||||
| "pods"
|
| "pods"
|
||||||
@ -103,6 +103,13 @@ export const useKubernetesStore = create<KubernetesState>()((set, get) => ({
|
|||||||
// Actions
|
// Actions
|
||||||
setSelectedCluster: (clusterId) => set({ selectedClusterId: clusterId, selectedNamespace: "all" }),
|
setSelectedCluster: (clusterId) => set({ selectedClusterId: clusterId, selectedNamespace: "all" }),
|
||||||
|
|
||||||
|
selectClusterFromKubeconfig: (kubeconfigs: KubeconfigInfo[]) => {
|
||||||
|
const activeConfig = kubeconfigs.find((c) => c.is_active);
|
||||||
|
if (activeConfig) {
|
||||||
|
set({ selectedClusterId: activeConfig.id, selectedNamespace: "all" });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
setSelectedNamespace: (namespace) => set({ selectedNamespace: namespace }),
|
setSelectedNamespace: (namespace) => set({ selectedNamespace: namespace }),
|
||||||
|
|
||||||
addCluster: (cluster) => set((state) => ({
|
addCluster: (cluster) => set((state) => ({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user