@prorobotech/openapi-k8s-toolkit 1.4.0-alpha.10 → 1.4.0-alpha.12

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.
@@ -1593,7 +1593,7 @@
1593
1593
  justify-content: center;
1594
1594
  }
1595
1595
  `;
1596
- const Styled$J = {
1596
+ const Styled$K = {
1597
1597
  CustomTreeProvider
1598
1598
  };
1599
1599
 
@@ -1658,7 +1658,7 @@
1658
1658
  });
1659
1659
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1660
1660
  /* @__PURE__ */ jsxRuntimeExports.jsx(Search$1, { style: { marginBottom: 8 }, placeholder: "Search", onChange }),
1661
- /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$J.CustomTreeProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1661
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$K.CustomTreeProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1662
1662
  antd.Tree,
1663
1663
  {
1664
1664
  treeData: loop(treeData),
@@ -8258,14 +8258,14 @@
8258
8258
  display: ${({ $displayFlex }) => $displayFlex ? "flex" : "block"};
8259
8259
  flex-flow: ${({ $flexFlow }) => $flexFlow};
8260
8260
  `;
8261
- const Styled$I = {
8261
+ const Styled$J = {
8262
8262
  ContentContainer
8263
8263
  };
8264
8264
 
8265
8265
  const ContentCard$1 = ({ children, flexGrow, displayFlex, flexFlow, maxHeight }) => {
8266
8266
  const { token } = antd.theme.useToken();
8267
8267
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
8268
- Styled$I.ContentContainer,
8268
+ Styled$J.ContentContainer,
8269
8269
  {
8270
8270
  $flexGrow: flexGrow,
8271
8271
  $bgColor: token.colorBgContainer,
@@ -8326,13 +8326,13 @@
8326
8326
  padding-inline: 8px;
8327
8327
  }
8328
8328
  `;
8329
- const Styled$H = {
8329
+ const Styled$I = {
8330
8330
  UncontrolledSelect: UncontrolledSelect$1
8331
8331
  };
8332
8332
 
8333
8333
  const UncontrolledSelect = (props) => {
8334
8334
  const { isCursorPointer } = props;
8335
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$H.UncontrolledSelect, { ...props, $isCursorPointer: isCursorPointer });
8335
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$I.UncontrolledSelect, { ...props, $isCursorPointer: isCursorPointer });
8336
8336
  };
8337
8337
 
8338
8338
  const CustomSelect$5 = styled(antd.Select)`
@@ -8380,13 +8380,13 @@
8380
8380
  margin-block: 0 !important;
8381
8381
  }
8382
8382
  `;
8383
- const Styled$G = {
8383
+ const Styled$H = {
8384
8384
  CustomSelect: CustomSelect$5
8385
8385
  };
8386
8386
 
8387
8387
  const CustomSelect$4 = (props) => {
8388
8388
  const { paddingContainerEnd, ...rest } = props;
8389
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$G.CustomSelect, { $paddingContainerEnd: paddingContainerEnd, ...rest });
8389
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$H.CustomSelect, { $paddingContainerEnd: paddingContainerEnd, ...rest });
8390
8390
  };
8391
8391
 
8392
8392
  const CursorPointerTag = styled(antd.Tag)`
@@ -8533,7 +8533,7 @@
8533
8533
  height: min-content;
8534
8534
  margin-right: 4px;
8535
8535
  `;
8536
- const Styled$F = {
8536
+ const Styled$G = {
8537
8537
  Abbr: Abbr$2
8538
8538
  };
8539
8539
 
@@ -8573,7 +8573,7 @@
8573
8573
  baseFactoriesMapping
8574
8574
  });
8575
8575
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Flex, { align: "center", gap: 8, children: [
8576
- /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$F.Abbr, { $bgColor: bgColor, children: abbr }),
8576
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$G.Abbr, { $bgColor: bgColor, children: abbr }),
8577
8577
  resourceLink ? /* @__PURE__ */ jsxRuntimeExports.jsx(
8578
8578
  antd.Typography.Link,
8579
8579
  {
@@ -8612,7 +8612,7 @@
8612
8612
  flex-wrap: nowrap !important;
8613
8613
  }
8614
8614
  `;
8615
- const Styled$E = {
8615
+ const Styled$F = {
8616
8616
  PositionRelativeContainer,
8617
8617
  FullWidthContainer,
8618
8618
  NoWrapContainer
@@ -8655,9 +8655,9 @@
8655
8655
  };
8656
8656
  return [firstItem, ellipsisItem, lastItem];
8657
8657
  };
8658
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled$E.PositionRelativeContainer, { children: [
8659
- /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$E.FullWidthContainer, { ref: containerRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Breadcrumb, { separator: ">", items: renderItems() }) }),
8660
- /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$E.NoWrapContainer, { ref: breadcrumbRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Breadcrumb, { separator: ">", items, style: { display: "flex", flexWrap: "nowrap" } }) })
8658
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled$F.PositionRelativeContainer, { children: [
8659
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$F.FullWidthContainer, { ref: containerRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Breadcrumb, { separator: ">", items: renderItems() }) }),
8660
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$F.NoWrapContainer, { ref: breadcrumbRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Breadcrumb, { separator: ">", items, style: { display: "flex", flexWrap: "nowrap" } }) })
8661
8661
  ] });
8662
8662
  };
8663
8663
 
@@ -8665,12 +8665,12 @@
8665
8665
  min-height: 22px;
8666
8666
  width: 100%;
8667
8667
  `;
8668
- const Styled$D = {
8668
+ const Styled$E = {
8669
8669
  HeightDiv: HeightDiv$1
8670
8670
  };
8671
8671
 
8672
8672
  const ManageableBreadcrumbs = ({ data }) => {
8673
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$D.HeightDiv, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CollapsibleBreadcrumb, { items: data.breadcrumbItems }) });
8673
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$E.HeightDiv, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CollapsibleBreadcrumb, { items: data.breadcrumbItems }) });
8674
8674
  };
8675
8675
 
8676
8676
  const kindByGvr = (entries) => (gvr) => {
@@ -9657,7 +9657,7 @@
9657
9657
  min-height: 22px;
9658
9658
  width: 100%;
9659
9659
  `;
9660
- const Styled$C = {
9660
+ const Styled$D = {
9661
9661
  HeightDiv
9662
9662
  };
9663
9663
 
@@ -9687,7 +9687,7 @@
9687
9687
  return null;
9688
9688
  }
9689
9689
  if (rawDataLoading) {
9690
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$C.HeightDiv, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Spin, {}) });
9690
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$D.HeightDiv, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Spin, {}) });
9691
9691
  }
9692
9692
  if (!rawData) {
9693
9693
  return null;
@@ -9703,7 +9703,7 @@
9703
9703
  fallbackIdToCompare
9704
9704
  });
9705
9705
  if (!result) {
9706
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$C.HeightDiv, {});
9706
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$D.HeightDiv, {});
9707
9707
  }
9708
9708
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ManageableBreadcrumbs, { data: result }, JSON.stringify(idToCompare));
9709
9709
  };
@@ -9731,7 +9731,7 @@
9731
9731
  margin: 0 !important;
9732
9732
  }
9733
9733
  `;
9734
- const Styled$B = {
9734
+ const Styled$C = {
9735
9735
  CustomMenu
9736
9736
  };
9737
9737
 
@@ -9758,7 +9758,7 @@
9758
9758
  setSelectedKeys(data.selectedKeys);
9759
9759
  }, [data.selectedKeys]);
9760
9760
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
9761
- Styled$B.CustomMenu,
9761
+ Styled$C.CustomMenu,
9762
9762
  {
9763
9763
  selectedKeys,
9764
9764
  onSelect: () => {
@@ -34299,7 +34299,7 @@
34299
34299
  white-space: nowrap;
34300
34300
  text-overflow: ellipsis;
34301
34301
  `;
34302
- const Styled$A = {
34302
+ const Styled$B = {
34303
34303
  ShortenedText
34304
34304
  };
34305
34305
 
@@ -34308,7 +34308,7 @@
34308
34308
  const trimmedText = text.substring(0, trimLength);
34309
34309
  return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Tooltip, { title: text, placement: "top", children: trimmedText });
34310
34310
  }
34311
- return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Tooltip, { title: text, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$A.ShortenedText, { $maxWidth: maxWidth, children: text }) });
34311
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Tooltip, { title: text, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$B.ShortenedText, { $maxWidth: maxWidth, children: text }) });
34312
34312
  };
34313
34313
 
34314
34314
  const FilterDropdown = ({
@@ -34444,18 +34444,48 @@
34444
34444
  text-align: ${({ $align }) => $align};
34445
34445
  `;
34446
34446
 
34447
+ const TableTag = styled(antd.Tag)`
34448
+ margin: 0;
34449
+ flex-shrink: 0;
34450
+ `;
34451
+ const TooltipTagsContainer = styled(antd.Flex)`
34452
+ max-width: min(95vw, 900px);
34453
+ min-width: min(60vw, 320px);
34454
+ `;
34455
+ const TooltipTag = styled(antd.Tag)`
34456
+ margin: 0;
34457
+ width: 100%;
34458
+ white-space: nowrap;
34459
+ overflow: hidden;
34460
+ text-overflow: ellipsis;
34461
+ `;
34462
+ const Styled$A = {
34463
+ TableTag,
34464
+ TooltipTagsContainer,
34465
+ TooltipTag
34466
+ };
34467
+
34447
34468
  const TrimmedTags = ({ tags, trimLength }) => {
34448
- const renderTags = (tags2) => tags2.map((tag) => /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Tag, { style: { margin: 0, flexShrink: 0 }, children: tag }, tag));
34469
+ const renderTableTags = (tags2) => tags2.map((tag) => /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$A.TableTag, { children: tag }, tag));
34470
+ const popoverTheme = { components: { Popover: { zIndexPopup: 2100 } } };
34471
+ const renderTooltipTags = (tags2) => /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$A.TooltipTagsContainer, { vertical: true, gap: 4, children: tags2.map((tag) => /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$A.TooltipTag, { children: tag }, tag)) });
34449
34472
  if (trimLength && trimLength < tags.length) {
34450
34473
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Flex, { wrap: "nowrap", gap: "4px", children: [
34451
- renderTags(tags.slice(0, trimLength)),
34452
- /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Tooltip, { title: /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: renderTags(tags.slice(trimLength)) }), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Tag, { children: [
34453
- "+",
34454
- tags.length - trimLength
34455
- ] }, "more") })
34474
+ renderTableTags(tags.slice(0, trimLength)),
34475
+ /* @__PURE__ */ jsxRuntimeExports.jsx(antd.ConfigProvider, { theme: popoverTheme, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
34476
+ antd.Popover,
34477
+ {
34478
+ content: renderTooltipTags(tags.slice(trimLength)),
34479
+ styles: { root: { maxWidth: "min(95vw, 900px)" } },
34480
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled$A.TableTag, { children: [
34481
+ "+",
34482
+ tags.length - trimLength
34483
+ ] }, "more")
34484
+ }
34485
+ ) })
34456
34486
  ] });
34457
34487
  }
34458
- return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Flex, { wrap: "nowrap", gap: "4px", children: renderTags(tags) });
34488
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Flex, { wrap: "nowrap", gap: "4px", children: renderTableTags(tags) });
34459
34489
  };
34460
34490
 
34461
34491
  const isFlatObject = (obj) => {
@@ -35025,8 +35055,100 @@
35025
35055
  data,
35026
35056
  children
35027
35057
  }) => {
35028
- const { id, ...tabsProps } = data;
35029
- return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Tabs, { ...tabsProps, children });
35058
+ const { id, syncActiveKeyWithHash, allowOpenInNewBrowserTab, unmountOnTabChange, ...tabsProps } = data;
35059
+ const destroyOnHidden = unmountOnTabChange ?? tabsProps.destroyOnHidden ?? true;
35060
+ const tabKeys = React$1.useMemo(
35061
+ () => (tabsProps.items || []).map((item) => item?.key).filter((key) => typeof key === "string"),
35062
+ [tabsProps.items]
35063
+ );
35064
+ const [hashActiveKey, setHashActiveKey] = React$1.useState(() => {
35065
+ if (typeof window === "undefined") return void 0;
35066
+ const hashValue = decodeURIComponent(window.location.hash.replace(/^#/, ""));
35067
+ return hashValue || void 0;
35068
+ });
35069
+ const tabItemsWithLinks = React$1.useMemo(() => {
35070
+ if (!allowOpenInNewBrowserTab || !tabsProps.items || typeof window === "undefined") {
35071
+ return tabsProps.items;
35072
+ }
35073
+ return tabsProps.items.map((item) => {
35074
+ const tabKey = item?.key !== void 0 && item?.key !== null ? String(item.key) : "";
35075
+ if (!tabKey) return item;
35076
+ const href = `${window.location.pathname}${window.location.search}#${encodeURIComponent(tabKey)}`;
35077
+ return {
35078
+ ...item,
35079
+ label: /* @__PURE__ */ jsxRuntimeExports.jsx(
35080
+ "a",
35081
+ {
35082
+ href,
35083
+ target: "_blank",
35084
+ rel: "noopener noreferrer",
35085
+ style: { color: "inherit", textDecoration: "none" },
35086
+ onClick: (event) => {
35087
+ if (event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey) {
35088
+ event.preventDefault();
35089
+ }
35090
+ },
35091
+ children: item.label
35092
+ }
35093
+ )
35094
+ };
35095
+ });
35096
+ }, [allowOpenInNewBrowserTab, tabsProps.items]);
35097
+ const updateUrlHash = (nextKey) => {
35098
+ if (typeof window === "undefined") return;
35099
+ const currentHash = decodeURIComponent(window.location.hash.replace(/^#/, ""));
35100
+ if (currentHash === nextKey) return;
35101
+ const oldUrl = window.location.href;
35102
+ const nextHash = `#${encodeURIComponent(nextKey)}`;
35103
+ const nextUrl = `${window.location.pathname}${window.location.search}${nextHash}`;
35104
+ window.history.replaceState(window.history.state, "", nextUrl);
35105
+ if (typeof HashChangeEvent === "function") {
35106
+ window.dispatchEvent(new HashChangeEvent("hashchange", { oldURL: oldUrl, newURL: window.location.href }));
35107
+ } else {
35108
+ window.dispatchEvent(new Event("hashchange"));
35109
+ }
35110
+ };
35111
+ React$1.useEffect(() => {
35112
+ if (!syncActiveKeyWithHash || typeof window === "undefined") {
35113
+ return void 0;
35114
+ }
35115
+ const readHashKey = () => {
35116
+ const hashValue = decodeURIComponent(window.location.hash.replace(/^#/, ""));
35117
+ setHashActiveKey(hashValue || void 0);
35118
+ };
35119
+ readHashKey();
35120
+ window.addEventListener("hashchange", readHashKey);
35121
+ return () => window.removeEventListener("hashchange", readHashKey);
35122
+ }, [syncActiveKeyWithHash]);
35123
+ const fallbackKey = (tabsProps.activeKey !== void 0 ? String(tabsProps.activeKey) : void 0) || (tabsProps.defaultActiveKey !== void 0 ? String(tabsProps.defaultActiveKey) : void 0) || tabKeys[0];
35124
+ const shouldValidateHashAgainstItems = tabKeys.length > 0;
35125
+ const isHashKeyValid = !!hashActiveKey && (!shouldValidateHashAgainstItems || tabKeys.includes(hashActiveKey));
35126
+ const resolvedActiveKey = isHashKeyValid ? hashActiveKey : fallbackKey;
35127
+ React$1.useEffect(() => {
35128
+ if (!syncActiveKeyWithHash || typeof window === "undefined") return;
35129
+ if (!resolvedActiveKey) return;
35130
+ updateUrlHash(resolvedActiveKey);
35131
+ }, [resolvedActiveKey, syncActiveKeyWithHash]);
35132
+ const onTabChange = (activeKey) => {
35133
+ tabsProps.onChange?.(activeKey);
35134
+ if (!syncActiveKeyWithHash || typeof window === "undefined") return;
35135
+ updateUrlHash(activeKey);
35136
+ setHashActiveKey(activeKey);
35137
+ };
35138
+ if (!syncActiveKeyWithHash) {
35139
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Tabs, { ...tabsProps, items: tabItemsWithLinks, destroyOnHidden, children });
35140
+ }
35141
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
35142
+ antd.Tabs,
35143
+ {
35144
+ ...tabsProps,
35145
+ items: tabItemsWithLinks,
35146
+ destroyOnHidden,
35147
+ activeKey: resolvedActiveKey,
35148
+ onChange: onTabChange,
35149
+ children
35150
+ }
35151
+ );
35030
35152
  };
35031
35153
 
35032
35154
  const AntdButton = ({
@@ -43459,14 +43581,55 @@
43459
43581
  }
43460
43582
  return null;
43461
43583
  };
43462
- const collapseManagedFieldsInEditor = (editor) => {
43584
+ const findManagedFieldsRange = (model) => {
43585
+ const startLineNumber = findManagedFieldsLine(model);
43586
+ if (startLineNumber === null) return null;
43587
+ const startLine = model.getLineContent(startLineNumber);
43588
+ const managedFieldsIndent = startLine.match(/^\s*/)?.[0].length ?? 0;
43589
+ for (let lineNumber = startLineNumber + 1; lineNumber <= model.getLineCount(); lineNumber++) {
43590
+ const line = model.getLineContent(lineNumber);
43591
+ const trimmed = line.trim();
43592
+ const indent = line.match(/^\s*/)?.[0].length ?? 0;
43593
+ if (trimmed && indent <= managedFieldsIndent) {
43594
+ const endLineNumber = lineNumber - 1;
43595
+ if (endLineNumber <= startLineNumber) return null;
43596
+ return { startLineNumber, endLineNumber };
43597
+ }
43598
+ }
43599
+ if (startLineNumber >= model.getLineCount()) return null;
43600
+ return { startLineNumber, endLineNumber: model.getLineCount() };
43601
+ };
43602
+ const collapseManagedFieldsInEditor = async (editor) => {
43463
43603
  const model = editor.getModel();
43464
- if (!model) return;
43465
- const managedFieldsLine = findManagedFieldsLine(model);
43466
- if (managedFieldsLine === null) return;
43467
- if (managedFieldsLine >= model.getLineCount()) return;
43468
- editor.setPosition({ lineNumber: managedFieldsLine, column: 1 });
43469
- editor.trigger("managed-fields-collapse", "editor.fold", null);
43604
+ if (!model) return false;
43605
+ const range = findManagedFieldsRange(model);
43606
+ if (!range) return false;
43607
+ const managedFieldsLine = range.startLineNumber;
43608
+ const foldingController = editor.getContribution?.(
43609
+ "editor.contrib.folding"
43610
+ );
43611
+ if (!foldingController?.getFoldingModel) {
43612
+ editor.trigger("managed-fields-collapse", "editor.fold", {
43613
+ selectionLines: [managedFieldsLine],
43614
+ levels: 1,
43615
+ direction: "down"
43616
+ });
43617
+ return true;
43618
+ }
43619
+ const foldingModel = await foldingController.getFoldingModel();
43620
+ if (!foldingModel) return false;
43621
+ const { regions } = foldingModel;
43622
+ let managedFieldsRegionIndex = -1;
43623
+ for (let index = 0; index < regions.length; index++) {
43624
+ if (regions.getStartLineNumber(index) === managedFieldsLine) {
43625
+ managedFieldsRegionIndex = index;
43626
+ break;
43627
+ }
43628
+ }
43629
+ if (managedFieldsRegionIndex === -1) return false;
43630
+ if (regions.isCollapsed(managedFieldsRegionIndex)) return true;
43631
+ foldingModel.toggleCollapseState([{ regionIndex: managedFieldsRegionIndex }]);
43632
+ return regions.isCollapsed(managedFieldsRegionIndex);
43470
43633
  };
43471
43634
 
43472
43635
  const NOTIFICATION_KEY = "yaml-data-changed";
@@ -43496,18 +43659,43 @@
43496
43659
  const latestPrefillYamlRef = React$1.useRef(null);
43497
43660
  const firstLoadRef = React$1.useRef(true);
43498
43661
  const editorRef = React$1.useRef(null);
43662
+ const shouldCollapseOnNextYamlRef = React$1.useRef(false);
43663
+ const collapseRetriesRef = React$1.useRef(0);
43499
43664
  const collapseManagedFieldsIfNeeded = React$1.useCallback(() => {
43500
43665
  const editor = editorRef.current;
43501
- if (!editor) return;
43502
- collapseManagedFieldsInEditor(editor);
43666
+ if (!editor) return Promise.resolve(false);
43667
+ return collapseManagedFieldsInEditor(editor);
43668
+ }, []);
43669
+ const setYamlDataWithManagedFieldsCollapsed = React$1.useCallback((nextYaml) => {
43670
+ shouldCollapseOnNextYamlRef.current = true;
43671
+ collapseRetriesRef.current = 0;
43672
+ setYamlData(nextYaml);
43503
43673
  }, []);
43674
+ const tryCollapseManagedFields = React$1.useCallback(() => {
43675
+ if (!shouldCollapseOnNextYamlRef.current) return;
43676
+ const MAX_RETRIES = 10;
43677
+ const RETRY_DELAY_MS = 50;
43678
+ setTimeout(() => {
43679
+ collapseManagedFieldsIfNeeded().then((collapsed) => {
43680
+ if (collapsed) {
43681
+ shouldCollapseOnNextYamlRef.current = false;
43682
+ collapseRetriesRef.current = 0;
43683
+ return;
43684
+ }
43685
+ collapseRetriesRef.current += 1;
43686
+ if (collapseRetriesRef.current <= MAX_RETRIES) {
43687
+ tryCollapseManagedFields();
43688
+ }
43689
+ });
43690
+ }, RETRY_DELAY_MS);
43691
+ }, [collapseManagedFieldsIfNeeded]);
43504
43692
  const handleReload = React$1.useCallback(() => {
43505
43693
  api.destroy(NOTIFICATION_KEY);
43506
43694
  const nextYaml = latestPrefillYamlRef.current ?? initialPrefillYamlRef.current;
43507
43695
  if (nextYaml !== null) {
43508
- setYamlData(nextYaml);
43696
+ setYamlDataWithManagedFieldsCollapsed(nextYaml);
43509
43697
  }
43510
- }, [api]);
43698
+ }, [api, setYamlDataWithManagedFieldsCollapsed]);
43511
43699
  const openNotificationYamlChanged = React$1.useCallback(() => {
43512
43700
  const btn = /* @__PURE__ */ jsxRuntimeExports.jsx(
43513
43701
  antd.Button,
@@ -43535,7 +43723,7 @@
43535
43723
  if (firstLoadRef.current) {
43536
43724
  initialPrefillYamlRef.current = nextYaml;
43537
43725
  latestPrefillYamlRef.current = nextYaml;
43538
- setYamlData(nextYaml);
43726
+ setYamlDataWithManagedFieldsCollapsed(nextYaml);
43539
43727
  firstLoadRef.current = false;
43540
43728
  return;
43541
43729
  }
@@ -43543,13 +43731,12 @@
43543
43731
  openNotificationYamlChanged();
43544
43732
  }
43545
43733
  latestPrefillYamlRef.current = nextYaml;
43546
- }, [prefillValuesSchema, openNotificationYamlChanged]);
43734
+ }, [prefillValuesSchema, openNotificationYamlChanged, setYamlDataWithManagedFieldsCollapsed]);
43547
43735
  React$1.useEffect(() => {
43548
- const id = setTimeout(() => {
43549
- collapseManagedFieldsIfNeeded();
43550
- }, 0);
43551
- return () => clearTimeout(id);
43552
- }, [yamlData, collapseManagedFieldsIfNeeded]);
43736
+ if (!shouldCollapseOnNextYamlRef.current) return void 0;
43737
+ tryCollapseManagedFields();
43738
+ return void 0;
43739
+ }, [yamlData, tryCollapseManagedFields]);
43553
43740
  const onSubmit = () => {
43554
43741
  setIsLoading(true);
43555
43742
  setError(void 0);
@@ -43609,9 +43796,9 @@
43609
43796
  value: yamlData,
43610
43797
  onMount: (editor) => {
43611
43798
  editorRef.current = editor;
43612
- setTimeout(() => {
43613
- collapseManagedFieldsIfNeeded();
43614
- }, 0);
43799
+ if (shouldCollapseOnNextYamlRef.current) {
43800
+ tryCollapseManagedFields();
43801
+ }
43615
43802
  },
43616
43803
  onChange: (value) => {
43617
43804
  if (!readOnly) {
@@ -79512,7 +79699,9 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
79512
79699
  icon: getActionIcon(action),
79513
79700
  disabled: action.props.disabled || isActionDisabledByPermission(actionKey, permissions),
79514
79701
  danger: action.props.danger,
79515
- onClick: () => onActionClick(action)
79702
+ onClick: () => {
79703
+ onActionClick(action);
79704
+ }
79516
79705
  }));
79517
79706
 
79518
79707
  const parseValueIfString = (value, ctx) => {
@@ -79829,6 +80018,96 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
79829
80018
  };
79830
80019
  return { rerunModalData, isRerunLoading, handleRerunLastAction, handleRerunConfirm, handleRerunCancel };
79831
80020
  };
80021
+ const MAX_FAILED_PODS_SHOWN = 5;
80022
+ const buildDrainFailureDescription = ({ drained, failed, skipped }) => {
80023
+ const lines = [`Evicted ${drained}, skipped ${skipped}, failed ${failed.length}`];
80024
+ const shown = failed.slice(0, MAX_FAILED_PODS_SHOWN);
80025
+ shown.forEach((pod) => {
80026
+ lines.push(React$1.createElement("br", null), `${pod.namespace}/${pod.name}: ${pod.error}`);
80027
+ });
80028
+ if (failed.length > MAX_FAILED_PODS_SHOWN) {
80029
+ lines.push(React$1.createElement("br", null), `+${failed.length - MAX_FAILED_PODS_SHOWN} more`);
80030
+ }
80031
+ return React$1.createElement(React$1.Fragment, null, ...lines);
80032
+ };
80033
+ const useDrainHandlers = (ctx, { showError }, notificationApi, invalidateMultiQuery) => {
80034
+ const [drainModalData, setDrainModalData] = React$1.useState(null);
80035
+ const [isDrainLoading, setIsDrainLoading] = React$1.useState(false);
80036
+ const handleDrainAction = (action) => {
80037
+ const bffEndpointPrepared = parseAll({ text: action.props.bffEndpoint, ...ctx });
80038
+ const nodeNamePrepared = parseAll({ text: action.props.nodeName, ...ctx });
80039
+ setDrainModalData({ bffEndpoint: bffEndpointPrepared, nodeName: nodeNamePrepared });
80040
+ };
80041
+ const handleDrainConfirm = () => {
80042
+ if (!drainModalData) return;
80043
+ setIsDrainLoading(true);
80044
+ const drainLabel = `Drain ${drainModalData.nodeName}`;
80045
+ axios.post(drainModalData.bffEndpoint, {
80046
+ nodeName: drainModalData.nodeName,
80047
+ apiPath: `/api/v1/nodes/${drainModalData.nodeName}`
80048
+ }).then((response) => {
80049
+ invalidateMultiQuery();
80050
+ const { drained, failed, skipped } = response.data;
80051
+ if (failed.length > 0) {
80052
+ notificationApi.warning({
80053
+ message: `${drainLabel} partially completed`,
80054
+ description: buildDrainFailureDescription({ drained, failed, skipped }),
80055
+ placement: "bottomRight",
80056
+ duration: 0
80057
+ });
80058
+ } else {
80059
+ notificationApi.success({
80060
+ message: `${drainLabel} successful`,
80061
+ description: `Evicted ${drained} pod(s), skipped ${skipped}`,
80062
+ placement: "bottomRight"
80063
+ });
80064
+ }
80065
+ }).catch((error) => {
80066
+ showError(drainLabel, error);
80067
+ }).finally(() => {
80068
+ setIsDrainLoading(false);
80069
+ setDrainModalData(null);
80070
+ });
80071
+ };
80072
+ const handleDrainCancel = () => {
80073
+ setDrainModalData(null);
80074
+ setIsDrainLoading(false);
80075
+ };
80076
+ return { drainModalData, isDrainLoading, handleDrainAction, handleDrainConfirm, handleDrainCancel };
80077
+ };
80078
+ const useRollbackHandlers = (ctx, { showSuccess, showError }) => {
80079
+ const [rollbackModalData, setRollbackModalData] = React$1.useState(null);
80080
+ const [isRollbackLoading, setIsRollbackLoading] = React$1.useState(false);
80081
+ const handleRollbackAction = (action) => {
80082
+ const bffEndpointPrepared = parseAll({ text: action.props.bffEndpoint, ...ctx });
80083
+ const resourceNamePrepared = parseAll({ text: action.props.resourceName, ...ctx });
80084
+ const resourceEndpointPrepared = parseAll({ text: action.props.resourceEndpoint, ...ctx });
80085
+ setRollbackModalData({
80086
+ bffEndpoint: bffEndpointPrepared,
80087
+ resourceName: resourceNamePrepared,
80088
+ resourceEndpoint: resourceEndpointPrepared
80089
+ });
80090
+ };
80091
+ const handleRollbackConfirm = () => {
80092
+ if (!rollbackModalData) return;
80093
+ setIsRollbackLoading(true);
80094
+ const rollbackLabel = `Rollback ${rollbackModalData.resourceName}`;
80095
+ axios.post(rollbackModalData.bffEndpoint, {
80096
+ resourceEndpoint: rollbackModalData.resourceEndpoint,
80097
+ resourceName: rollbackModalData.resourceName
80098
+ }).then(() => showSuccess(rollbackLabel)).catch((error) => {
80099
+ showError(rollbackLabel, error);
80100
+ }).finally(() => {
80101
+ setIsRollbackLoading(false);
80102
+ setRollbackModalData(null);
80103
+ });
80104
+ };
80105
+ const handleRollbackCancel = () => {
80106
+ setRollbackModalData(null);
80107
+ setIsRollbackLoading(false);
80108
+ };
80109
+ return { rollbackModalData, isRollbackLoading, handleRollbackAction, handleRollbackConfirm, handleRollbackCancel };
80110
+ };
79832
80111
  const fireTriggerRunAction = (action, ctx, multiQueryData, { showSuccess, showError }) => {
79833
80112
  const createEndpointPrepared = parseAll({ text: action.props.createEndpoint, ...ctx });
79834
80113
  const cronJobNamePrepared = parseAll({ text: action.props.cronJobName, ...ctx });
@@ -79901,6 +80180,13 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
79901
80180
  );
79902
80181
  const { evictModalData, isEvictLoading, setEvictModalData, handleEvictConfirm, handleEvictCancel } = useEvictHandlers(notificationCallbacks);
79903
80182
  const { rerunModalData, isRerunLoading, handleRerunLastAction, handleRerunConfirm, handleRerunCancel } = useRerunHandlers(ctx, multiQueryData, notificationCallbacks);
80183
+ const { drainModalData, isDrainLoading, handleDrainAction, handleDrainConfirm, handleDrainCancel } = useDrainHandlers(
80184
+ ctx,
80185
+ notificationCallbacks,
80186
+ notificationApi,
80187
+ invalidateMultiQuery
80188
+ );
80189
+ const { rollbackModalData, isRollbackLoading, handleRollbackAction, handleRollbackConfirm, handleRollbackCancel } = useRollbackHandlers(ctx, notificationCallbacks);
79904
80190
  const handleDeleteChildrenAction = (action) => {
79905
80191
  try {
79906
80192
  const data = buildDeleteChildrenData(action, ctx);
@@ -79956,7 +80242,12 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
79956
80242
  handleRerunLastAction(action);
79957
80243
  return;
79958
80244
  }
79959
- if (action.type === "drain" || action.type === "rollback") {
80245
+ if (action.type === "drain") {
80246
+ handleDrainAction(action);
80247
+ return;
80248
+ }
80249
+ if (action.type === "rollback") {
80250
+ handleRollbackAction(action);
79960
80251
  return;
79961
80252
  }
79962
80253
  setActiveAction(action);
@@ -79988,6 +80279,10 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
79988
80279
  deleteChildrenModalData,
79989
80280
  rerunModalData,
79990
80281
  isRerunLoading,
80282
+ drainModalData,
80283
+ isDrainLoading,
80284
+ rollbackModalData,
80285
+ isRollbackLoading,
79991
80286
  handleActionClick,
79992
80287
  handleCloseModal,
79993
80288
  handleDeleteModalClose,
@@ -79997,7 +80292,11 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
79997
80292
  handleScaleCancel,
79998
80293
  handleDeleteChildrenClose,
79999
80294
  handleRerunConfirm,
80000
- handleRerunCancel
80295
+ handleRerunCancel,
80296
+ handleDrainConfirm,
80297
+ handleDrainCancel,
80298
+ handleRollbackConfirm,
80299
+ handleRollbackCancel
80001
80300
  };
80002
80301
  };
80003
80302
 
@@ -80277,6 +80576,10 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
80277
80576
  deleteChildrenModalData,
80278
80577
  rerunModalData,
80279
80578
  isRerunLoading,
80579
+ drainModalData,
80580
+ isDrainLoading,
80581
+ rollbackModalData,
80582
+ isRollbackLoading,
80280
80583
  handleActionClick,
80281
80584
  handleCloseModal,
80282
80585
  handleDeleteModalClose,
@@ -80286,7 +80589,11 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
80286
80589
  handleScaleCancel,
80287
80590
  handleDeleteChildrenClose,
80288
80591
  handleRerunConfirm,
80289
- handleRerunCancel
80592
+ handleRerunCancel,
80593
+ handleDrainConfirm,
80594
+ handleDrainCancel,
80595
+ handleRollbackConfirm,
80596
+ handleRollbackCancel
80290
80597
  } = useActionsDropdownHandlers({
80291
80598
  replaceValues,
80292
80599
  multiQueryData: safeMultiQueryData
@@ -80359,6 +80666,30 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
80359
80666
  children: "This will create a new Job with the same spec."
80360
80667
  }
80361
80668
  ),
80669
+ drainModalData && /* @__PURE__ */ jsxRuntimeExports.jsx(
80670
+ ConfirmModal,
80671
+ {
80672
+ title: `Drain node «${drainModalData.nodeName}»?`,
80673
+ onConfirm: handleDrainConfirm,
80674
+ onClose: handleDrainCancel,
80675
+ confirmText: "Drain",
80676
+ confirmLoading: isDrainLoading,
80677
+ danger: true,
80678
+ children: "This will cordon the node and evict all eligible pods. DaemonSet pods will be skipped."
80679
+ }
80680
+ ),
80681
+ rollbackModalData && /* @__PURE__ */ jsxRuntimeExports.jsx(
80682
+ ConfirmModal,
80683
+ {
80684
+ title: `Rollback «${rollbackModalData.resourceName}»?`,
80685
+ onConfirm: handleRollbackConfirm,
80686
+ onClose: handleRollbackCancel,
80687
+ confirmText: "Rollback",
80688
+ confirmLoading: isRollbackLoading,
80689
+ danger: true,
80690
+ children: "This will revert the resource to its previous revision."
80691
+ }
80692
+ ),
80362
80693
  children
80363
80694
  ] });
80364
80695
  };
@@ -80597,6 +80928,7 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
80597
80928
  additionalPrinterColumnsUndefinedValues,
80598
80929
  additionalPrinterColumnsTrimLengths,
80599
80930
  additionalPrinterColumnsColWidths,
80931
+ additionalPrinterColumnsTooltips,
80600
80932
  additionalPrinterColumnsKeyTypeProps,
80601
80933
  additionalPrinterColumnsCustomSortersAndFilters,
80602
80934
  theme,
@@ -80614,6 +80946,7 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
80614
80946
  const possibleUndefinedValue = additionalPrinterColumnsUndefinedValues?.find(({ key }) => key === el.key)?.value;
80615
80947
  const possibleTrimLength = additionalPrinterColumnsTrimLengths?.find(({ key }) => key === el.key)?.value;
80616
80948
  const possibleColWidth = additionalPrinterColumnsColWidths?.find(({ key }) => key === el.key)?.value;
80949
+ const possibleTooltip = additionalPrinterColumnsTooltips?.find(({ key }) => key === el.key)?.value;
80617
80950
  const possibleCustomTypeWithProps = additionalPrinterColumnsKeyTypeProps && el.key ? additionalPrinterColumnsKeyTypeProps[el.key.toString()] : void 0;
80618
80951
  const useFactorySearch = possibleCustomTypeWithProps?.type === "factory";
80619
80952
  const colKey = el.key != null && String(el.key) || (Array.isArray(el.dataIndex) ? el.dataIndex.join(".") : String(el.dataIndex ?? colIndex));
@@ -80654,8 +80987,22 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
80654
80987
  if (bNaN) return -1;
80655
80988
  return a - b;
80656
80989
  };
80990
+ const columnTitle = possibleTooltip && typeof el.title !== "function" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Flex, { align: "center", gap: 4, children: [
80991
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: el.title || String(el.key || "") }),
80992
+ /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Tooltip, { title: possibleTooltip, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
80993
+ "span",
80994
+ {
80995
+ onClick: (e) => e.stopPropagation(),
80996
+ onMouseDown: (e) => e.stopPropagation(),
80997
+ onKeyDown: (e) => e.stopPropagation(),
80998
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(AntIcons.QuestionCircleOutlined, {})
80999
+ }
81000
+ ) })
81001
+ ] }) : el.title;
80657
81002
  return {
80658
81003
  ...el,
81004
+ title: columnTitle,
81005
+ showSorterTooltip: false,
80659
81006
  render: (value, record) => getCellRender({
80660
81007
  value,
80661
81008
  record,
@@ -80867,6 +81214,7 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
80867
81214
  additionalPrinterColumnsUndefinedValues,
80868
81215
  additionalPrinterColumnsTrimLengths,
80869
81216
  additionalPrinterColumnsColWidths,
81217
+ additionalPrinterColumnsTooltips,
80870
81218
  additionalPrinterColumnsKeyTypeProps,
80871
81219
  additionalPrinterColumnsCustomSortersAndFilters,
80872
81220
  selectData,
@@ -80883,6 +81231,7 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
80883
81231
  additionalPrinterColumnsUndefinedValues,
80884
81232
  additionalPrinterColumnsTrimLengths,
80885
81233
  additionalPrinterColumnsColWidths,
81234
+ additionalPrinterColumnsTooltips,
80886
81235
  additionalPrinterColumnsKeyTypeProps,
80887
81236
  additionalPrinterColumnsCustomSortersAndFilters,
80888
81237
  theme,
@@ -81300,6 +81649,7 @@ Take a look at the reducer(s) handling this action type: ${action.type}.
81300
81649
  additionalPrinterColumnsUndefinedValues: preparedProps.additionalPrinterColumnsUndefinedValues,
81301
81650
  additionalPrinterColumnsTrimLengths: preparedProps.additionalPrinterColumnsTrimLengths,
81302
81651
  additionalPrinterColumnsColWidths: preparedProps.additionalPrinterColumnsColWidths,
81652
+ additionalPrinterColumnsTooltips: preparedProps.additionalPrinterColumnsTooltips,
81303
81653
  additionalPrinterColumnsKeyTypeProps: preparedProps.additionalPrinterColumnsKeyTypeProps,
81304
81654
  additionalPrinterColumnsCustomSortersAndFilters: preparedProps.additionalPrinterColumnsCustomSortersAndFilters,
81305
81655
  selectData,