From 1386e9bbbd507cd6e333161a84e6d26d1c5e1a68 Mon Sep 17 00:00:00 2001 From: Star Richardson <67430892+alicenstar@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:25:05 -0600 Subject: [PATCH] uncomment real queries --- .../apps/HelmVMClusterManagement.jsx | 77 ++++++++----------- web/src/components/apps/HelmVMViewNode.jsx | 72 ++++++++--------- 2 files changed, 70 insertions(+), 79 deletions(-) diff --git a/web/src/components/apps/HelmVMClusterManagement.jsx b/web/src/components/apps/HelmVMClusterManagement.jsx index 189560449d..4e2ede85d0 100644 --- a/web/src/components/apps/HelmVMClusterManagement.jsx +++ b/web/src/components/apps/HelmVMClusterManagement.jsx @@ -113,45 +113,42 @@ const HelmVMClusterManagement = ({ fromLicenseFlow = false }) => { const navigate = useNavigate(); - const nodes = testData; - const nodesLoading = false; - // #region queries - // const { data: nodes, isLoading: nodesLoading } = useQuery({ - // queryKey: "helmVmNodes", - // queryFn: async () => { - // return ( - // await fetch(`${process.env.API_ENDPOINT}/helmvm/nodes`, { - // headers: { - // Accept: "application/json", - // }, - // credentials: "include", - // method: "GET", - // }) - // ).json(); - // }, - // onError: (err) => { - // if (err.status === 401) { - // Utilities.logoutUser(); - // return; - // } - // console.log( - // "failed to get node status list, unexpected status code", - // err.status - // ); - // }, - // onSuccess: (data) => { - // setState({ - // // if cluster doesn't support ha, then primary will be disabled. Force into secondary - // selectedNodeType: !data.ha ? "secondary" : state.selectedNodeType, - // }); - // }, - // config: { - // refetchInterval: 1000, - // retry: false, - // }, - // }); + const { data: nodes, isLoading: nodesLoading } = useQuery({ + queryKey: "helmVmNodes", + queryFn: async () => { + return ( + await fetch(`${process.env.API_ENDPOINT}/helmvm/nodes`, { + headers: { + Accept: "application/json", + }, + credentials: "include", + method: "GET", + }) + ).json(); + }, + onError: (err) => { + if (err.status === 401) { + Utilities.logoutUser(); + return; + } + console.log( + "failed to get node status list, unexpected status code", + err.status + ); + }, + onSuccess: (data) => { + setState({ + // if cluster doesn't support ha, then primary will be disabled. Force into secondary + selectedNodeType: !data.ha ? "secondary" : state.selectedNodeType, + }); + }, + config: { + refetchInterval: 1000, + retry: false, + }, + }); const { data: generateSecondaryAddNodeCommand, @@ -216,12 +213,6 @@ const HelmVMClusterManagement = ({ fromLicenseFlow = false }) => { }) ).json(); }, - onSuccess: () => { - // if (fromLicenseFlow && data.isConfigurable) { - // navigate(`/${data.slug}/config`, { replace: true }); - // return; - // } - }, }); // #endregion diff --git a/web/src/components/apps/HelmVMViewNode.jsx b/web/src/components/apps/HelmVMViewNode.jsx index 7992ca57be..e22874c3ca 100644 --- a/web/src/components/apps/HelmVMViewNode.jsx +++ b/web/src/components/apps/HelmVMViewNode.jsx @@ -271,43 +271,43 @@ const testData = { }; const HelmVMViewNode = () => { - // const { nodeName } = useParams(); - // const { data: node } = useQuery({ - // queryKey: ["helmVmNode", nodeName], - // queryFn: async ({ queryKey }) => { - // const [, nodeName] = queryKey; - // return ( - // await fetch(`${process.env.API_ENDPOINT}/helmvm/node/${nodeName}`, { - // headers: { - // Accept: "application/json", - // }, - // credentials: "include", - // method: "GET", - // }) - // ).json(); - // }, - // onError: (err) => { - // if (err.status === 401) { - // Utilities.logoutUser(); - // return; - // } - // console.log( - // "failed to get node status list, unexpected status code", - // err.status - // ); - // }, - // onSuccess: (data) => { - // setState({ - // // if cluster doesn't support ha, then primary will be disabled. Force into secondary - // selectedNodeType: !data.ha ? "secondary" : state.selectedNodeType, - // }); - // }, - // config: { - // retry: false, - // }, - // }); + const { nodeName } = useParams(); + const { data: nodeData } = useQuery({ + queryKey: ["helmVmNode", nodeName], + queryFn: async ({ queryKey }) => { + const [, nodeName] = queryKey; + return ( + await fetch(`${process.env.API_ENDPOINT}/helmvm/node/${nodeName}`, { + headers: { + Accept: "application/json", + }, + credentials: "include", + method: "GET", + }) + ).json(); + }, + onError: (err) => { + if (err.status === 401) { + Utilities.logoutUser(); + return; + } + console.log( + "failed to get node status list, unexpected status code", + err.status + ); + }, + onSuccess: (data) => { + setState({ + // if cluster doesn't support ha, then primary will be disabled. Force into secondary + selectedNodeType: !data.ha ? "secondary" : state.selectedNodeType, + }); + }, + config: { + retry: false, + }, + }); - const node = testData.nodes[0]; + const node = nodeData || testData.nodes[0]; const columns = useMemo( () => [