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

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.
@@ -1,5 +1,5 @@
1
1
  import o, { useDebugValue, createElement, useRef, useContext, useState, useLayoutEffect, useEffect, useMemo, memo, useCallback, createContext, Suspense, Fragment } from 'react';
2
- import { Input, Tree, Modal, Alert, theme, Breadcrumb, Spin, Menu, Tooltip, Space, Button, Flex, Tag, Table, Form, Typography, Select, Row, Col, Slider, InputNumber, Switch, Card, notification, Dropdown, Result, Tabs } from 'antd';
2
+ import { Input, Tree, Modal, Alert, theme, Breadcrumb, Spin, Menu, Tooltip, Space, Button, Flex, Tag, Table, Typography, Form, Select, Row, Col, Slider, InputNumber, Switch, Card, notification, Dropdown, Result, Tabs } from 'antd';
3
3
  import { LoadingOutlined, ExclamationCircleFilled, CloseCircleFilled, CheckCircleFilled, SearchOutlined, CheckOutlined, CloseOutlined, EditOutlined, DeleteOutlined, CaretDownOutlined, CaretRightOutlined, BugOutlined, PlusOutlined, EllipsisOutlined } from '@ant-design/icons';
4
4
  import { useQuery, useQueries } from '@tanstack/react-query';
5
5
  import { Link, useNavigate, useLocation } from 'react-router-dom';
@@ -41598,9 +41598,14 @@ const ControlsRowContainer$1 = st.div`
41598
41598
  border-radius: 8px;
41599
41599
  padding: 4px;
41600
41600
  `;
41601
+ const BigText$1 = st.div`
41602
+ font-size: 16px;
41603
+ line-height: 24px;
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 @@ const YamlEditorSingleton = ({
41657
41662
  }
41658
41663
  };
41659
41664
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
41660
- error && /* @__PURE__ */ jsxRuntimeExports.jsx(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 @@ const YamlEditorSingleton = ({
41677
41681
  /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$9.ControlsRowContainer, { $bgColor: token.colorPrimaryBg, $designNewLayout: designNewLayout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: designNewLayout ? 10 : 16, align: "center", children: [
41678
41682
  /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "primary", onClick: onSubmit, loading: isLoading, children: "Submit" }),
41679
41683
  backlink && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: () => navigate(backlink), children: "Cancel" })
41680
- ] }) })
41684
+ ] }) }),
41685
+ error && /* @__PURE__ */ jsxRuntimeExports.jsxs(
41686
+ Modal,
41687
+ {
41688
+ open: !!error,
41689
+ onOk: () => setError(void 0),
41690
+ onCancel: () => setError(void 0),
41691
+ title: /* @__PURE__ */ jsxRuntimeExports.jsx(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 @@ const Styled = {
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] = useState(true);
44947
44965
  const [error, setError] = useState();
44948
44966
  const [terminal, setTerminal] = useState();
@@ -44994,7 +45012,7 @@ const XTerminal = ({ endpoint, namespace, podName }) => {
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 @@ const XTerminal = ({ endpoint, namespace, podName }) => {
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(Spin, {}),
@@ -45039,9 +45057,38 @@ const XTerminal = ({ endpoint, namespace, podName }) => {
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] = 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
+ Select,
45069
+ {
45070
+ placeholder: "Select container",
45071
+ options: containers.map((container) => ({ value: container, label: container })),
45072
+ filterOption: filterSelectOptions,
45073
+ allowClear: true,
45074
+ disabled: containers.length === 0,
45075
+ showSearch: true,
45076
+ value: currentContainer,
45077
+ onChange: (value) => setCurrentContainer(value)
45078
+ }
45079
+ ),
45080
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Spacer$1, { $space: 8, $samespace: true }),
45081
+ currentContainer && /* @__PURE__ */ jsxRuntimeExports.jsx(
45082
+ XTerminal,
45083
+ {
45084
+ endpoint,
45085
+ namespace,
45086
+ podName,
45087
+ container: currentContainer
45088
+ },
45089
+ `${cluster}-${namespace}-${podName}-${currentContainer}`
45090
+ )
45091
+ ] });
45045
45092
  };
45046
45093
 
45047
45094
  const DynamicRendererInner = ({
@@ -45570,6 +45617,7 @@ const parseMutliqueryText = ({ text, multiQueryData }) => {
45570
45617
  }
45571
45618
  });
45572
45619
  };
45620
+ const getRunningContainerNames = (pod) => (pod.status?.containerStatuses ?? []).filter((st) => Boolean(st.state?.running)).map((st) => st.name);
45573
45621
 
45574
45622
  const PodTerminal = ({
45575
45623
  data,
@@ -45602,11 +45650,43 @@ const PodTerminal = ({
45602
45650
  template: parseMutliqueryText({ text: podName, multiQueryData }),
45603
45651
  replaceValues
45604
45652
  });
45653
+ const {
45654
+ data: podInfo,
45655
+ isError: isPodInfoError,
45656
+ isLoading: isLoadingPodInfo
45657
+ } = useDirectUnknownResource({
45658
+ uri: `/api/clusters/${clusterPrepared}/k8s/api/v1/namespaces/${namespacePrepared}/pods/${podNamePrepared}`,
45659
+ refetchInterval: 5e3,
45660
+ queryKey: [clusterPrepared || "no-cluster", "pods", podNamePrepared],
45661
+ isEnabled: clusterPrepared !== void 0 && namespacePrepared !== void 0 && podNamePrepared !== void 0
45662
+ });
45605
45663
  if (isMultiqueryLoading) {
45606
45664
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
45607
45665
  }
45666
+ if (isLoadingPodInfo) {
45667
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Spin, {}) });
45668
+ }
45669
+ if (isPodInfoError) {
45670
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
45671
+ "Error: ",
45672
+ JSON.stringify(isPodInfoError)
45673
+ ] });
45674
+ }
45675
+ if (!podInfo) {
45676
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: "No Pod Info" });
45677
+ }
45678
+ const containers = getRunningContainerNames(podInfo);
45608
45679
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
45609
- /* @__PURE__ */ jsxRuntimeExports.jsx(PodTerminal$1, { cluster: clusterPrepared, namespace: namespacePrepared, podName: podNamePrepared, ...props }),
45680
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
45681
+ PodTerminal$1,
45682
+ {
45683
+ cluster: clusterPrepared,
45684
+ namespace: namespacePrepared,
45685
+ podName: podNamePrepared,
45686
+ containers,
45687
+ ...props
45688
+ }
45689
+ ),
45610
45690
  children
45611
45691
  ] });
45612
45692
  };