@prorobotech/openapi-k8s-toolkit 0.0.1-alpha.63 → 0.0.1-alpha.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41597,10 +41597,15 @@
41597
41597
  background-color: ${({ $bgColor, $designNewLayout }) => $designNewLayout ? $bgColor : "initial"};
41598
41598
  border-radius: 8px;
41599
41599
  padding: 4px;
41600
+ `;
41601
+ const BigText$1 = st.div`
41602
+ font-size: 16px;
41603
+ line-height: 24px;
41600
41604
  `;
41601
41605
  const Styled$9 = {
41602
41606
  BorderRadiusContainer,
41603
- ControlsRowContainer: ControlsRowContainer$1
41607
+ ControlsRowContainer: ControlsRowContainer$1,
41608
+ BigText: BigText$1
41604
41609
  };
41605
41610
 
41606
41611
  const YamlEditorSingleton = ({
@@ -41657,7 +41662,6 @@
41657
41662
  }
41658
41663
  };
41659
41664
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
41660
- error && /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Alert, { message: `An error has occurred: ${error?.response?.data?.message} `, type: "error" }),
41661
41665
  /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$9.BorderRadiusContainer, { $designNewLayoutHeight: designNewLayoutHeight, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
41662
41666
  Ft,
41663
41667
  {
@@ -41677,7 +41681,21 @@
41677
41681
  /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$9.ControlsRowContainer, { $bgColor: token.colorPrimaryBg, $designNewLayout: designNewLayout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Flex, { gap: designNewLayout ? 10 : 16, align: "center", children: [
41678
41682
  /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Button, { type: "primary", onClick: onSubmit, loading: isLoading, children: "Submit" }),
41679
41683
  backlink && /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Button, { onClick: () => navigate(backlink), children: "Cancel" })
41680
- ] }) })
41684
+ ] }) }),
41685
+ error && /* @__PURE__ */ jsxRuntimeExports.jsxs(
41686
+ antd.Modal,
41687
+ {
41688
+ open: !!error,
41689
+ onOk: () => setError(void 0),
41690
+ onCancel: () => setError(void 0),
41691
+ title: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Typography.Text, { type: "danger", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$9.BigText, { children: "Error!" }) }),
41692
+ cancelButtonProps: { style: { display: "none" } },
41693
+ children: [
41694
+ "An error has occurred: ",
41695
+ error?.response?.data?.message
41696
+ ]
41697
+ }
41698
+ )
41681
41699
  ] });
41682
41700
  };
41683
41701
 
@@ -44942,7 +44960,7 @@
44942
44960
  CustomCard
44943
44961
  };
44944
44962
 
44945
- const XTerminal = ({ endpoint, namespace, podName }) => {
44963
+ const XTerminal = ({ endpoint, namespace, podName, container }) => {
44946
44964
  const [isLoading, setIsLoading] = o.useState(true);
44947
44965
  const [error, setError] = o.useState();
44948
44966
  const [terminal, setTerminal] = o.useState();
@@ -44994,7 +45012,7 @@
44994
45012
  socket.send(
44995
45013
  JSON.stringify({
44996
45014
  type: "init",
44997
- payload: { namespace, podName }
45015
+ payload: { namespace, podName, container }
44998
45016
  })
44999
45017
  );
45000
45018
  console.log(`[${namespace}/${podName}]: WebSocket Client Connected`);
@@ -45031,7 +45049,7 @@
45031
45049
  socket.close();
45032
45050
  }
45033
45051
  };
45034
- }, [terminal, endpoint, namespace, podName]);
45052
+ }, [terminal, endpoint, namespace, podName, container]);
45035
45053
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
45036
45054
  /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.CustomCard, { $isVisible: !isLoading && !error, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.FullWidthDiv, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: terminalRef }) }) }),
45037
45055
  isLoading && !error && /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Spin, {}),
@@ -45039,9 +45057,37 @@
45039
45057
  ] });
45040
45058
  };
45041
45059
 
45042
- const PodTerminal$1 = ({ cluster, namespace, podName }) => {
45060
+ const PodTerminal$1 = ({ cluster, namespace, podName, containers }) => {
45061
+ const [currentContainer, setCurrentContainer] = o.useState(containers[0] || void 0);
45043
45062
  const endpoint = `/api/clusters/${cluster}/openapi-bff-ws/terminal/terminalPod/terminalPod`;
45044
- return /* @__PURE__ */ jsxRuntimeExports.jsx(XTerminal, { endpoint, namespace, podName }, `${cluster}-${namespace}-${podName}`);
45063
+ if (containers.length === 0) {
45064
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: "No Running Containers" });
45065
+ }
45066
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
45067
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
45068
+ antd.Select,
45069
+ {
45070
+ placeholder: "Select container",
45071
+ options: containers.map((container) => ({ value: container, label: container })),
45072
+ filterOption: filterSelectOptions,
45073
+ disabled: containers.length === 0,
45074
+ showSearch: true,
45075
+ value: currentContainer,
45076
+ onChange: (value) => setCurrentContainer(value)
45077
+ }
45078
+ ),
45079
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Spacer$1, { $space: 8, $samespace: true }),
45080
+ currentContainer && /* @__PURE__ */ jsxRuntimeExports.jsx(
45081
+ XTerminal,
45082
+ {
45083
+ endpoint,
45084
+ namespace,
45085
+ podName,
45086
+ container: currentContainer
45087
+ },
45088
+ `${cluster}-${namespace}-${podName}-${currentContainer}`
45089
+ )
45090
+ ] });
45045
45091
  };
45046
45092
 
45047
45093
  const DynamicRendererInner = ({
@@ -45570,6 +45616,7 @@
45570
45616
  }
45571
45617
  });
45572
45618
  };
45619
+ const getRunningContainerNames = (pod) => (pod.status?.containerStatuses ?? []).filter((st) => Boolean(st.state?.running)).map((st) => st.name);
45573
45620
 
45574
45621
  const PodTerminal = ({
45575
45622
  data,
@@ -45602,11 +45649,43 @@
45602
45649
  template: parseMutliqueryText({ text: podName, multiQueryData }),
45603
45650
  replaceValues
45604
45651
  });
45652
+ const {
45653
+ data: podInfo,
45654
+ isError: isPodInfoError,
45655
+ isLoading: isLoadingPodInfo
45656
+ } = useDirectUnknownResource({
45657
+ uri: `/api/clusters/${clusterPrepared}/k8s/api/v1/namespaces/${namespacePrepared}/pods/${podNamePrepared}`,
45658
+ refetchInterval: 5e3,
45659
+ queryKey: [clusterPrepared || "no-cluster", "pods", podNamePrepared],
45660
+ isEnabled: clusterPrepared !== void 0 && namespacePrepared !== void 0 && podNamePrepared !== void 0
45661
+ });
45605
45662
  if (isMultiqueryLoading) {
45606
45663
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
45607
45664
  }
45665
+ if (isLoadingPodInfo) {
45666
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Spin, {}) });
45667
+ }
45668
+ if (isPodInfoError) {
45669
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
45670
+ "Error: ",
45671
+ JSON.stringify(isPodInfoError)
45672
+ ] });
45673
+ }
45674
+ if (!podInfo) {
45675
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: "No Pod Info" });
45676
+ }
45677
+ const containers = getRunningContainerNames(podInfo);
45608
45678
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
45609
- /* @__PURE__ */ jsxRuntimeExports.jsx(PodTerminal$1, { cluster: clusterPrepared, namespace: namespacePrepared, podName: podNamePrepared, ...props }),
45679
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
45680
+ PodTerminal$1,
45681
+ {
45682
+ cluster: clusterPrepared,
45683
+ namespace: namespacePrepared,
45684
+ podName: podNamePrepared,
45685
+ containers,
45686
+ ...props
45687
+ }
45688
+ ),
45610
45689
  children
45611
45690
  ] });
45612
45691
  };