@prorobotech/openapi-k8s-toolkit 1.4.0-alpha.7 → 1.4.0-alpha.8

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.
@@ -9760,178 +9760,6 @@ const ManageableSidebar = ({ data, noMarginTop }) => {
9760
9760
  );
9761
9761
  };
9762
9762
 
9763
- const getLabel$1 = ({
9764
- preparedLink,
9765
- label,
9766
- key,
9767
- externalKeys,
9768
- replaceValues
9769
- }) => {
9770
- const preparedLabel = prepareTemplate({ template: label, replaceValues });
9771
- if (preparedLink) {
9772
- if (externalKeys && externalKeys.includes(key)) {
9773
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
9774
- "a",
9775
- {
9776
- onClick: (e) => {
9777
- e.preventDefault();
9778
- e.stopPropagation();
9779
- const url = preparedLink.startsWith("/") ? `${window.location.origin}${preparedLink}` : preparedLink;
9780
- window.open(url);
9781
- },
9782
- children: preparedLabel
9783
- }
9784
- );
9785
- }
9786
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: preparedLink, children: preparedLabel });
9787
- }
9788
- return preparedLabel;
9789
- };
9790
- const mapLinksFromRaw = ({
9791
- rawLinks,
9792
- replaceValues,
9793
- externalKeys
9794
- }) => {
9795
- return rawLinks.map(({ key, label, link, children }) => {
9796
- const preparedLink = link ? prepareTemplate({ template: link, replaceValues }) : void 0;
9797
- return {
9798
- key,
9799
- label: getLabel$1({ preparedLink, label, key, externalKeys, replaceValues }),
9800
- internalMetaLink: preparedLink,
9801
- children: children ? mapLinksFromRaw({
9802
- rawLinks: children,
9803
- replaceValues,
9804
- externalKeys
9805
- }) : void 0
9806
- };
9807
- });
9808
- };
9809
- const findMatchingItems = ({
9810
- items,
9811
- pathname,
9812
- searchParams,
9813
- tags
9814
- }) => {
9815
- const normalizePath = (value) => {
9816
- if (!value) {
9817
- return void 0;
9818
- }
9819
- return value.startsWith("/") ? value.slice(1) : value;
9820
- };
9821
- const traverse = (nodes, parents) => nodes.flatMap((node) => {
9822
- const currentPath = [...parents, node.key ? node.key : String(node.key)];
9823
- const cleanNodeInternalMetaLink = normalizePath(node.internalMetaLink);
9824
- const cleanPathname = normalizePath(pathname.split("?")[0]);
9825
- let searchSuffix;
9826
- if (searchParams && searchParams.length > 0) {
9827
- searchSuffix = searchParams.startsWith("?") ? searchParams : `?${searchParams}`;
9828
- }
9829
- let pathnameWithSearch;
9830
- if (searchSuffix) {
9831
- pathnameWithSearch = `${pathname}${searchSuffix}`;
9832
- } else if (pathname.includes("?")) {
9833
- pathnameWithSearch = pathname;
9834
- }
9835
- const cleanPathnameWithSearch = normalizePath(pathnameWithSearch);
9836
- const matched = cleanNodeInternalMetaLink === cleanPathname || cleanPathnameWithSearch && cleanNodeInternalMetaLink === cleanPathnameWithSearch ? currentPath : [];
9837
- const tagsToMatch = tags && tags.keysAndTags && node.key ? tags.keysAndTags[typeof node.key === "string" ? node.key : String(node.key)] : void 0;
9838
- const matchedByTags = tags && tags.currentTags && tagsToMatch && tagsToMatch.some((tag) => tags.currentTags?.includes(tag)) ? currentPath : [];
9839
- let childrenResults = [];
9840
- if ("children" in node && node.children) {
9841
- childrenResults = traverse(node.children, currentPath);
9842
- }
9843
- return [...matched, ...matchedByTags, ...childrenResults];
9844
- });
9845
- return traverse(items, []);
9846
- };
9847
- const prepareDataForManageableSidebar = ({
9848
- data,
9849
- replaceValues,
9850
- pathname,
9851
- searchParams,
9852
- idToCompare,
9853
- fallbackIdToCompare,
9854
- currentTags
9855
- }) => {
9856
- const foundData = data.find((el) => el.id === idToCompare) || (fallbackIdToCompare ? data.find((el) => el.id === fallbackIdToCompare) : void 0);
9857
- if (!foundData) {
9858
- return void 0;
9859
- }
9860
- const preparedCurrentTags = currentTags && currentTags.length > 0 ? currentTags.map((el) => prepareTemplate({ template: el, replaceValues })) : void 0;
9861
- const result = {
9862
- menuItems: mapLinksFromRaw({
9863
- rawLinks: foundData.menuItems,
9864
- replaceValues,
9865
- externalKeys: foundData.externalKeys
9866
- })
9867
- };
9868
- const openedKeys = result?.menuItems ? findMatchingItems({
9869
- items: result?.menuItems,
9870
- pathname,
9871
- searchParams,
9872
- tags: { keysAndTags: foundData.keysAndTags, currentTags: preparedCurrentTags }
9873
- }) : [];
9874
- const stringedOpenedKeys = openedKeys.map((el) => typeof el === "string" ? el : String(el));
9875
- return { ...result, selectedKeys: stringedOpenedKeys };
9876
- };
9877
-
9878
- const ManageableSidebarProvider = ({
9879
- cluster,
9880
- apiGroup,
9881
- apiVersion,
9882
- plural,
9883
- isEnabled,
9884
- replaceValues,
9885
- pathname,
9886
- searchParams,
9887
- idToCompare,
9888
- fallbackIdToCompare,
9889
- currentTags,
9890
- hidden,
9891
- noMarginTop
9892
- }) => {
9893
- const {
9894
- data: rawData,
9895
- isError: rawDataError,
9896
- isLoading: rawDataLoading
9897
- } = useK8sSmartResource({
9898
- cluster,
9899
- apiGroup,
9900
- apiVersion,
9901
- plural,
9902
- isEnabled
9903
- });
9904
- if (rawDataError) {
9905
- return null;
9906
- }
9907
- if (rawDataLoading) {
9908
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Spin, {});
9909
- }
9910
- if (!rawData) {
9911
- return null;
9912
- }
9913
- if (hidden) {
9914
- return null;
9915
- }
9916
- const parsedData = rawData?.items.map(({ spec }) => spec);
9917
- if (!parsedData) {
9918
- return null;
9919
- }
9920
- const result = prepareDataForManageableSidebar({
9921
- data: parsedData,
9922
- replaceValues,
9923
- pathname,
9924
- searchParams,
9925
- idToCompare,
9926
- fallbackIdToCompare,
9927
- currentTags
9928
- });
9929
- if (!result) {
9930
- return null;
9931
- }
9932
- return /* @__PURE__ */ jsxRuntimeExports.jsx(ManageableSidebar, { data: result, noMarginTop });
9933
- };
9934
-
9935
9763
  function commonjsRequire(path) {
9936
9764
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
9937
9765
  }
@@ -33947,6 +33775,509 @@ lodash.exports;
33947
33775
  var lodashExports = lodash.exports;
33948
33776
  const _$1 = /*@__PURE__*/getDefaultExportFromCjs(lodashExports);
33949
33777
 
33778
+ const parsePartsOfUrl = ({
33779
+ template,
33780
+ replaceValues
33781
+ }) => {
33782
+ return prepareTemplate({ template, replaceValues });
33783
+ };
33784
+ const parseMutliqueryText = ({
33785
+ text,
33786
+ multiQueryData,
33787
+ customFallback
33788
+ }) => {
33789
+ if (!text) {
33790
+ return "";
33791
+ }
33792
+ return text.replace(
33793
+ /\{reqs\[(\d+)\]\[((?:\s*['"][^'"]+['"]\s*,?)+)\](?:\[\s*['"]([^'"]+)['"]\s*\])?\}/g,
33794
+ (_match, reqIndexStr, rawPath, fallback) => {
33795
+ try {
33796
+ const reqIndex = parseInt(reqIndexStr, 10);
33797
+ const path = Array.from(rawPath.matchAll(/['"]([^'"]+)['"]/g)).map(
33798
+ (m) => m[1]
33799
+ );
33800
+ const value = _$1.get(multiQueryData[`req${reqIndex}`] || {}, path, fallback !== void 0 ? fallback : void 0);
33801
+ if (value == null && !customFallback) {
33802
+ return fallback ?? "Undefined with no fallback";
33803
+ }
33804
+ if (customFallback && (value === void 0 || value === null)) {
33805
+ return customFallback;
33806
+ }
33807
+ return String(value);
33808
+ } catch {
33809
+ return _match;
33810
+ }
33811
+ }
33812
+ );
33813
+ };
33814
+ const parseJsonPathTemplate = ({
33815
+ text,
33816
+ multiQueryData,
33817
+ customFallback,
33818
+ replaceValues
33819
+ }) => {
33820
+ if (!text) return "";
33821
+ const placeholderRegex = /\{reqsJsonPath\[(\d+)\]\s*\[\s*(['"])([\s\S]*?)\2\s*\](?:\s*\[\s*(['"])([\s\S]*?)\4\s*\])?\}/g;
33822
+ const resolve = (input) => input.replace(
33823
+ placeholderRegex,
33824
+ (match, reqIndexStr, _quote, rawJsonPathExpr, _fallbackQuote, inlineFallback = "Undefined with no fallback") => {
33825
+ try {
33826
+ const reqIndex = Number(reqIndexStr);
33827
+ const jsonRoot = multiQueryData[`req${reqIndex}`];
33828
+ let jsonPathExpr = rawJsonPathExpr;
33829
+ let previous2 = null;
33830
+ let loopGuard = 0;
33831
+ while (previous2 !== jsonPathExpr && loopGuard < 10) {
33832
+ previous2 = jsonPathExpr;
33833
+ jsonPathExpr = resolve(jsonPathExpr);
33834
+ loopGuard++;
33835
+ }
33836
+ if (replaceValues) {
33837
+ jsonPathExpr = prepareTemplate({
33838
+ template: jsonPathExpr,
33839
+ replaceValues
33840
+ });
33841
+ }
33842
+ if (jsonRoot === void 0 && customFallback) return customFallback;
33843
+ if (jsonRoot === void 0) return inlineFallback;
33844
+ const results = jp.query(jsonRoot, `$${jsonPathExpr}`);
33845
+ const value = results?.[0];
33846
+ if (value == null) {
33847
+ return customFallback ?? inlineFallback;
33848
+ }
33849
+ return String(value);
33850
+ } catch {
33851
+ return match;
33852
+ }
33853
+ }
33854
+ );
33855
+ let result = text;
33856
+ let previous = null;
33857
+ let iterations = 0;
33858
+ while (result !== previous && iterations < 10) {
33859
+ previous = result;
33860
+ result = resolve(result);
33861
+ iterations++;
33862
+ }
33863
+ return result;
33864
+ };
33865
+ const parseWithoutPartsOfUrl = ({
33866
+ text,
33867
+ multiQueryData,
33868
+ customFallback
33869
+ }) => {
33870
+ return parseJsonPathTemplate({
33871
+ text: parseMutliqueryText({
33872
+ text,
33873
+ multiQueryData,
33874
+ customFallback
33875
+ }),
33876
+ multiQueryData,
33877
+ customFallback
33878
+ });
33879
+ };
33880
+ const parseAll = ({
33881
+ text,
33882
+ replaceValues,
33883
+ multiQueryData
33884
+ }) => {
33885
+ return parsePartsOfUrl({
33886
+ template: parseJsonPathTemplate({
33887
+ text: parseMutliqueryText({
33888
+ text,
33889
+ multiQueryData
33890
+ }),
33891
+ multiQueryData,
33892
+ replaceValues
33893
+ }),
33894
+ replaceValues
33895
+ });
33896
+ };
33897
+ const parsePromTemplate = ({
33898
+ text,
33899
+ replaceValues,
33900
+ multiQueryData
33901
+ }) => {
33902
+ const parsed = parseJsonPathTemplate({
33903
+ text: parseMutliqueryText({
33904
+ text,
33905
+ multiQueryData
33906
+ }),
33907
+ multiQueryData,
33908
+ replaceValues
33909
+ });
33910
+ return parsed.replace(/\{(\d+)\}/g, (_2, key) => replaceValues[key] || "");
33911
+ };
33912
+
33913
+ const collectLinksWithResourcesList = ({
33914
+ items,
33915
+ parentPath = "",
33916
+ replaceValues,
33917
+ multiQueryData,
33918
+ isEnabled
33919
+ }) => items.flatMap((item) => {
33920
+ const nodePath = parentPath ? `${parentPath}/${item.key}` : item.key;
33921
+ const self = item.resourcesList ? (() => {
33922
+ const clusterPrepared = parseAll({
33923
+ text: item.resourcesList.cluster,
33924
+ replaceValues,
33925
+ multiQueryData
33926
+ });
33927
+ const apiGroupPrepared = item.resourcesList.apiGroup ? parseAll({
33928
+ text: item.resourcesList.apiGroup,
33929
+ replaceValues,
33930
+ multiQueryData
33931
+ }) : void 0;
33932
+ const apiVersionPrepared = parseAll({
33933
+ text: item.resourcesList.apiVersion,
33934
+ replaceValues,
33935
+ multiQueryData
33936
+ });
33937
+ const pluralPrepared = parseAll({
33938
+ text: item.resourcesList.plural,
33939
+ replaceValues,
33940
+ multiQueryData
33941
+ });
33942
+ const namespacePrepared = item.resourcesList.namespace ? parseAll({
33943
+ text: item.resourcesList.namespace,
33944
+ replaceValues,
33945
+ multiQueryData
33946
+ }) : void 0;
33947
+ return [
33948
+ {
33949
+ nodePath,
33950
+ k8sParams: {
33951
+ cluster: clusterPrepared,
33952
+ apiGroup: apiGroupPrepared,
33953
+ apiVersion: apiVersionPrepared,
33954
+ plural: pluralPrepared,
33955
+ namespace: namespacePrepared,
33956
+ isEnabled: Boolean(clusterPrepared && apiVersionPrepared && pluralPrepared && isEnabled !== false)
33957
+ }
33958
+ }
33959
+ ];
33960
+ })() : [];
33961
+ const nested = item.children ? collectLinksWithResourcesList({
33962
+ items: item.children,
33963
+ parentPath: nodePath,
33964
+ replaceValues,
33965
+ multiQueryData,
33966
+ isEnabled
33967
+ }) : [];
33968
+ return [...self, ...nested];
33969
+ });
33970
+ const getLabel$1 = ({
33971
+ preparedLink,
33972
+ label,
33973
+ key,
33974
+ externalKeys,
33975
+ replaceValues,
33976
+ multiQueryData
33977
+ }) => {
33978
+ const preparedLabel = parseAll({ text: label, replaceValues, multiQueryData });
33979
+ if (preparedLink) {
33980
+ if (externalKeys && externalKeys.includes(key)) {
33981
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
33982
+ "a",
33983
+ {
33984
+ onClick: (e) => {
33985
+ e.preventDefault();
33986
+ e.stopPropagation();
33987
+ const url = preparedLink.startsWith("/") ? `${window.location.origin}${preparedLink}` : preparedLink;
33988
+ window.open(url);
33989
+ },
33990
+ children: preparedLabel
33991
+ }
33992
+ );
33993
+ }
33994
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: preparedLink, children: preparedLabel });
33995
+ }
33996
+ return preparedLabel;
33997
+ };
33998
+ const mapLinksFromRaw = ({
33999
+ rawLinks,
34000
+ replaceValues,
34001
+ multiQueryData,
34002
+ externalKeys,
34003
+ resourcesListData,
34004
+ parentPath = ""
34005
+ }) => {
34006
+ return rawLinks.map(({ key, label, link, children, resourcesList }) => {
34007
+ const nodePath = parentPath ? `${parentPath}/${key}` : key;
34008
+ const preparedLink = link ? parseAll({ text: link, replaceValues, multiQueryData }) : void 0;
34009
+ const staticChildren = children ? mapLinksFromRaw({
34010
+ rawLinks: children,
34011
+ replaceValues,
34012
+ multiQueryData,
34013
+ externalKeys,
34014
+ resourcesListData,
34015
+ parentPath: nodePath
34016
+ }) : [];
34017
+ const dynamicChildrenRaw = resourcesList ? (resourcesListData?.[nodePath]?.items || []).map((item, index) => {
34018
+ const resourceName = (() => {
34019
+ try {
34020
+ const value = jp.query(item, `$${resourcesList.jsonPathToName}`)[0];
34021
+ return value !== void 0 && value !== null ? String(value) : void 0;
34022
+ } catch {
34023
+ return void 0;
34024
+ }
34025
+ })();
34026
+ if (!resourceName) {
34027
+ return void 0;
34028
+ }
34029
+ const childLink = parseAll({
34030
+ text: resourcesList.linkToResource,
34031
+ replaceValues: { ...replaceValues, resourceName },
34032
+ multiQueryData
34033
+ });
34034
+ const childKey = `${key}-${resourceName}-${index}`;
34035
+ return {
34036
+ key: childKey,
34037
+ label: getLabel$1({
34038
+ preparedLink: childLink,
34039
+ label: resourceName,
34040
+ key: childKey,
34041
+ externalKeys,
34042
+ replaceValues,
34043
+ multiQueryData
34044
+ }),
34045
+ internalMetaLink: childLink
34046
+ };
34047
+ }).filter(Boolean) : [];
34048
+ const dynamicChildren = dynamicChildrenRaw;
34049
+ const mergedChildren = [...staticChildren, ...dynamicChildren];
34050
+ return {
34051
+ key,
34052
+ label: getLabel$1({ preparedLink, label, key, externalKeys, replaceValues, multiQueryData }),
34053
+ internalMetaLink: preparedLink,
34054
+ children: mergedChildren.length > 0 ? mergedChildren : void 0
34055
+ };
34056
+ });
34057
+ };
34058
+ const findMatchingItems = ({
34059
+ items,
34060
+ pathname,
34061
+ searchParams,
34062
+ tags
34063
+ }) => {
34064
+ const normalizePath = (value) => {
34065
+ if (!value) {
34066
+ return void 0;
34067
+ }
34068
+ return value.startsWith("/") ? value.slice(1) : value;
34069
+ };
34070
+ const traverse = (nodes, parents) => nodes.flatMap((node) => {
34071
+ const currentPath = [...parents, node.key ? node.key : String(node.key)];
34072
+ const cleanNodeInternalMetaLink = normalizePath(node.internalMetaLink);
34073
+ const cleanPathname = normalizePath(pathname.split("?")[0]);
34074
+ let searchSuffix;
34075
+ if (searchParams && searchParams.length > 0) {
34076
+ searchSuffix = searchParams.startsWith("?") ? searchParams : `?${searchParams}`;
34077
+ }
34078
+ let pathnameWithSearch;
34079
+ if (searchSuffix) {
34080
+ pathnameWithSearch = `${pathname}${searchSuffix}`;
34081
+ } else if (pathname.includes("?")) {
34082
+ pathnameWithSearch = pathname;
34083
+ }
34084
+ const cleanPathnameWithSearch = normalizePath(pathnameWithSearch);
34085
+ const matched = cleanNodeInternalMetaLink === cleanPathname || cleanPathnameWithSearch && cleanNodeInternalMetaLink === cleanPathnameWithSearch ? currentPath : [];
34086
+ const tagsToMatch = tags && tags.keysAndTags && node.key ? tags.keysAndTags[typeof node.key === "string" ? node.key : String(node.key)] : void 0;
34087
+ const matchedByTags = tags && tags.currentTags && tagsToMatch && tagsToMatch.some((tag) => tags.currentTags?.includes(tag)) ? currentPath : [];
34088
+ let childrenResults = [];
34089
+ if ("children" in node && node.children) {
34090
+ childrenResults = traverse(node.children, currentPath);
34091
+ }
34092
+ return [...matched, ...matchedByTags, ...childrenResults];
34093
+ });
34094
+ return traverse(items, []);
34095
+ };
34096
+ const stripInternalMetaFromItems = (items) => items.map((item) => {
34097
+ if (!item) {
34098
+ return item;
34099
+ }
34100
+ const rest = { ...item };
34101
+ delete rest.internalMetaLink;
34102
+ if ("children" in rest && Array.isArray(rest.children)) {
34103
+ return {
34104
+ ...rest,
34105
+ children: stripInternalMetaFromItems(rest.children)
34106
+ };
34107
+ }
34108
+ return rest;
34109
+ });
34110
+ const prepareDataForManageableSidebar = ({
34111
+ data,
34112
+ replaceValues,
34113
+ multiQueryData = {},
34114
+ pathname,
34115
+ searchParams,
34116
+ idToCompare,
34117
+ fallbackIdToCompare,
34118
+ currentTags,
34119
+ resourcesListData
34120
+ }) => {
34121
+ const foundData = data.find((el) => el.id === idToCompare) || (fallbackIdToCompare ? data.find((el) => el.id === fallbackIdToCompare) : void 0);
34122
+ if (!foundData) {
34123
+ return void 0;
34124
+ }
34125
+ const preparedCurrentTags = currentTags && currentTags.length > 0 ? currentTags.map((el) => parseAll({ text: el, replaceValues, multiQueryData })) : void 0;
34126
+ const result = {
34127
+ menuItems: mapLinksFromRaw({
34128
+ rawLinks: foundData.menuItems,
34129
+ replaceValues,
34130
+ multiQueryData,
34131
+ externalKeys: foundData.externalKeys,
34132
+ resourcesListData
34133
+ })
34134
+ };
34135
+ const openedKeys = result?.menuItems ? findMatchingItems({
34136
+ items: result?.menuItems,
34137
+ pathname,
34138
+ searchParams,
34139
+ tags: { keysAndTags: foundData.keysAndTags, currentTags: preparedCurrentTags }
34140
+ }) : [];
34141
+ const stringedOpenedKeys = openedKeys.map((el) => typeof el === "string" ? el : String(el));
34142
+ return { menuItems: stripInternalMetaFromItems(result.menuItems), selectedKeys: stringedOpenedKeys };
34143
+ };
34144
+
34145
+ const ResourcesListFetcher = ({ nodePath, params, onUpdate }) => {
34146
+ const { data, isLoading } = useK8sSmartResource(params);
34147
+ useEffect(() => {
34148
+ const maybeItems = data?.items;
34149
+ const preparedItems = Array.isArray(maybeItems) ? maybeItems : [];
34150
+ onUpdate({
34151
+ nodePath,
34152
+ entry: {
34153
+ items: preparedItems,
34154
+ isLoading
34155
+ }
34156
+ });
34157
+ }, [nodePath, data?.items, isLoading, onUpdate]);
34158
+ return null;
34159
+ };
34160
+ const ManageableSidebarProvider = ({
34161
+ cluster,
34162
+ apiGroup,
34163
+ apiVersion,
34164
+ plural,
34165
+ isEnabled,
34166
+ replaceValues,
34167
+ multiQueryData,
34168
+ pathname,
34169
+ searchParams,
34170
+ idToCompare,
34171
+ fallbackIdToCompare,
34172
+ currentTags,
34173
+ hidden,
34174
+ noMarginTop
34175
+ }) => {
34176
+ const safeMultiQueryData = useMemo(() => multiQueryData || {}, [multiQueryData]);
34177
+ const {
34178
+ data: rawData,
34179
+ isError: rawDataError,
34180
+ isLoading: rawDataLoading
34181
+ } = useK8sSmartResource({
34182
+ cluster,
34183
+ apiGroup,
34184
+ apiVersion,
34185
+ plural,
34186
+ isEnabled
34187
+ });
34188
+ const parsedData = rawData?.items.map(({ spec }) => spec) || [];
34189
+ const foundData = parsedData.find((el) => el.id === idToCompare) || (fallbackIdToCompare ? parsedData.find((el) => el.id === fallbackIdToCompare) : void 0);
34190
+ const linksWithResourcesList = useMemo(
34191
+ () => collectLinksWithResourcesList({
34192
+ items: foundData?.menuItems || [],
34193
+ replaceValues,
34194
+ multiQueryData: safeMultiQueryData,
34195
+ isEnabled
34196
+ }),
34197
+ [foundData?.menuItems, replaceValues, safeMultiQueryData, isEnabled]
34198
+ );
34199
+ const [resourcesByPath, setResourcesByPath] = useState({});
34200
+ useEffect(() => {
34201
+ setResourcesByPath((prev) => {
34202
+ const next = linksWithResourcesList.reduce(
34203
+ (acc, { nodePath, k8sParams }) => {
34204
+ acc[nodePath] = prev[nodePath] || { items: [], isLoading: Boolean(k8sParams.isEnabled) };
34205
+ return acc;
34206
+ },
34207
+ {}
34208
+ );
34209
+ return next;
34210
+ });
34211
+ }, [linksWithResourcesList]);
34212
+ const handleResourceUpdate = useCallback(({ nodePath, entry }) => {
34213
+ setResourcesByPath((prev) => {
34214
+ const previous = prev[nodePath];
34215
+ if (previous && previous.items === entry.items && previous.isLoading === entry.isLoading) {
34216
+ return prev;
34217
+ }
34218
+ return { ...prev, [nodePath]: entry };
34219
+ });
34220
+ }, []);
34221
+ const isResourcesLoading = linksWithResourcesList.some(({ nodePath, k8sParams }) => {
34222
+ if (!k8sParams.isEnabled) {
34223
+ return false;
34224
+ }
34225
+ return resourcesByPath[nodePath]?.isLoading !== false;
34226
+ });
34227
+ if (isResourcesLoading) {
34228
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
34229
+ linksWithResourcesList.map(({ nodePath, k8sParams }) => /* @__PURE__ */ jsxRuntimeExports.jsx(ResourcesListFetcher, { nodePath, params: k8sParams, onUpdate: handleResourceUpdate }, nodePath)),
34230
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Spin, {})
34231
+ ] });
34232
+ }
34233
+ if (rawDataError) {
34234
+ return null;
34235
+ }
34236
+ if (rawDataLoading) {
34237
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Spin, {});
34238
+ }
34239
+ if (!rawData) {
34240
+ return null;
34241
+ }
34242
+ if (hidden) {
34243
+ return null;
34244
+ }
34245
+ if (!parsedData || parsedData.length === 0) {
34246
+ return null;
34247
+ }
34248
+ if (!foundData) {
34249
+ return null;
34250
+ }
34251
+ const resourcesListData = linksWithResourcesList.reduce(
34252
+ (acc, { nodePath }) => {
34253
+ const result2 = resourcesByPath[nodePath];
34254
+ acc[nodePath] = {
34255
+ items: Array.isArray(result2?.items) ? result2.items : []
34256
+ };
34257
+ return acc;
34258
+ },
34259
+ {}
34260
+ );
34261
+ const result = prepareDataForManageableSidebar({
34262
+ data: parsedData,
34263
+ replaceValues,
34264
+ multiQueryData: safeMultiQueryData,
34265
+ pathname,
34266
+ searchParams,
34267
+ idToCompare,
34268
+ fallbackIdToCompare,
34269
+ currentTags,
34270
+ resourcesListData
34271
+ });
34272
+ if (!result) {
34273
+ return null;
34274
+ }
34275
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
34276
+ linksWithResourcesList.map(({ nodePath, k8sParams }) => /* @__PURE__ */ jsxRuntimeExports.jsx(ResourcesListFetcher, { nodePath, params: k8sParams, onUpdate: handleResourceUpdate }, nodePath)),
34277
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ManageableSidebar, { data: result, noMarginTop })
34278
+ ] });
34279
+ };
34280
+
33950
34281
  const ShortenedText = styled.div`
33951
34282
  max-width: ${({ $maxWidth }) => $maxWidth}px;
33952
34283
  overflow: hidden;
@@ -34593,141 +34924,6 @@ const partsOfUrlContext = createContextFactory();
34593
34924
  const PartsOfUrlProvider = partsOfUrlContext.Provider;
34594
34925
  const usePartsOfUrl = partsOfUrlContext.useTypedContext;
34595
34926
 
34596
- const parsePartsOfUrl = ({
34597
- template,
34598
- replaceValues
34599
- }) => {
34600
- return prepareTemplate({ template, replaceValues });
34601
- };
34602
- const parseMutliqueryText = ({
34603
- text,
34604
- multiQueryData,
34605
- customFallback
34606
- }) => {
34607
- if (!text) {
34608
- return "";
34609
- }
34610
- return text.replace(
34611
- /\{reqs\[(\d+)\]\[((?:\s*['"][^'"]+['"]\s*,?)+)\](?:\[\s*['"]([^'"]+)['"]\s*\])?\}/g,
34612
- (_match, reqIndexStr, rawPath, fallback) => {
34613
- try {
34614
- const reqIndex = parseInt(reqIndexStr, 10);
34615
- const path = Array.from(rawPath.matchAll(/['"]([^'"]+)['"]/g)).map(
34616
- (m) => m[1]
34617
- );
34618
- const value = _$1.get(multiQueryData[`req${reqIndex}`] || {}, path, fallback !== void 0 ? fallback : void 0);
34619
- if (value == null && !customFallback) {
34620
- return fallback ?? "Undefined with no fallback";
34621
- }
34622
- if (customFallback && (value === void 0 || value === null)) {
34623
- return customFallback;
34624
- }
34625
- return String(value);
34626
- } catch {
34627
- return _match;
34628
- }
34629
- }
34630
- );
34631
- };
34632
- const parseJsonPathTemplate = ({
34633
- text,
34634
- multiQueryData,
34635
- customFallback,
34636
- replaceValues
34637
- }) => {
34638
- if (!text) return "";
34639
- const placeholderRegex = /\{reqsJsonPath\[(\d+)\]\s*\[\s*(['"])([\s\S]*?)\2\s*\](?:\s*\[\s*(['"])([\s\S]*?)\4\s*\])?\}/g;
34640
- const resolve = (input) => input.replace(
34641
- placeholderRegex,
34642
- (match, reqIndexStr, _quote, rawJsonPathExpr, _fallbackQuote, inlineFallback = "Undefined with no fallback") => {
34643
- try {
34644
- const reqIndex = Number(reqIndexStr);
34645
- const jsonRoot = multiQueryData[`req${reqIndex}`];
34646
- let jsonPathExpr = rawJsonPathExpr;
34647
- let previous2 = null;
34648
- let loopGuard = 0;
34649
- while (previous2 !== jsonPathExpr && loopGuard < 10) {
34650
- previous2 = jsonPathExpr;
34651
- jsonPathExpr = resolve(jsonPathExpr);
34652
- loopGuard++;
34653
- }
34654
- if (replaceValues) {
34655
- jsonPathExpr = prepareTemplate({
34656
- template: jsonPathExpr,
34657
- replaceValues
34658
- });
34659
- }
34660
- if (jsonRoot === void 0 && customFallback) return customFallback;
34661
- if (jsonRoot === void 0) return inlineFallback;
34662
- const results = jp.query(jsonRoot, `$${jsonPathExpr}`);
34663
- const value = results?.[0];
34664
- if (value == null) {
34665
- return customFallback ?? inlineFallback;
34666
- }
34667
- return String(value);
34668
- } catch {
34669
- return match;
34670
- }
34671
- }
34672
- );
34673
- let result = text;
34674
- let previous = null;
34675
- let iterations = 0;
34676
- while (result !== previous && iterations < 10) {
34677
- previous = result;
34678
- result = resolve(result);
34679
- iterations++;
34680
- }
34681
- return result;
34682
- };
34683
- const parseWithoutPartsOfUrl = ({
34684
- text,
34685
- multiQueryData,
34686
- customFallback
34687
- }) => {
34688
- return parseJsonPathTemplate({
34689
- text: parseMutliqueryText({
34690
- text,
34691
- multiQueryData,
34692
- customFallback
34693
- }),
34694
- multiQueryData,
34695
- customFallback
34696
- });
34697
- };
34698
- const parseAll = ({
34699
- text,
34700
- replaceValues,
34701
- multiQueryData
34702
- }) => {
34703
- return parsePartsOfUrl({
34704
- template: parseJsonPathTemplate({
34705
- text: parseMutliqueryText({
34706
- text,
34707
- multiQueryData
34708
- }),
34709
- multiQueryData,
34710
- replaceValues
34711
- }),
34712
- replaceValues
34713
- });
34714
- };
34715
- const parsePromTemplate = ({
34716
- text,
34717
- replaceValues,
34718
- multiQueryData
34719
- }) => {
34720
- const parsed = parseJsonPathTemplate({
34721
- text: parseMutliqueryText({
34722
- text,
34723
- multiQueryData
34724
- }),
34725
- multiQueryData,
34726
- replaceValues
34727
- });
34728
- return parsed.replace(/\{(\d+)\}/g, (_2, key) => replaceValues[key] || "");
34729
- };
34730
-
34731
34927
  const isExternalHref = (href) => {
34732
34928
  if (!href) {
34733
34929
  return false;
@@ -77970,7 +78166,7 @@ const TolerationsModal = ({
77970
78166
  };
77971
78167
 
77972
78168
  const LazyEnrichedTableModal = lazy(
77973
- () => import('./index-BOKNPmwt.mjs').then((mod) => ({ default: mod.EnrichedTableModal }))
78169
+ () => import('./index-DPPcb4Gw.mjs').then((mod) => ({ default: mod.EnrichedTableModal }))
77974
78170
  );
77975
78171
  const renderActiveType = (activeType, extraProps) => {
77976
78172
  if (!activeType) return null;
@@ -89033,4 +89229,4 @@ const usePluginManifest = ({
89033
89229
  };
89034
89230
 
89035
89231
  export { useInfiniteSentinel as $, getBuiltinResourceTypes as A, getCrdData as B, getDirectUnknownResource as C, DeleteIcon as D, EnrichedTableProvider as E, checkPermission as F, getSwagger as G, filterIfApiInstanceNamespaceScoped as H, filterIfBuiltInInstanceNamespaceScoped as I, checkIfApiInstanceNamespaceScoped as J, checkIfBuiltInInstanceNamespaceScoped as K, getKinds as L, useClusterList as M, useApiResources as N, useApiResourceSingle as O, PaddingContainer as P, useBuiltinResources as Q, ReadOnlyModal as R, useBuiltinResourceSingle as S, useCrdResources as T, useCrdResourceSingle as U, useApisResourceTypes as V, useApiResourceTypesByGroup as W, useBuiltinResourceTypes as X, useCrdData as Y, useListWatch as Z, _$1 as _, useTheme as a, parseQuotaValueMemoryAndStorage as a$, useK8sVerbs as a0, useManyK8sSmartResource as a1, useSmartResourceParams as a2, useResourceScope as a3, useKinds as a4, usePluginManifest as a5, Spacer$1 as a6, TreeWithSearch as a7, ConfirmModal as a8, UpIcon as a9, EnrichedTable as aA, getEnrichedColumns as aB, getEnrichedColumnsWithControls as aC, YamlEditorSingleton$1 as aD, BlackholeFormProvider as aE, BlackholeForm as aF, getObjectFormItemsDraft as aG, MarketPlace as aH, MarketplaceCard as aI, ProjectInfoCard as aJ, PodTerminal as aK, NodeTerminal as aL, PodLogs as aM, PodLogsMonaco as aN, VMVNC as aO, Search as aP, Events as aQ, DynamicRenderer as aR, DynamicComponents as aS, DynamicRendererWithProviders as aT, prepareTemplate as aU, isFlatObject as aV, filterSelectOptions as aW, getStringByName as aX, floorToDecimal as aY, parseQuotaValue as aZ, parseQuotaValueCpu as a_, DownIcon as aa, BackToDefaultIcon as ab, SuccessIcon as ac, feedbackIcons as ad, PlusIcon as ae, MinusIcon as af, LockedIcon as ag, UnlockedIcon as ah, PauseCircleIcon as ai, ResumeCircleIcon as aj, LookingGlassIcon as ak, EarthIcon as al, ContentCard$1 as am, FlexGrow as an, UncontrolledSelect as ao, CustomSelect$4 as ap, CursorPointerTag as aq, CursorPointerTagMinContent as ar, CursorDefaultDiv as as, ResourceLink as at, ManageableBreadcrumbsProvider as au, prepareDataForManageableBreadcrumbs as av, ManageableBreadcrumbs as aw, ManageableSidebarProvider as ax, prepareDataForManageableSidebar as ay, ManageableSidebar as az, usePartsOfUrl as b, normalizeValuesForQuotasToNumber as b0, getAllPathsFromObj as b1, getPrefixSubarrays as b2, groupsToTreeData as b3, getBuiltinTreeData as b4, getGroupsByCategory as b5, createContextFactory as b6, prepareUrlsToFetchForDynamicRenderer as b7, deepMerge as b8, getSortedKinds as b9, getSortedKindsAll as ba, hslFromString as bb, getUppercase as bc, kindByGvr as bd, pluralByKind as be, namespacedByGvr as bf, getLinkToBuiltinForm as bg, getLinkToApiForm as bh, isMultilineString as bi, isMultilineFromYaml as bj, includesArray as bk, getResourceLink as bl, getNamespaceLink as bm, convertBytes as bn, formatBytesAuto as bo, toBytes as bp, convertStorage as bq, parseValueWithUnit as br, convertCores as bs, formatCoresAuto as bt, toCores as bu, convertCompute as bv, parseCoresWithUnit as bw, formatDateAuto as bx, isValidRFC3339 as by, usePermissions as c, useDirectUnknownResource as d, useK8sSmartResource as e, jsxRuntimeExports as f, EditIcon as g, getLinkToForm as h, DeleteModal as i, jp as j, DeleteModalMany as k, getClusterList as l, createNewEntry as m, updateEntry as n, deleteEntry as o, parseAll as p, getApiResources as q, getApiResourceSingle as r, serializeLabelsWithNoEncoding$1 as s, getBuiltinResources as t, useMultiQuery as u, getBuiltinResourceSingle as v, getCrdResources as w, getCrdResourceSingle as x, getApiResourceTypes as y, getApiResourceTypesByApiGroup as z };
89036
- //# sourceMappingURL=index-bpfCtuwB.mjs.map
89232
+ //# sourceMappingURL=index-DGEm7Wqt.mjs.map