@prorobotech/openapi-k8s-toolkit 1.2.0-alpha.18 → 1.2.0-alpha.19
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.
- package/dist/openapi-k8s-toolkit.es.js +126 -36
- package/dist/openapi-k8s-toolkit.es.js.map +1 -1
- package/dist/openapi-k8s-toolkit.umd.js +126 -36
- package/dist/openapi-k8s-toolkit.umd.js.map +1 -1
- package/dist/types/components/molecules/Terminals/NodeTerminal/NodeTerminal.d.ts +1 -0
- package/dist/types/components/molecules/Terminals/NodeTerminal/molecules/XTerminal/XTerminal.d.ts +3 -0
- package/dist/types/components/molecules/Terminals/NodeTerminal/molecules/XTerminal/types.d.ts +7 -0
- package/dist/types/components/molecules/Terminals/NodeTerminal/types.d.ts +12 -0
- package/dist/types/components/organisms/DynamicComponents/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -35415,6 +35415,7 @@ const NodeTerminal$1 = ({
|
|
|
35415
35415
|
cluster,
|
|
35416
35416
|
nodeName,
|
|
35417
35417
|
substractHeight,
|
|
35418
|
+
listPodTemplatesNs,
|
|
35418
35419
|
...props
|
|
35419
35420
|
} = data;
|
|
35420
35421
|
const { nodeTerminalDefaultProfile } = useFactoryConfig();
|
|
@@ -35424,6 +35425,7 @@ const NodeTerminal$1 = ({
|
|
|
35424
35425
|
return acc;
|
|
35425
35426
|
}, {});
|
|
35426
35427
|
const clusterPrepared = parseAll({ text: cluster, replaceValues, multiQueryData });
|
|
35428
|
+
const listPodTemplatesNsPrepared = listPodTemplatesNs ? parseAll({ text: listPodTemplatesNs, replaceValues, multiQueryData }) : void 0;
|
|
35427
35429
|
const nodeNamePrepared = parseAll({ text: nodeName, replaceValues, multiQueryData });
|
|
35428
35430
|
if (isMultiqueryLoading) {
|
|
35429
35431
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading multiquery" });
|
|
@@ -35436,6 +35438,7 @@ const NodeTerminal$1 = ({
|
|
|
35436
35438
|
nodeName: nodeNamePrepared,
|
|
35437
35439
|
substractHeight: substractHeight || 340,
|
|
35438
35440
|
defaultProfile: nodeTerminalDefaultProfile,
|
|
35441
|
+
listPodTemplatesNs: listPodTemplatesNsPrepared,
|
|
35439
35442
|
...props
|
|
35440
35443
|
}
|
|
35441
35444
|
),
|
|
@@ -82543,6 +82546,19 @@ const PodTerminal = ({ cluster, namespace, podName, containers, substractHeight
|
|
|
82543
82546
|
] });
|
|
82544
82547
|
};
|
|
82545
82548
|
|
|
82549
|
+
const useInfiniteSentinel = (sentinelRef, hasMore, onNeedMore) => {
|
|
82550
|
+
useEffect(() => {
|
|
82551
|
+
const el = sentinelRef.current;
|
|
82552
|
+
if (!el) return void 0;
|
|
82553
|
+
const io = new IntersectionObserver((entries) => {
|
|
82554
|
+
const visible = entries.some((e) => e.isIntersecting);
|
|
82555
|
+
if (visible && hasMore) onNeedMore();
|
|
82556
|
+
});
|
|
82557
|
+
io.observe(el);
|
|
82558
|
+
return () => io.disconnect();
|
|
82559
|
+
}, [sentinelRef, hasMore, onNeedMore]);
|
|
82560
|
+
};
|
|
82561
|
+
|
|
82546
82562
|
const CustomCard$3 = styled.div`
|
|
82547
82563
|
visibility: ${({ $isVisible }) => $isVisible ? "visible" : "hidden"};
|
|
82548
82564
|
height: calc(100vh - ${({ $substractHeight }) => $substractHeight}px);
|
|
@@ -82572,7 +82588,15 @@ const Styled$a = {
|
|
|
82572
82588
|
ProgressContainer
|
|
82573
82589
|
};
|
|
82574
82590
|
|
|
82575
|
-
const XTerminal$1 = ({
|
|
82591
|
+
const XTerminal$1 = ({
|
|
82592
|
+
endpoint,
|
|
82593
|
+
nodeName,
|
|
82594
|
+
profile,
|
|
82595
|
+
isCustomTemplate,
|
|
82596
|
+
podTemplateNamespace,
|
|
82597
|
+
containerName,
|
|
82598
|
+
substractHeight
|
|
82599
|
+
}) => {
|
|
82576
82600
|
const [isLoading, setIsLoading] = useState(true);
|
|
82577
82601
|
const [error, setError] = useState();
|
|
82578
82602
|
const [isTerminalVisible, setIsTerminalVisible] = useState(false);
|
|
@@ -82617,12 +82641,13 @@ const XTerminal$1 = ({ endpoint, nodeName, profile, substractHeight }) => {
|
|
|
82617
82641
|
const socket = new WebSocket(endpoint);
|
|
82618
82642
|
socketRef.current = socket;
|
|
82619
82643
|
socket.onopen = () => {
|
|
82620
|
-
|
|
82621
|
-
|
|
82622
|
-
|
|
82623
|
-
|
|
82624
|
-
|
|
82625
|
-
|
|
82644
|
+
const payload = { nodeName, profile };
|
|
82645
|
+
if (isCustomTemplate) {
|
|
82646
|
+
payload.podTemplateName = profile;
|
|
82647
|
+
payload.podTemplateNamespace = podTemplateNamespace;
|
|
82648
|
+
payload.containerName = containerName;
|
|
82649
|
+
}
|
|
82650
|
+
socket.send(JSON.stringify({ type: "init", payload }));
|
|
82626
82651
|
console.log(`[${nodeName}/${profile}]: WebSocket Client Connected`);
|
|
82627
82652
|
setIsLoading(false);
|
|
82628
82653
|
};
|
|
@@ -82696,7 +82721,7 @@ const XTerminal$1 = ({ endpoint, nodeName, profile, substractHeight }) => {
|
|
|
82696
82721
|
socket.close();
|
|
82697
82722
|
}
|
|
82698
82723
|
};
|
|
82699
|
-
}, [terminal, endpoint, nodeName, profile]);
|
|
82724
|
+
}, [terminal, endpoint, nodeName, profile, isCustomTemplate, podTemplateNamespace, containerName]);
|
|
82700
82725
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
82701
82726
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Styled$a.CustomCard, { $isVisible: isTerminalVisible, $substractHeight: substractHeight, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$a.FullWidthDiv, { $substractHeight: substractHeight, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: terminalRef, style: { width: "100%", height: "100%" } }) }) }),
|
|
82702
82727
|
!isTerminalVisible && !error && isWarmingUp && /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled$a.ProgressContainer, { $substractHeight: substractHeight, children: [
|
|
@@ -82724,32 +82749,110 @@ const Styled$9 = {
|
|
|
82724
82749
|
CustomSelect: CustomSelect$2
|
|
82725
82750
|
};
|
|
82726
82751
|
|
|
82727
|
-
const
|
|
82752
|
+
const PREDEFINED_PROFILES = ["legacy", "general", "baseline", "netadmin", "restricted", "sysadmin"];
|
|
82753
|
+
const NodeTerminal = ({
|
|
82754
|
+
cluster,
|
|
82755
|
+
nodeName,
|
|
82756
|
+
substractHeight,
|
|
82757
|
+
defaultProfile,
|
|
82758
|
+
listPodTemplatesNs
|
|
82759
|
+
}) => {
|
|
82728
82760
|
const [currentProfile, setCurrentProfile] = useState(defaultProfile || "general");
|
|
82761
|
+
const [currentContainer, setCurrentContainer] = useState();
|
|
82729
82762
|
const endpoint = `/api/clusters/${cluster}/openapi-bff-ws/terminal/terminalNode/terminalNode`;
|
|
82730
|
-
const
|
|
82763
|
+
const isUsingPodTemplates = Boolean(listPodTemplatesNs && listPodTemplatesNs.length > 0);
|
|
82764
|
+
const podTemplatesWsUrl = `/api/clusters/${cluster}/openapi-bff-ws/listThenWatch/listWatchWs`;
|
|
82765
|
+
const podTemplates = useListWatch({
|
|
82766
|
+
wsUrl: podTemplatesWsUrl,
|
|
82767
|
+
query: {
|
|
82768
|
+
apiVersion: "v1",
|
|
82769
|
+
plural: "podtemplates",
|
|
82770
|
+
namespace: listPodTemplatesNs
|
|
82771
|
+
},
|
|
82772
|
+
isEnabled: isUsingPodTemplates
|
|
82773
|
+
});
|
|
82774
|
+
const podTemplateNames = useMemo(() => {
|
|
82775
|
+
const values = Object.values(podTemplates.state.byKey ?? {}).map((it) => String(it?.metadata?.name ?? "")).filter(Boolean);
|
|
82776
|
+
return Array.from(new Set(values)).sort((a, b) => a.localeCompare(b));
|
|
82777
|
+
}, [podTemplates.state.byKey]);
|
|
82778
|
+
const hasPodTemplates = podTemplateNames.length > 0;
|
|
82779
|
+
const isPodTemplatesExist = isUsingPodTemplates && hasPodTemplates;
|
|
82780
|
+
useEffect(() => {
|
|
82781
|
+
if (hasPodTemplates && !podTemplateNames.includes(currentProfile)) {
|
|
82782
|
+
setCurrentProfile(podTemplateNames[0]);
|
|
82783
|
+
} else if (!hasPodTemplates && !PREDEFINED_PROFILES.includes(currentProfile)) {
|
|
82784
|
+
setCurrentProfile(defaultProfile || "general");
|
|
82785
|
+
}
|
|
82786
|
+
}, [hasPodTemplates, podTemplateNames, currentProfile, defaultProfile]);
|
|
82787
|
+
const containerNames = useMemo(() => {
|
|
82788
|
+
if (!isPodTemplatesExist) {
|
|
82789
|
+
return [];
|
|
82790
|
+
}
|
|
82791
|
+
const selectedTemplate = Object.values(podTemplates.state.byKey ?? {}).find(
|
|
82792
|
+
(it) => it?.metadata?.name === currentProfile
|
|
82793
|
+
);
|
|
82794
|
+
const containers = selectedTemplate?.template?.spec?.containers ?? [];
|
|
82795
|
+
return containers.map((c) => c.name).filter((name) => Boolean(name));
|
|
82796
|
+
}, [isPodTemplatesExist, podTemplates.state.byKey, currentProfile]);
|
|
82797
|
+
const hasMultipleContainers = containerNames.length > 1;
|
|
82798
|
+
useEffect(() => {
|
|
82799
|
+
if (isPodTemplatesExist && containerNames.length > 0) {
|
|
82800
|
+
setCurrentContainer(containerNames[0]);
|
|
82801
|
+
} else {
|
|
82802
|
+
setCurrentContainer(void 0);
|
|
82803
|
+
}
|
|
82804
|
+
}, [isPodTemplatesExist, containerNames]);
|
|
82805
|
+
const selectOptions = useMemo(() => {
|
|
82806
|
+
if (hasPodTemplates) {
|
|
82807
|
+
return podTemplateNames.map((name) => ({ value: name, label: name }));
|
|
82808
|
+
}
|
|
82809
|
+
return PREDEFINED_PROFILES.map((profile) => ({
|
|
82810
|
+
value: profile,
|
|
82811
|
+
label: profile
|
|
82812
|
+
}));
|
|
82813
|
+
}, [hasPodTemplates, podTemplateNames]);
|
|
82814
|
+
const canShowTerminal = currentProfile && (!isPodTemplatesExist || currentContainer);
|
|
82731
82815
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
82732
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
82733
|
-
|
|
82734
|
-
|
|
82735
|
-
|
|
82736
|
-
|
|
82737
|
-
|
|
82738
|
-
|
|
82739
|
-
|
|
82740
|
-
|
|
82741
|
-
|
|
82742
|
-
|
|
82816
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: 16, children: [
|
|
82817
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Styled$9.CustomSelect, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
82818
|
+
Select,
|
|
82819
|
+
{
|
|
82820
|
+
placeholder: "Select profile",
|
|
82821
|
+
options: selectOptions,
|
|
82822
|
+
filterOption: filterSelectOptions,
|
|
82823
|
+
showSearch: true,
|
|
82824
|
+
value: currentProfile,
|
|
82825
|
+
onChange: (value) => {
|
|
82826
|
+
setCurrentProfile(value);
|
|
82827
|
+
setCurrentContainer(void 0);
|
|
82828
|
+
}
|
|
82829
|
+
}
|
|
82830
|
+
) }),
|
|
82831
|
+
isPodTemplatesExist && hasMultipleContainers && /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$9.CustomSelect, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
82832
|
+
Select,
|
|
82833
|
+
{
|
|
82834
|
+
placeholder: "Select container",
|
|
82835
|
+
options: containerNames.map((name) => ({ value: name, label: name })),
|
|
82836
|
+
filterOption: filterSelectOptions,
|
|
82837
|
+
showSearch: true,
|
|
82838
|
+
value: currentContainer,
|
|
82839
|
+
onChange: (value) => setCurrentContainer(value)
|
|
82840
|
+
}
|
|
82841
|
+
) })
|
|
82842
|
+
] }),
|
|
82743
82843
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Spacer$1, { $space: 16, $samespace: true }),
|
|
82744
|
-
|
|
82844
|
+
canShowTerminal && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
82745
82845
|
XTerminal$1,
|
|
82746
82846
|
{
|
|
82747
82847
|
endpoint,
|
|
82748
82848
|
nodeName,
|
|
82749
82849
|
profile: currentProfile,
|
|
82850
|
+
isCustomTemplate: isPodTemplatesExist,
|
|
82851
|
+
podTemplateNamespace: isPodTemplatesExist ? listPodTemplatesNs : void 0,
|
|
82852
|
+
containerName: isPodTemplatesExist ? currentContainer : void 0,
|
|
82750
82853
|
substractHeight
|
|
82751
82854
|
},
|
|
82752
|
-
`${cluster}-${nodeName}-${currentProfile}`
|
|
82855
|
+
`${cluster}-${nodeName}-${listPodTemplatesNs}-${currentProfile}-${currentContainer}`
|
|
82753
82856
|
)
|
|
82754
82857
|
] });
|
|
82755
82858
|
};
|
|
@@ -85396,19 +85499,6 @@ const useCrdData = ({
|
|
|
85396
85499
|
});
|
|
85397
85500
|
};
|
|
85398
85501
|
|
|
85399
|
-
const useInfiniteSentinel = (sentinelRef, hasMore, onNeedMore) => {
|
|
85400
|
-
useEffect(() => {
|
|
85401
|
-
const el = sentinelRef.current;
|
|
85402
|
-
if (!el) return void 0;
|
|
85403
|
-
const io = new IntersectionObserver((entries) => {
|
|
85404
|
-
const visible = entries.some((e) => e.isIntersecting);
|
|
85405
|
-
if (visible && hasMore) onNeedMore();
|
|
85406
|
-
});
|
|
85407
|
-
io.observe(el);
|
|
85408
|
-
return () => io.disconnect();
|
|
85409
|
-
}, [sentinelRef, hasMore, onNeedMore]);
|
|
85410
|
-
};
|
|
85411
|
-
|
|
85412
85502
|
const useResourceScope = ({ plural, cluster, apiGroup, apiVersion }) => {
|
|
85413
85503
|
const computedResourceType = apiGroup ? "api" : "builtin";
|
|
85414
85504
|
const enabled = Boolean(cluster) && Boolean(plural) && (computedResourceType === "builtin" || Boolean(apiVersion));
|