@prorobotech/openapi-k8s-toolkit 1.2.0-alpha.12 → 1.2.0-alpha.14

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.
@@ -8612,8 +8612,7 @@
8612
8612
  };
8613
8613
 
8614
8614
  const getKinds = async ({ cluster }) => {
8615
- const result = await axios.get(`/api/clusters/${cluster}/openapi-bff/search/kinds/getKinds`);
8616
- return result.data;
8615
+ return axios.get(`/api/clusters/${cluster}/openapi-bff/search/kinds/getKinds`);
8617
8616
  };
8618
8617
 
8619
8618
  const kindByGvr = (entries) => (gvr) => {
@@ -9385,7 +9384,7 @@
9385
9384
  if (cancelled) {
9386
9385
  return;
9387
9386
  }
9388
- setKindsWithVersion(getSortedKindsAll(data));
9387
+ setKindsWithVersion(getSortedKindsAll(data.data));
9389
9388
  }).catch(() => {
9390
9389
  if (!cancelled) {
9391
9390
  setKindsWithVersion(void 0);
@@ -46468,6 +46467,23 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
46468
46467
  return uniq.length === 1 ? uniq[0] : void 0;
46469
46468
  };
46470
46469
 
46470
+ const useKinds = ({
46471
+ cluster,
46472
+ refetchInterval,
46473
+ isEnabled
46474
+ }) => {
46475
+ return reactQuery.useQuery({
46476
+ queryKey: ["useKinds", cluster],
46477
+ queryFn: () => getKinds({ cluster }),
46478
+ select: (data) => ({
46479
+ kindIndex: data.data,
46480
+ kindsWithVersion: getSortedKindsAll(data.data)
46481
+ }),
46482
+ refetchInterval: refetchInterval !== void 0 ? refetchInterval : 6e4,
46483
+ enabled: isEnabled
46484
+ });
46485
+ };
46486
+
46471
46487
  const findOwnerReferencePath = (rawObject, jsonPathToArrayOfRefs, reference) => {
46472
46488
  if (!rawObject || !jsonPathToArrayOfRefs) return void 0;
46473
46489
  let arrayJsonPath = jsonPathToArrayOfRefs.trim();
@@ -46599,16 +46615,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
46599
46615
  baseNavigationName,
46600
46616
  listFlexProps
46601
46617
  }) => {
46602
- const [kindIndex, setKindIndex] = K.useState();
46603
- const [kindsWithVersion, setKindWithVersion] = K.useState();
46604
- K.useEffect(() => {
46605
- getKinds({ cluster }).then((data) => {
46606
- setKindIndex(data);
46607
- setKindWithVersion(getSortedKindsAll(data));
46608
- }).catch((error) => {
46609
- console.error(error);
46610
- });
46611
- }, [cluster]);
46618
+ const { data: kindsData } = useKinds({ cluster });
46612
46619
  const { data: navigationDataArr } = useK8sSmartResource({
46613
46620
  cluster,
46614
46621
  apiGroup: "front.in-cloud.io",
@@ -46616,7 +46623,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
46616
46623
  plural: baseNavigationPlural,
46617
46624
  fieldSelector: `metadata.name=${baseNavigationName}`
46618
46625
  });
46619
- const getPlural = kindsWithVersion ? pluralByKind(kindsWithVersion) : void 0;
46626
+ const getPlural = kindsData?.kindsWithVersion ? pluralByKind(kindsData?.kindsWithVersion) : void 0;
46620
46627
  const baseFactoriesMapping = navigationDataArr && navigationDataArr.items && navigationDataArr.items.length > 0 ? navigationDataArr.items[0].spec?.baseFactoriesMapping : void 0;
46621
46628
  return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Flex, { vertical: true, gap: 8, ...listFlexProps, children: refsArr.map((ref) => /* @__PURE__ */ jsxRuntimeExports.jsx(
46622
46629
  RefElement,
@@ -54896,16 +54903,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
54896
54903
  baseNavigationName
54897
54904
  }) => {
54898
54905
  const { token } = antd.theme.useToken();
54899
- const [kindIndex, setKindIndex] = K.useState();
54900
- const [kindsWithVersion, setKindWithVersion] = K.useState();
54901
- K.useEffect(() => {
54902
- getKinds({ cluster }).then((data) => {
54903
- setKindIndex(data);
54904
- setKindWithVersion(getSortedKindsAll(data));
54905
- }).catch((error) => {
54906
- console.error(error);
54907
- });
54908
- }, [cluster]);
54906
+ const { data: kindsData } = useKinds({ cluster });
54909
54907
  const { data: navigationDataArr } = useK8sSmartResource({
54910
54908
  cluster,
54911
54909
  apiGroup: "front.in-cloud.io",
@@ -55124,7 +55122,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
55124
55122
  if (nearBottom && hasMore) sendScroll();
55125
55123
  }, [hasMore, sendScroll]);
55126
55124
  const total = state.order.length;
55127
- const getPlural = kindsWithVersion ? pluralByKind(kindsWithVersion) : void 0;
55125
+ const getPlural = kindsData?.kindsWithVersion ? pluralByKind(kindsData?.kindsWithVersion) : void 0;
55128
55126
  const baseFactoriesMapping = navigationDataArr && navigationDataArr.items && navigationDataArr.items.length > 0 ? navigationDataArr.items[0].spec?.baseFactoriesMapping : void 0;
55129
55127
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled.Root, { $substractHeight: substractHeight || 340, children: [
55130
55128
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled.Header, { children: [
@@ -55955,6 +55953,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
55955
55953
  exports.useInfiniteSentinel = useInfiniteSentinel;
55956
55954
  exports.useK8sSmartResource = useK8sSmartResource;
55957
55955
  exports.useK8sVerbs = useK8sVerbs;
55956
+ exports.useKinds = useKinds;
55958
55957
  exports.useListWatch = useListWatch;
55959
55958
  exports.useManyK8sSmartResource = useManyK8sSmartResource;
55960
55959
  exports.usePermissions = usePermissions;