@prorobotech/openapi-k8s-toolkit 0.0.1-alpha.122 → 0.0.1-alpha.124

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,8 +1,8 @@
1
1
  import o, { useRef, useContext, useDebugValue, createElement, useState, useLayoutEffect, useEffect, Fragment, createContext, useMemo, isValidElement, cloneElement, useCallback, useInsertionEffect, useSyncExternalStore, memo, Suspense } from 'react';
2
- import { Input, Tree, Modal, Alert, theme, Select, Tag, Breadcrumb, Spin, Menu, Tooltip, Space, Button, Flex, Typography, Card, Row, Col, Tabs, Form, Popover, notification, Table, Slider, InputNumber, Switch, Dropdown, Result, Progress } from 'antd';
2
+ import { Input, Tree, Modal, Alert, theme, Select, Tag, Breadcrumb, Spin, Menu, Tooltip, Space, Button, Flex, Typography, Card, Row, Col, Tabs, Form, Popover, notification, Table, Slider, InputNumber, Switch, Dropdown, Result, Progress, Checkbox } from 'antd';
3
3
  import { LoadingOutlined, ExclamationCircleFilled, CloseCircleFilled, CheckCircleFilled, CaretDownOutlined, CaretRightOutlined, InfoCircleOutlined, EyeOutlined, EyeInvisibleOutlined, SearchOutlined, EditOutlined, DeleteOutlined, CheckOutlined, CloseOutlined, BugOutlined, PlusOutlined, EllipsisOutlined } from '@ant-design/icons';
4
4
  import { useQuery, useQueries, useQueryClient } from '@tanstack/react-query';
5
- import { Link, useLocation, useNavigate, useSearchParams } from 'react-router-dom';
5
+ import { Link, useLocation, useNavigate } from 'react-router-dom';
6
6
 
7
7
  function getDefaultExportFromCjs$1 (x) {
8
8
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -8295,8 +8295,8 @@ const EditIcon = () => {
8295
8295
  ) });
8296
8296
  };
8297
8297
 
8298
- const UpIcon = () => {
8299
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
8298
+ const UpIcon = ({ size }) => {
8299
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { width: size ?? 12, height: size ?? 12, viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
8300
8300
  /* @__PURE__ */ jsxRuntimeExports.jsx("g", { clipPath: "url(#clip0_186_9937)", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
8301
8301
  "path",
8302
8302
  {
@@ -8308,8 +8308,8 @@ const UpIcon = () => {
8308
8308
  ] });
8309
8309
  };
8310
8310
 
8311
- const DownIcon = () => {
8312
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
8311
+ const DownIcon = ({ size }) => {
8312
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { width: size ?? 12, height: size ?? 12, viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
8313
8313
  /* @__PURE__ */ jsxRuntimeExports.jsx("g", { clipPath: "url(#clip0_186_11488)", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
8314
8314
  "path",
8315
8315
  {
@@ -34438,7 +34438,7 @@ const PossibleHiddenContainer = st$1.div`
34438
34438
  display: ${({ $isHidden }) => $isHidden ? "none" : "block"};
34439
34439
  `;
34440
34440
 
34441
- const ResetedFormItem = st$1(Form.Item)`
34441
+ const ResetedFormItem$1 = st$1(Form.Item)`
34442
34442
  margin-bottom: 8px;
34443
34443
  `;
34444
34444
 
@@ -34598,7 +34598,7 @@ const EditModal$3 = ({
34598
34598
  inputLabel && /* @__PURE__ */ jsxRuntimeExports.jsx(CustomSizeTitle, { $designNewLayout: true, style: inputLabelStyle, children: inputLabel }),
34599
34599
  /* @__PURE__ */ jsxRuntimeExports.jsx(Spacer$1, { $space: 10, $samespace: true }),
34600
34600
  /* @__PURE__ */ jsxRuntimeExports.jsx(
34601
- ResetedFormItem,
34601
+ ResetedFormItem$1,
34602
34602
  {
34603
34603
  name: "labels",
34604
34604
  hasFeedback: true,
@@ -34894,7 +34894,7 @@ const LabelsToSearchParams = ({ data, children }) => {
34894
34894
  }
34895
34895
  const labels = Object.entries(labelsRaw).map(([key, value]) => `${key}=${value}`).join(",");
34896
34896
  const labelsEncoded = encodeURIComponent(labels);
34897
- const hrefPrepared = `${linkPrefixPrepared}?${labelsEncoded}`;
34897
+ const hrefPrepared = `${linkPrefixPrepared}${labelsEncoded}`;
34898
34898
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Typography.Link, { href: hrefPrepared, ...linkProps, children: [
34899
34899
  labels,
34900
34900
  children
@@ -34992,7 +34992,7 @@ const EditModal$2 = ({
34992
34992
  /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$l.ResetedFormList, { name: "taints", children: (fields, { add, remove }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
34993
34993
  fields.map(({ key, name, ...restField }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Row, { gutter: [16, 16], children: [
34994
34994
  /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[0], children: /* @__PURE__ */ jsxRuntimeExports.jsx(
34995
- ResetedFormItem,
34995
+ ResetedFormItem$1,
34996
34996
  {
34997
34997
  ...restField,
34998
34998
  name: [name, "key"],
@@ -35005,7 +35005,7 @@ const EditModal$2 = ({
35005
35005
  }
35006
35006
  ) }),
35007
35007
  /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[1], children: /* @__PURE__ */ jsxRuntimeExports.jsx(
35008
- ResetedFormItem,
35008
+ ResetedFormItem$1,
35009
35009
  {
35010
35010
  ...restField,
35011
35011
  name: [name, "value"],
@@ -35018,7 +35018,7 @@ const EditModal$2 = ({
35018
35018
  }
35019
35019
  ) }),
35020
35020
  /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[2], children: /* @__PURE__ */ jsxRuntimeExports.jsx(
35021
- ResetedFormItem,
35021
+ ResetedFormItem$1,
35022
35022
  {
35023
35023
  ...restField,
35024
35024
  name: [name, "effect"],
@@ -35039,7 +35039,7 @@ const EditModal$2 = ({
35039
35039
  ) }),
35040
35040
  /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[3], children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", type: "text", onClick: () => remove(name), children: /* @__PURE__ */ jsxRuntimeExports.jsx(MinusIcon, {}) }) })
35041
35041
  ] }, key)),
35042
- /* @__PURE__ */ jsxRuntimeExports.jsx(ResetedFormItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "text", size: "small", onClick: () => add(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon, {}) }) })
35042
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ResetedFormItem$1, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "text", size: "small", onClick: () => add(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon, {}) }) })
35043
35043
  ] }) })
35044
35044
  ] })
35045
35045
  ]
@@ -35327,7 +35327,7 @@ const EditModal$1 = ({
35327
35327
  /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$k.ResetedFormList, { name: "tolerations", children: (fields, { add, remove }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
35328
35328
  fields.map(({ key, name, ...restField }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Row, { gutter: [16, 16], children: [
35329
35329
  /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[0], children: /* @__PURE__ */ jsxRuntimeExports.jsx(
35330
- ResetedFormItem,
35330
+ ResetedFormItem$1,
35331
35331
  {
35332
35332
  ...restField,
35333
35333
  name: [name, "key"],
@@ -35346,7 +35346,7 @@ const EditModal$1 = ({
35346
35346
  }
35347
35347
  ) }),
35348
35348
  /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[1], children: /* @__PURE__ */ jsxRuntimeExports.jsx(
35349
- ResetedFormItem,
35349
+ ResetedFormItem$1,
35350
35350
  {
35351
35351
  ...restField,
35352
35352
  name: [name, "operator"],
@@ -35366,7 +35366,7 @@ const EditModal$1 = ({
35366
35366
  }
35367
35367
  ) }),
35368
35368
  /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[2], children: /* @__PURE__ */ jsxRuntimeExports.jsx(
35369
- ResetedFormItem,
35369
+ ResetedFormItem$1,
35370
35370
  {
35371
35371
  ...restField,
35372
35372
  name: [name, "value"],
@@ -35385,7 +35385,7 @@ const EditModal$1 = ({
35385
35385
  }
35386
35386
  ) }),
35387
35387
  /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[3], children: /* @__PURE__ */ jsxRuntimeExports.jsx(
35388
- ResetedFormItem,
35388
+ ResetedFormItem$1,
35389
35389
  {
35390
35390
  ...restField,
35391
35391
  name: [name, "effect"],
@@ -35400,7 +35400,7 @@ const EditModal$1 = ({
35400
35400
  ) }),
35401
35401
  /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[4], children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", type: "text", onClick: () => remove(name), children: /* @__PURE__ */ jsxRuntimeExports.jsx(MinusIcon, {}) }) })
35402
35402
  ] }, key)),
35403
- /* @__PURE__ */ jsxRuntimeExports.jsx(ResetedFormItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "text", size: "small", onClick: () => add(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon, {}) }) })
35403
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ResetedFormItem$1, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "text", size: "small", onClick: () => add(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon, {}) }) })
35404
35404
  ] }) })
35405
35405
  ] })
35406
35406
  ]
@@ -35694,7 +35694,7 @@ const EditModal = ({
35694
35694
  /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$j.ResetedFormList, { name: "annotations", children: (fields, { add, remove }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
35695
35695
  fields.map(({ key, name, ...restField }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Row, { gutter: [16, 16], children: [
35696
35696
  /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[0], children: /* @__PURE__ */ jsxRuntimeExports.jsx(
35697
- ResetedFormItem,
35697
+ ResetedFormItem$1,
35698
35698
  {
35699
35699
  ...restField,
35700
35700
  name: [name, "key"],
@@ -35702,10 +35702,10 @@ const EditModal = ({
35702
35702
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { placeholder: "key" })
35703
35703
  }
35704
35704
  ) }),
35705
- /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[1], children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResetedFormItem, { ...restField, name: [name, "value"], children: /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { placeholder: "value" }) }) }),
35705
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[1], children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResetedFormItem$1, { ...restField, name: [name, "value"], children: /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { placeholder: "value" }) }) }),
35706
35706
  /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: cols[2], children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", type: "text", onClick: () => remove(name), children: /* @__PURE__ */ jsxRuntimeExports.jsx(MinusIcon, {}) }) })
35707
35707
  ] }, key)),
35708
- /* @__PURE__ */ jsxRuntimeExports.jsx(ResetedFormItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "text", size: "small", onClick: () => add(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon, {}) }) })
35708
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ResetedFormItem$1, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "text", size: "small", onClick: () => add(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon, {}) }) })
35709
35709
  ] }) })
35710
35710
  ] })
35711
35711
  ]
@@ -36881,13 +36881,14 @@ const fnv1a32 = (str) => {
36881
36881
  const pickInRange = (u32, min, max) => min + u32 % (max - min + 1);
36882
36882
  const hslFromString = (value, theme) => {
36883
36883
  const hash = fnv1a32(value);
36884
- const hue = hash % 360;
36885
- const [sMin, sMax] = theme === "light" ? [5, 10] : [5, 15];
36886
- const [lMin, lMax] = theme === "light" ? [88, 94] : [18, 25];
36884
+ const hue = hash % 345;
36885
+ const [sMin, sMax] = theme === "light" ? [90, 100] : [80, 100];
36886
+ const [lMin, lMax] = theme === "light" ? [78, 80] : [35, 50];
36887
36887
  const s = pickInRange(hash >>> 8, sMin, sMax);
36888
36888
  const l = pickInRange(hash >>> 16, lMin, lMax);
36889
36889
  return `hsl(${hue}, ${s}%, ${l}%)`;
36890
36890
  };
36891
+
36891
36892
  const getUppercase = (s) => {
36892
36893
  const uppercases = [...s].filter((c) => c >= "A" && c <= "Z").join("");
36893
36894
  return uppercases.length > 0 ? uppercases : s[0].toUpperCase();
@@ -46014,7 +46015,7 @@ const FormListInput = ({
46014
46015
  ] })
46015
46016
  ] }),
46016
46017
  /* @__PURE__ */ jsxRuntimeExports.jsx(
46017
- ResetedFormItem,
46018
+ ResetedFormItem$1,
46018
46019
  {
46019
46020
  name: arrName || fixedName,
46020
46021
  rules: [{ required: forceNonRequired === false && required?.includes(getStringByName(name)) }],
@@ -46198,7 +46199,7 @@ const RangeInput = ({
46198
46199
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Row, { children: [
46199
46200
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Col, { span: 12, children: [
46200
46201
  /* @__PURE__ */ jsxRuntimeExports.jsx(
46201
- ResetedFormItem,
46202
+ ResetedFormItem$1,
46202
46203
  {
46203
46204
  name: arrName || name,
46204
46205
  rules: [{ required: forceNonRequired === false && required?.includes(getStringByName(name)) }],
@@ -46214,7 +46215,7 @@ const RangeInput = ({
46214
46215
  ] }) })
46215
46216
  ] }),
46216
46217
  /* @__PURE__ */ jsxRuntimeExports.jsx(Col, { span: 4, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
46217
- ResetedFormItem,
46218
+ ResetedFormItem$1,
46218
46219
  {
46219
46220
  name: arrName || name,
46220
46221
  rules: [{ required: forceNonRequired === false && required?.includes(getStringByName(name)) }],
@@ -46443,7 +46444,7 @@ const FormNamespaceInput = ({
46443
46444
  /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { gap: 4, children: isAdditionalProperties && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", type: "text", onClick: () => removeField({ path: name }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(MinusIcon, {}) }) })
46444
46445
  ] }),
46445
46446
  /* @__PURE__ */ jsxRuntimeExports.jsx(
46446
- ResetedFormItem,
46447
+ ResetedFormItem$1,
46447
46448
  {
46448
46449
  name,
46449
46450
  rules: [{ required: true }],
@@ -46494,7 +46495,7 @@ const FormStringInput = ({
46494
46495
  ] })
46495
46496
  ] }),
46496
46497
  /* @__PURE__ */ jsxRuntimeExports.jsx(
46497
- ResetedFormItem,
46498
+ ResetedFormItem$1,
46498
46499
  {
46499
46500
  name: arrName || fixedName,
46500
46501
  rules: [{ required: forceNonRequired === false && required?.includes(getStringByName(name)) }],
@@ -46542,7 +46543,7 @@ const FormBooleanInput = ({
46542
46543
  ] }),
46543
46544
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled$e.SwitchAndCrossContainer, { children: [
46544
46545
  /* @__PURE__ */ jsxRuntimeExports.jsx(
46545
- ResetedFormItem,
46546
+ ResetedFormItem$1,
46546
46547
  {
46547
46548
  name: arrName || name,
46548
46549
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(Switch, { size: "small" })
@@ -46594,7 +46595,7 @@ const FormEnumStringInput = ({
46594
46595
  ] })
46595
46596
  ] }),
46596
46597
  /* @__PURE__ */ jsxRuntimeExports.jsx(
46597
- ResetedFormItem,
46598
+ ResetedFormItem$1,
46598
46599
  {
46599
46600
  name: arrName || fixedName,
46600
46601
  rules: [{ required: forceNonRequired === false && required?.includes(getStringByName(name)) }],
@@ -46636,7 +46637,7 @@ const FormNumberInput = ({
46636
46637
  ] })
46637
46638
  ] }),
46638
46639
  /* @__PURE__ */ jsxRuntimeExports.jsx(
46639
- ResetedFormItem,
46640
+ ResetedFormItem$1,
46640
46641
  {
46641
46642
  name: arrName || name,
46642
46643
  rules: [{ required: forceNonRequired === false && required?.includes(getStringByName(name)) }],
@@ -47134,7 +47135,7 @@ const getArrayFormItemFromSwagger = ({
47134
47135
  })
47135
47136
  ] }, field.key);
47136
47137
  }),
47137
- /* @__PURE__ */ jsxRuntimeExports.jsxs(ResetedFormItem, { children: [
47138
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(ResetedFormItem$1, { children: [
47138
47139
  /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "text", size: "small", onClick: () => add(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon, {}) }),
47139
47140
  /* @__PURE__ */ jsxRuntimeExports.jsx(Form.ErrorList, { errors })
47140
47141
  ] })
@@ -48272,7 +48273,7 @@ const TagsContainer = st$1.div`
48272
48273
  flex-flow: row wrap;
48273
48274
  align-items: flex-start;
48274
48275
  `;
48275
- const CustomTag = st$1(Tag)`
48276
+ const CustomTag$1 = st$1(Tag)`
48276
48277
  margin-right: 4px;
48277
48278
  margin-bottom: 4px;
48278
48279
 
@@ -48295,7 +48296,7 @@ const Styled$b = {
48295
48296
  OverflowContainer,
48296
48297
  TitleContainer,
48297
48298
  TagsContainer,
48298
- CustomTag,
48299
+ CustomTag: CustomTag$1,
48299
48300
  DescriptionContainer,
48300
48301
  EditButtonContainer
48301
48302
  };
@@ -49694,75 +49695,12 @@ const PodLogsMonaco = ({
49694
49695
  ] });
49695
49696
  };
49696
49697
 
49697
- const getKinds = async ({ clusterName }) => {
49698
- const result = await axios.get(`/api/clusters/${clusterName}/openapi-bff/search/kinds/getKinds`);
49699
- return result.data;
49700
- };
49701
-
49702
- const parseK8sVersion = (raw) => {
49703
- const m = /^v(?<major>\d+)(?:(?<stage>alpha|beta)(?<stageNum>\d+)?)?$/i.exec(raw ?? "");
49704
- if (!m?.groups) return { rank: 0, major: -1, stageNum: -1 };
49705
- const stage = (m.groups.stage ?? "").toLowerCase();
49706
- const major = Number(m.groups.major);
49707
- const stageNum = m.groups.stageNum ? Number(m.groups.stageNum) : 0;
49708
- const rank = stage === "" ? 3 : stage === "beta" ? 2 : 1;
49709
- return { rank, major, stageNum };
49710
- };
49711
- const versionToken = (e) => e.version || (e.groupVersion?.split("/").pop() ?? "");
49712
- const compareK8sVersionDesc = (a, b) => {
49713
- const pa = parseK8sVersion(versionToken(a));
49714
- const pb = parseK8sVersion(versionToken(b));
49715
- return pb.rank - pa.rank || pb.major - pa.major || pb.stageNum - pa.stageNum;
49716
- };
49717
- const getSortedKinds = (index) => {
49718
- const counts = index.items.reduce(
49719
- (acc, item) => ({ ...acc, [item.kind]: (acc[item.kind] ?? 0) + 1 }),
49720
- {}
49721
- );
49722
- const pickVersion = (versions) => versions.find((v) => v.preferred) ?? [...versions].sort(compareK8sVersionDesc)[0];
49723
- return index.items.map((item) => {
49724
- const version = pickVersion(item.versions);
49725
- return version ? {
49726
- group: item.group,
49727
- kind: item.kind,
49728
- version,
49729
- ...counts[item.kind] > 1 ? { notUnique: true } : {}
49730
- } : void 0;
49731
- }).filter((x) => Boolean(x)).sort(
49732
- (a, b) => a.kind.localeCompare(b.kind, void 0, { sensitivity: "base" }) || a.group.localeCompare(b.group, void 0, { sensitivity: "base" })
49733
- );
49734
- };
49735
-
49736
- const useDebouncedCallback = (fn, delay = 300) => {
49737
- const timer = useRef(void 0);
49738
- return (...args) => {
49739
- if (timer.current) window.clearTimeout(timer.current);
49740
- timer.current = window.setTimeout(() => fn(...args), delay);
49741
- };
49742
- };
49743
- const getArrayParam = (sp, key) => {
49744
- const raw = sp.get(key);
49745
- if (!raw) return [];
49746
- return raw.split(",").map((s) => s.trim()).filter(Boolean);
49747
- };
49748
- const setArrayParam = (sp, key, values) => {
49749
- const next = new URLSearchParams(sp);
49750
- if (!values || values.length === 0) {
49751
- next.delete(key);
49752
- } else {
49753
- next.set(key, values.join(","));
49754
- }
49755
- return next;
49756
- };
49757
- const getStringParam = (sp, key) => {
49758
- return sp.get(key) ?? "";
49759
- };
49760
- const setStringParam = (sp, key, value) => {
49761
- const next = new URLSearchParams(sp);
49762
- const v = (value ?? "").trim();
49763
- if (!v) next.delete(key);
49764
- else next.set(key, v);
49765
- return next;
49698
+ const kindByGvr = (entries) => (gvr) => {
49699
+ const [group = "", v = "", resource = ""] = gvr.split("~", 3);
49700
+ const norm = (s) => s.trim();
49701
+ const kinds = entries.filter((e) => norm(e.group) === norm(group) && e.version.version === v && e.version.resource === resource).map((e) => e.kind);
49702
+ const uniq = Array.from(new Set(kinds));
49703
+ return uniq.length === 1 ? uniq[0] : void 0;
49766
49704
  };
49767
49705
 
49768
49706
  const SelectTag = st$1(Tag)`
@@ -49772,143 +49710,147 @@ const SelectTag = st$1(Tag)`
49772
49710
  align-items: center;
49773
49711
  white-space: normal;
49774
49712
  line-height: 1.1;
49775
- max-width: 240px;
49776
49713
  `;
49777
49714
  const SelectTagSpan = st$1.span`
49778
49715
  display: inline-flex;
49779
49716
  flex-direction: column;
49780
49717
  `;
49718
+ const MaxTagPlacheolder = st$1.div`
49719
+ padding-left: 16px;
49720
+ `;
49721
+ const MaxTagPlacheolderLength = st$1.span`
49722
+ min-height: 20px;
49723
+ padding-right: 4px;
49724
+ padding-left: 4px;
49725
+ border: 1px solid ${({ $colorBorder }) => $colorBorder};
49726
+ border-radius: 20px;
49727
+ `;
49728
+ const OptionLabelKind = st$1.div`
49729
+ font-size: 14px;
49730
+ font-style: normal;
49731
+ font-weight: 400;
49732
+ line-height: 22px;
49733
+ `;
49734
+ const OptionLabelVersion = st$1.div`
49735
+ font-size: 10px;
49736
+ font-style: italic;
49737
+ font-weight: 400;
49738
+ line-height: 14px; /* 140% */
49739
+ `;
49740
+ const BackgroundContainer = st$1.div`
49741
+ width: 100%;
49742
+ gap: 8px;
49743
+ border: 1px solid ${({ $colorBorder }) => $colorBorder};
49744
+ border-radius: 6px;
49745
+ background: ${({ $colorBgLayout }) => $colorBgLayout};
49746
+ padding: 8px;
49747
+ `;
49781
49748
  const FormContainer = st$1.div`
49782
49749
  display: grid;
49783
- grid-template-columns: 300px 100px 1fr 100px;
49784
- gap: 16px;
49750
+ grid-template-columns: 3fr 9fr;
49751
+ gap: 8px;
49752
+ `;
49753
+ const ResetedFormItem = st$1(Form.Item)`
49754
+ margin-bottom: 0;
49785
49755
  `;
49786
49756
  const HideableContainer = st$1.div`
49787
49757
  display: ${({ $isHidden }) => $isHidden ? "none" : "initial"};
49788
49758
  `;
49759
+ const CompoundItem = st$1.div`
49760
+ display: grid;
49761
+ grid-template-columns: 130px 1fr;
49762
+ `;
49763
+ const LeftSideSelect = st$1(Select)`
49764
+ /* stylelint-disable declaration-no-important */
49765
+
49766
+ .ant-select-selector {
49767
+ border-top-right-radius: 0 !important;
49768
+ border-bottom-right-radius: 0 !important;
49769
+ border-right-width: 0 !important;
49770
+ height: 32px !important;
49771
+ }
49772
+ `;
49773
+ const RightSideInput = st$1(Input)`
49774
+ &&&.ant-input-outlined {
49775
+ border-top-left-radius: 0 !important;
49776
+ border-bottom-left-radius: 0 !important;
49777
+ border-left-width: 0 !important;
49778
+ height: 32px !important;
49779
+ }
49780
+ `;
49781
+ const RightSideSelect = st$1(Select)`
49782
+ .ant-select-selector {
49783
+ border-top-left-radius: 0 !important;
49784
+ border-bottom-left-radius: 0 !important;
49785
+ border-left-width: 0 !important;
49786
+ height: 32px !important;
49787
+ }
49788
+ `;
49789
+ const BottomTagsHolder = st$1.div`
49790
+ display: flex;
49791
+ gap: 4px;
49792
+ flex-wrap: wrap;
49793
+ margin-top: 8px;
49794
+ `;
49795
+ const CustomTag = st$1(Tag)`
49796
+ font-size: 14px;
49797
+ height: 22px;
49798
+ margin-inline-end: 0 !important;
49799
+ `;
49800
+ const Abbr = st$1.span`
49801
+ background-color: ${({ $bgColor }) => $bgColor};
49802
+ border-radius: 13px;
49803
+ padding: 2px 5px;
49804
+ height: min-content;
49805
+ `;
49806
+ const ClearButtonHolder = st$1.div`
49807
+ display: flex;
49808
+ justify-content: flex-end;
49809
+ margin-top: 8px;
49810
+ `;
49789
49811
  const Styled = {
49790
49812
  SelectTag,
49791
49813
  SelectTagSpan,
49814
+ MaxTagPlacheolder,
49815
+ MaxTagPlacheolderLength,
49816
+ OptionLabelKind,
49817
+ OptionLabelVersion,
49818
+ BackgroundContainer,
49792
49819
  FormContainer,
49793
- HideableContainer
49820
+ ResetedFormItem,
49821
+ HideableContainer,
49822
+ CompoundItem,
49823
+ LeftSideSelect,
49824
+ RightSideInput,
49825
+ RightSideSelect,
49826
+ BottomTagsHolder,
49827
+ CustomTag,
49828
+ Abbr,
49829
+ ClearButtonHolder
49794
49830
  };
49795
49831
 
49796
- const Search = ({ cluster, updateCurrentSearch }) => {
49797
- const [form] = Form.useForm();
49798
- const [searchParams, setSearchParams] = useSearchParams();
49799
- const location = useLocation();
49800
- const FIELD_NAME = "kinds";
49801
- const FIELD_NAME_STRING = "name";
49802
- const FIELD_NAME_LABELS = "labels";
49803
- const FIELD_NAME_FIELDS = "fields";
49804
- const TYPE_SELECTOR = "TYPE_SELECTOR";
49805
- const QUERY_KEY = "kinds";
49806
- const NAME_QUERY_KEY = "name";
49807
- const LABELS_QUERY_KEY = "labels";
49808
- const FIELDS_QUERY_KEY = "fields";
49832
+ const Search = ({ theme: theme$1, form, constants, kindsWithVersion }) => {
49833
+ const { token } = theme.useToken();
49834
+ const { FIELD_NAME, FIELD_NAME_STRING, FIELD_NAME_LABELS, FIELD_NAME_FIELDS, TYPE_SELECTOR } = constants;
49809
49835
  const watchedKinds = Form.useWatch(FIELD_NAME, form);
49810
49836
  const watchedName = Form.useWatch(FIELD_NAME_STRING, form);
49811
49837
  const watchedLabels = Form.useWatch(FIELD_NAME_LABELS, form);
49812
49838
  const watchedFields = Form.useWatch(FIELD_NAME_FIELDS, form);
49813
49839
  const watchedTypedSelector = Form.useWatch(TYPE_SELECTOR, form);
49814
- const [kindIndex, setKindIndex] = useState();
49815
- const [kindWithVersion, setKindWithVersion] = useState();
49816
- useEffect(() => {
49817
- getKinds({
49818
- clusterName: cluster
49819
- }).then((data) => {
49820
- setKindIndex(data);
49821
- setKindWithVersion(getSortedKinds(data));
49822
- });
49823
- }, [cluster]);
49824
- useEffect(() => {
49825
- const fromKinds = getArrayParam(searchParams, QUERY_KEY);
49826
- const currentKinds = form.getFieldValue(FIELD_NAME);
49827
- const kindsDiffer = (fromKinds.length || 0) !== (currentKinds?.length || 0) || fromKinds.some((v, i) => v !== currentKinds?.[i]);
49828
- const fromName = getStringParam(searchParams, NAME_QUERY_KEY);
49829
- const currentName = form.getFieldValue(FIELD_NAME_STRING);
49830
- const nameDiffer = (fromName || "") !== (currentName || "");
49831
- const fromLabels = getArrayParam(searchParams, LABELS_QUERY_KEY);
49832
- const currentLabels = form.getFieldValue(FIELD_NAME_LABELS);
49833
- const labelsDiffer = (fromLabels.length || 0) !== (currentLabels?.length || 0) || fromLabels.some((v, i) => v !== currentLabels?.[i]);
49834
- const fromFields = getArrayParam(searchParams, FIELDS_QUERY_KEY);
49835
- const currentFields = form.getFieldValue(FIELD_NAME_FIELDS);
49836
- const fieldsDiffer = (fromFields.length || 0) !== (currentFields?.length || 0) || fromFields.some((v, i) => v !== currentFields?.[i]);
49837
- const currentType = form.getFieldValue(TYPE_SELECTOR);
49838
- let inferredType;
49839
- if (fromName) {
49840
- inferredType = "name";
49841
- } else if (fromLabels.length > 0) {
49842
- inferredType = "labels";
49843
- } else if (fromFields.length > 0) {
49844
- inferredType = "fields";
49845
- }
49846
- const typeDiffer = inferredType !== currentType;
49847
- if (kindsDiffer || nameDiffer || labelsDiffer || fieldsDiffer) {
49848
- form.setFieldsValue({
49849
- [FIELD_NAME]: kindsDiffer ? fromKinds : currentKinds,
49850
- [FIELD_NAME_STRING]: nameDiffer ? fromName : currentName,
49851
- [FIELD_NAME_LABELS]: labelsDiffer ? fromLabels : currentLabels,
49852
- [FIELD_NAME_FIELDS]: fieldsDiffer ? fromFields : currentFields,
49853
- [TYPE_SELECTOR]: typeDiffer ? inferredType : currentType
49854
- });
49855
- }
49856
- }, [location.search]);
49857
- const debouncedPush = useDebouncedCallback((values) => {
49858
- const next = setArrayParam(searchParams, QUERY_KEY, values);
49859
- setSearchParams(next, { replace: true });
49860
- }, 250);
49861
- const debouncedPushName = useDebouncedCallback((value) => {
49862
- const next = setStringParam(searchParams, NAME_QUERY_KEY, value);
49863
- setSearchParams(next, { replace: true });
49864
- }, 250);
49865
- const debouncedPushLabels = useDebouncedCallback((values) => {
49866
- const next = setArrayParam(searchParams, LABELS_QUERY_KEY, values);
49867
- setSearchParams(next, { replace: true });
49868
- }, 250);
49869
- const debouncedPushFields = useDebouncedCallback((values) => {
49870
- const next = setArrayParam(searchParams, FIELDS_QUERY_KEY, values);
49871
- setSearchParams(next, { replace: true });
49872
- }, 250);
49873
- useEffect(() => {
49874
- debouncedPush(watchedKinds || []);
49875
- }, [watchedKinds]);
49876
- useEffect(() => {
49877
- debouncedPushName((watchedName || "").trim());
49878
- }, [watchedName]);
49879
- useEffect(() => {
49880
- debouncedPushLabels(watchedLabels || []);
49881
- }, [watchedLabels]);
49882
- useEffect(() => {
49883
- debouncedPushFields(watchedFields || []);
49884
- }, [watchedFields]);
49885
- useEffect(() => {
49886
- if (watchedTypedSelector === "name") {
49887
- form.setFieldsValue({ [FIELD_NAME_LABELS]: [], [FIELD_NAME_FIELDS]: [] });
49888
- } else if (watchedTypedSelector === "labels") {
49889
- form.setFieldsValue({ [FIELD_NAME_STRING]: "", [FIELD_NAME_FIELDS]: [] });
49890
- } else if (watchedTypedSelector === "fields") {
49891
- form.setFieldsValue({ [FIELD_NAME_STRING]: "", [FIELD_NAME_LABELS]: [] });
49892
- }
49893
- }, [watchedTypedSelector]);
49894
- const options = kindWithVersion?.map(({ kind, group, version }) => ({
49895
- // kindWithVersion?.map(({ kind, notUnique, group, version }) => ({
49896
- // label: notUnique ? (
49897
- // <div>
49898
- // {kind}
49899
- // <br />
49900
- // {version.groupVersion}
49901
- // </div>
49902
- // ) : (
49903
- // kind
49904
- // ),
49905
- label: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
49906
- kind,
49907
- /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
49908
- version.groupVersion
49909
- ] }),
49910
- value: `${group}~${version.version}~${version.resource}`
49911
- })) || [];
49840
+ const options = kindsWithVersion.filter(({ version }) => version.verbs && version.verbs.includes("list")).map(({ kind, group, version }) => {
49841
+ const abbr = getUppercase(kind);
49842
+ const bgColor = kind && kind.length ? hslFromString(abbr, theme$1) : "";
49843
+ return {
49844
+ label: /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: 8, align: "center", children: [
49845
+ bgColor.length && /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.Abbr, { $bgColor: bgColor, children: abbr }),
49846
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: 2, vertical: true, children: [
49847
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.OptionLabelKind, { children: kind }),
49848
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.OptionLabelVersion, { children: version.groupVersion })
49849
+ ] })
49850
+ ] }),
49851
+ value: `${group}~${version.version}~${version.resource}`
49852
+ };
49853
+ }) || [];
49912
49854
  const tagRender = ({ label, closable, onClose }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
49913
49855
  Styled.SelectTag,
49914
49856
  {
@@ -49921,9 +49863,39 @@ const Search = ({ cluster, updateCurrentSearch }) => {
49921
49863
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.SelectTagSpan, { children: label })
49922
49864
  }
49923
49865
  );
49924
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
49866
+ const maxTagPlaceholder = () => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
49867
+ "Kinds",
49868
+ " ",
49869
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.MaxTagPlacheolderLength, { $colorBorder: token.colorBorder, children: watchedKinds?.length ? watchedKinds.length : "0" })
49870
+ ] });
49871
+ const maxTagTagRender = ({ label }) => /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.MaxTagPlacheolder, { children: label });
49872
+ const getKindByGvr = kindByGvr(kindsWithVersion);
49873
+ const removeKind = (value) => {
49874
+ const cur = form.getFieldValue(FIELD_NAME) || [];
49875
+ form.setFieldsValue({ [FIELD_NAME]: cur.filter((v) => v !== value) });
49876
+ };
49877
+ const clearName = () => {
49878
+ form.setFieldsValue({ [FIELD_NAME_STRING]: "" });
49879
+ };
49880
+ const removeLabel = (label) => {
49881
+ const cur = form.getFieldValue(FIELD_NAME_LABELS) || [];
49882
+ form.setFieldsValue({ [FIELD_NAME_LABELS]: cur.filter((v) => v !== label) });
49883
+ };
49884
+ const removeField = (field) => {
49885
+ const cur = form.getFieldValue(FIELD_NAME_FIELDS) || [];
49886
+ form.setFieldsValue({ [FIELD_NAME_FIELDS]: cur.filter((v) => v !== field) });
49887
+ };
49888
+ const kindOptionRender = (option) => {
49889
+ const selectedList = form.getFieldValue(FIELD_NAME) || [];
49890
+ const checked = selectedList.includes(option.value);
49891
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: 8, align: "center", children: [
49892
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { checked }) }),
49893
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: option.label })
49894
+ ] });
49895
+ };
49896
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled.BackgroundContainer, { $colorBorder: token.colorBorder, $colorBgLayout: token.colorBgLayout, children: [
49925
49897
  /* @__PURE__ */ jsxRuntimeExports.jsx(Form, { form, layout: "vertical", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled.FormContainer, { children: [
49926
- /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Item, { name: FIELD_NAME, label: "Kinds", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49898
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.ResetedFormItem, { name: FIELD_NAME, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49927
49899
  Select,
49928
49900
  {
49929
49901
  mode: "multiple",
@@ -49932,127 +49904,187 @@ const Search = ({ cluster, updateCurrentSearch }) => {
49932
49904
  filterOption: (input, option) => (option?.value || "").toString().toLowerCase().includes(input.toLowerCase()),
49933
49905
  allowClear: true,
49934
49906
  showSearch: true,
49935
- tagRender,
49936
- maxTagCount: "responsive"
49937
- }
49938
- ) }),
49939
- /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Item, { name: TYPE_SELECTOR, label: "Type", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49940
- Select,
49941
- {
49942
- placeholder: "Select",
49943
- options: [
49944
- { label: "Name", value: "name" },
49945
- { label: "Labels", value: "labels" },
49946
- { label: "Fields", value: "fields" }
49947
- ],
49948
- defaultValue: "name",
49949
- filterOption: filterSelectOptions,
49950
- showSearch: true
49907
+ maxTagCount: 0,
49908
+ maxTagPlaceholder,
49909
+ tagRender: maxTagTagRender,
49910
+ menuItemSelectedIcon: null,
49911
+ optionRender: kindOptionRender
49951
49912
  }
49952
49913
  ) }),
49953
- /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.HideableContainer, { $isHidden: watchedTypedSelector === "labels" || watchedTypedSelector === "fields", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Item, { name: FIELD_NAME_STRING, label: "Name", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { allowClear: true }) }) }),
49954
- /* @__PURE__ */ jsxRuntimeExports.jsx(
49955
- Styled.HideableContainer,
49956
- {
49957
- $isHidden: watchedTypedSelector === "name" || watchedTypedSelector === "fields" || watchedTypedSelector === void 0,
49958
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49959
- Form.Item,
49960
- {
49961
- name: FIELD_NAME_LABELS,
49962
- label: "Labels",
49963
- validateTrigger: "onBlur",
49964
- rules: [
49965
- () => ({
49966
- validator(_, value) {
49967
- if (Array.isArray(value) && value.every((str) => typeof str === "string" && str.includes("=") && !str.startsWith("="))) {
49968
- return Promise.resolve();
49914
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled.CompoundItem, { children: [
49915
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.ResetedFormItem, { name: TYPE_SELECTOR, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49916
+ Styled.LeftSideSelect,
49917
+ {
49918
+ placeholder: "Select",
49919
+ options: [
49920
+ { label: "Name", value: "name" },
49921
+ { label: "Labels", value: "labels" },
49922
+ { label: "Fields", value: "fields" }
49923
+ ],
49924
+ defaultValue: "name",
49925
+ filterOption: filterSelectOptions,
49926
+ showSearch: true
49927
+ }
49928
+ ) }),
49929
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49930
+ Styled.HideableContainer,
49931
+ {
49932
+ $isHidden: watchedTypedSelector === "labels" || watchedTypedSelector === "fields",
49933
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.ResetedFormItem, { name: FIELD_NAME_STRING, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.RightSideInput, { allowClear: true, placeholder: "Name", disabled: !watchedKinds || !watchedKinds.length }) })
49934
+ }
49935
+ ),
49936
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49937
+ Styled.HideableContainer,
49938
+ {
49939
+ $isHidden: watchedTypedSelector === "name" || watchedTypedSelector === "fields" || watchedTypedSelector === void 0,
49940
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49941
+ Styled.ResetedFormItem,
49942
+ {
49943
+ name: FIELD_NAME_LABELS,
49944
+ validateTrigger: "onBlur",
49945
+ rules: [
49946
+ () => ({
49947
+ validator(_, value) {
49948
+ if (Array.isArray(value) && value.every((str) => typeof str === "string" && str.includes("=") && !str.startsWith("="))) {
49949
+ return Promise.resolve();
49950
+ }
49951
+ return Promise.reject(new Error("Please enter key=value style"));
49969
49952
  }
49970
- return Promise.reject(new Error("Please enter key=value style"));
49953
+ })
49954
+ ],
49955
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49956
+ Styled.RightSideSelect,
49957
+ {
49958
+ mode: "tags",
49959
+ allowClear: true,
49960
+ placeholder: "Key=Value",
49961
+ tokenSeparators: [",", " ", " "],
49962
+ suffixIcon: null,
49963
+ filterOption: filterSelectOptions,
49964
+ tagRender,
49965
+ maxTagCount: "responsive",
49966
+ disabled: !watchedKinds || !watchedKinds.length
49971
49967
  }
49972
- })
49973
- ],
49974
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49975
- Select,
49976
- {
49977
- mode: "tags",
49978
- allowClear: true,
49979
- placeholder: "Select",
49980
- tokenSeparators: [",", " ", " "],
49981
- suffixIcon: null,
49982
- filterOption: filterSelectOptions,
49983
- tagRender
49984
- }
49985
- )
49986
- }
49987
- )
49988
- }
49989
- ),
49990
- /* @__PURE__ */ jsxRuntimeExports.jsx(
49991
- Styled.HideableContainer,
49992
- {
49993
- $isHidden: watchedTypedSelector === "name" || watchedTypedSelector === "labels" || watchedTypedSelector === void 0,
49994
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49995
- Form.Item,
49996
- {
49997
- name: FIELD_NAME_FIELDS,
49998
- label: "Fields",
49999
- validateTrigger: "onBlur",
50000
- rules: [
50001
- () => ({
50002
- validator(_, value) {
50003
- if (Array.isArray(value) && value.every((str) => typeof str === "string" && str.includes("=") && !str.startsWith("="))) {
50004
- return Promise.resolve();
49968
+ )
49969
+ }
49970
+ )
49971
+ }
49972
+ ),
49973
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49974
+ Styled.HideableContainer,
49975
+ {
49976
+ $isHidden: watchedTypedSelector === "name" || watchedTypedSelector === "labels" || watchedTypedSelector === void 0,
49977
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49978
+ Styled.ResetedFormItem,
49979
+ {
49980
+ name: FIELD_NAME_FIELDS,
49981
+ validateTrigger: "onBlur",
49982
+ rules: [
49983
+ () => ({
49984
+ validator(_, value) {
49985
+ if (Array.isArray(value) && value.every((str) => typeof str === "string" && str.includes("=") && !str.startsWith("="))) {
49986
+ return Promise.resolve();
49987
+ }
49988
+ return Promise.reject(new Error("Please enter key=value style"));
50005
49989
  }
50006
- return Promise.reject(new Error("Please enter key=value style"));
49990
+ })
49991
+ ],
49992
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49993
+ Styled.RightSideSelect,
49994
+ {
49995
+ mode: "tags",
49996
+ allowClear: true,
49997
+ placeholder: "Key=Value",
49998
+ tokenSeparators: [",", " ", " "],
49999
+ suffixIcon: null,
50000
+ filterOption: filterSelectOptions,
50001
+ tagRender,
50002
+ maxTagCount: "responsive",
50003
+ disabled: !watchedKinds || !watchedKinds.length
50007
50004
  }
50008
- })
50009
- ],
50010
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
50011
- Select,
50012
- {
50013
- mode: "tags",
50014
- allowClear: true,
50015
- placeholder: "Select",
50016
- tokenSeparators: [",", " ", " "],
50017
- suffixIcon: null,
50018
- filterOption: filterSelectOptions,
50019
- tagRender
50020
- }
50021
- )
50022
- }
50023
- )
50024
- }
50025
- ),
50026
- /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Item, { label: "Search", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
50005
+ )
50006
+ }
50007
+ )
50008
+ }
50009
+ )
50010
+ ] })
50011
+ ] }) }),
50012
+ watchedKinds && watchedKinds.length || watchedName && watchedName.length || watchedLabels && watchedLabels.length || watchedFields && watchedFields.length ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
50013
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Styled.BottomTagsHolder, { children: [
50014
+ watchedKinds && watchedKinds.map((fullKindName) => {
50015
+ const kind = getKindByGvr(fullKindName);
50016
+ const abbr = getUppercase(kind && kind.length ? kind : "Loading");
50017
+ const bgColor = kind && kind.length ? hslFromString(abbr, theme$1) : "";
50018
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
50019
+ Styled.CustomTag,
50020
+ {
50021
+ onClose: (e) => {
50022
+ e.preventDefault();
50023
+ removeKind(fullKindName);
50024
+ },
50025
+ closable: true,
50026
+ children: [
50027
+ kind && kind.length && bgColor.length && /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.Abbr, { $bgColor: bgColor, children: abbr }),
50028
+ kind
50029
+ ]
50030
+ },
50031
+ fullKindName
50032
+ );
50033
+ }),
50034
+ watchedName && /* @__PURE__ */ jsxRuntimeExports.jsx(
50035
+ Styled.CustomTag,
50036
+ {
50037
+ onClose: (e) => {
50038
+ e.preventDefault();
50039
+ clearName();
50040
+ },
50041
+ closable: true,
50042
+ children: watchedName
50043
+ }
50044
+ ),
50045
+ watchedLabels && watchedLabels.map((label) => /* @__PURE__ */ jsxRuntimeExports.jsx(
50046
+ Styled.CustomTag,
50047
+ {
50048
+ onClose: (e) => {
50049
+ e.preventDefault();
50050
+ removeLabel(label);
50051
+ },
50052
+ closable: true,
50053
+ children: label
50054
+ },
50055
+ label
50056
+ )),
50057
+ watchedFields && watchedFields.map((field) => /* @__PURE__ */ jsxRuntimeExports.jsx(
50058
+ Styled.CustomTag,
50059
+ {
50060
+ onClose: (e) => {
50061
+ e.preventDefault();
50062
+ removeField(field);
50063
+ },
50064
+ closable: true,
50065
+ children: field
50066
+ },
50067
+ field
50068
+ ))
50069
+ ] }),
50070
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Styled.ClearButtonHolder, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
50027
50071
  Button,
50028
50072
  {
50029
50073
  type: "primary",
50030
- onClick: () => updateCurrentSearch({
50031
- resources: watchedKinds,
50032
- name: watchedName,
50033
- labels: watchedLabels,
50034
- fields: watchedFields
50035
- }),
50036
- children: "Search"
50074
+ onClick: () => {
50075
+ form.setFieldsValue({
50076
+ [FIELD_NAME]: [],
50077
+ [FIELD_NAME_STRING]: "",
50078
+ [FIELD_NAME_LABELS]: [],
50079
+ [FIELD_NAME_FIELDS]: [],
50080
+ [TYPE_SELECTOR]: "name"
50081
+ // reset selector to default
50082
+ });
50083
+ },
50084
+ children: "Clear"
50037
50085
  }
50038
50086
  ) })
50039
- ] }) }),
50040
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
50041
- "Current: ",
50042
- (watchedKinds || []).join(", ")
50043
- ] }),
50044
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
50045
- "Current name: ",
50046
- watchedName
50047
- ] }),
50048
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
50049
- "Current labels: ",
50050
- (watchedLabels || []).join(", ")
50051
- ] }),
50052
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
50053
- "Current fields: ",
50054
- (watchedFields || []).join(", ")
50055
- ] })
50087
+ ] }) : void 0
50056
50088
  ] });
50057
50089
  };
50058
50090
 
@@ -50168,6 +50200,48 @@ const getGroupsByCategory = async ({
50168
50200
  return { crdGroups, nonCrdGroups, builtinGroups: filteredBuiltinData, apiExtensionVersion };
50169
50201
  };
50170
50202
 
50203
+ const parseK8sVersion = (raw) => {
50204
+ const m = /^v(?<major>\d+)(?:(?<stage>alpha|beta)(?<stageNum>\d+)?)?$/i.exec(raw ?? "");
50205
+ if (!m?.groups) return { rank: 0, major: -1, stageNum: -1 };
50206
+ const stage = (m.groups.stage ?? "").toLowerCase();
50207
+ const major = Number(m.groups.major);
50208
+ const stageNum = m.groups.stageNum ? Number(m.groups.stageNum) : 0;
50209
+ const rank = stage === "" ? 3 : stage === "beta" ? 2 : 1;
50210
+ return { rank, major, stageNum };
50211
+ };
50212
+ const versionToken = (e) => e.version || (e.groupVersion?.split("/").pop() ?? "");
50213
+ const compareK8sVersionDesc = (a, b) => {
50214
+ const pa = parseK8sVersion(versionToken(a));
50215
+ const pb = parseK8sVersion(versionToken(b));
50216
+ return pb.rank - pa.rank || pb.major - pa.major || pb.stageNum - pa.stageNum;
50217
+ };
50218
+ const getSortedKinds = (index) => {
50219
+ const counts = index.items.reduce(
50220
+ (acc, item) => ({ ...acc, [item.kind]: (acc[item.kind] ?? 0) + 1 }),
50221
+ {}
50222
+ );
50223
+ const pickVersion = (versions) => versions.find((v) => v.preferred) ?? [...versions].sort(compareK8sVersionDesc)[0];
50224
+ return index.items.map((item) => {
50225
+ const version = pickVersion(item.versions);
50226
+ return version ? {
50227
+ group: item.group,
50228
+ kind: item.kind,
50229
+ version,
50230
+ ...counts[item.kind] > 1 ? { notUnique: true } : {}
50231
+ } : void 0;
50232
+ }).filter((x) => Boolean(x)).sort(
50233
+ (a, b) => a.kind.localeCompare(b.kind, void 0, { sensitivity: "base" }) || a.group.localeCompare(b.group, void 0, { sensitivity: "base" })
50234
+ );
50235
+ };
50236
+
50237
+ const namespacedByGvr = (entries) => (gvr) => {
50238
+ const [group = "", v = "", resource = ""] = gvr.split("~", 3);
50239
+ const norm = (s) => s.trim();
50240
+ const kinds = entries.filter((e) => norm(e.group) === norm(group) && e.version.version === v && e.version.resource === resource).map((e) => e.version.namespaced);
50241
+ const uniq = Array.from(new Set(kinds));
50242
+ return uniq.length === 1 ? uniq[0] : void 0;
50243
+ };
50244
+
50171
50245
  const getClusterList = async () => {
50172
50246
  return axios.get("/clusterlist");
50173
50247
  };
@@ -50336,6 +50410,11 @@ const checkIfBuiltInInstanceNamespaceScoped = async ({
50336
50410
  return data;
50337
50411
  };
50338
50412
 
50413
+ const getKinds = async ({ clusterName }) => {
50414
+ const result = await axios.get(`/api/clusters/${clusterName}/openapi-bff/search/kinds/getKinds`);
50415
+ return result.data;
50416
+ };
50417
+
50339
50418
  const useClusterList = ({ refetchInterval }) => {
50340
50419
  return useQuery({
50341
50420
  queryKey: ["useClusterList"],
@@ -50589,5 +50668,5 @@ const useCrdData = ({
50589
50668
  });
50590
50669
  };
50591
50670
 
50592
- export { BackToDefaultIcon, BlackholeForm, BlackholeFormDataProvider, ContentCard$1 as ContentCard, CursorDefaultDiv, CursorPointerTag, CustomSelect$4 as CustomSelect, DeleteIcon, DeleteModal, DeleteModalMany, DownIcon, DynamicComponents, DynamicRenderer, DynamicRendererWithProviders, EditIcon, EnrichedTable, EnrichedTableProvider, FlexGrow, LockedIcon, ManageableBreadcrumbs, ManageableBreadcrumbsWithDataProvider, ManageableSidebar, ManageableSidebarWithDataProvider, MarketPlace, MarketplaceCard, MinusIcon, NodeTerminal, PauseCircleIcon, PlusIcon, PodLogs, PodLogsMonaco, PodTerminal, ProjectInfoCard, ResumeCircleIcon, Search, Spacer$1 as Spacer, SuccessIcon, TreeWithSearch, UncontrolledSelect, UnlockedIcon, UpIcon, YamlEditorSingleton, checkIfApiInstanceNamespaceScoped, checkIfBuiltInInstanceNamespaceScoped, checkPermission, createContextFactory, createNewEntry, deepMerge, deleteEntry, feedbackIcons, filterIfApiInstanceNamespaceScoped, filterIfBuiltInInstanceNamespaceScoped, filterSelectOptions, floorToDecimal, getAllPathsFromObj, getApiResourceSingle, getApiResourceTypes, getApiResourceTypesByApiGroup, getApiResources, getBuiltinResourceSingle, getBuiltinResourceTypes, getBuiltinResources, getBuiltinTreeData, getClusterList, getCrdData, getCrdResourceSingle, getCrdResources, getDirectUnknownResource, getEnrichedColumns, getEnrichedColumnsWithControls, getGroupsByCategory, getKinds, getObjectFormItemsDraft, getPrefixSubarrays, getSortedKinds, getStringByName, getSwagger, groupsToTreeData, isFlatObject, normalizeValuesForQuotasToNumber, parseQuotaValue, parseQuotaValueCpu, parseQuotaValueMemoryAndStorage, prepareDataForManageableBreadcrumbs, prepareDataForManageableSidebar, prepareTemplate, prepareUrlsToFetchForDynamicRenderer, updateEntry, useApiResourceSingle, useApiResourceTypesByGroup, useApiResources, useApisResourceTypes, useBuiltinResourceSingle, useBuiltinResourceTypes, useBuiltinResources, useClusterList, useCrdData, useCrdResourceSingle, useCrdResources, useDirectUnknownResource, usePermissions };
50671
+ export { BackToDefaultIcon, BlackholeForm, BlackholeFormDataProvider, ContentCard$1 as ContentCard, CursorDefaultDiv, CursorPointerTag, CustomSelect$4 as CustomSelect, DeleteIcon, DeleteModal, DeleteModalMany, DownIcon, DynamicComponents, DynamicRenderer, DynamicRendererWithProviders, EditIcon, EnrichedTable, EnrichedTableProvider, FlexGrow, LockedIcon, ManageableBreadcrumbs, ManageableBreadcrumbsWithDataProvider, ManageableSidebar, ManageableSidebarWithDataProvider, MarketPlace, MarketplaceCard, MinusIcon, NodeTerminal, PauseCircleIcon, PlusIcon, PodLogs, PodLogsMonaco, PodTerminal, ProjectInfoCard, ResumeCircleIcon, Search, Spacer$1 as Spacer, SuccessIcon, TreeWithSearch, UncontrolledSelect, UnlockedIcon, UpIcon, YamlEditorSingleton, checkIfApiInstanceNamespaceScoped, checkIfBuiltInInstanceNamespaceScoped, checkPermission, createContextFactory, createNewEntry, deepMerge, deleteEntry, feedbackIcons, filterIfApiInstanceNamespaceScoped, filterIfBuiltInInstanceNamespaceScoped, filterSelectOptions, floorToDecimal, getAllPathsFromObj, getApiResourceSingle, getApiResourceTypes, getApiResourceTypesByApiGroup, getApiResources, getBuiltinResourceSingle, getBuiltinResourceTypes, getBuiltinResources, getBuiltinTreeData, getClusterList, getCrdData, getCrdResourceSingle, getCrdResources, getDirectUnknownResource, getEnrichedColumns, getEnrichedColumnsWithControls, getGroupsByCategory, getKinds, getObjectFormItemsDraft, getPrefixSubarrays, getSortedKinds, getStringByName, getSwagger, getUppercase, groupsToTreeData, hslFromString, isFlatObject, kindByGvr, namespacedByGvr, normalizeValuesForQuotasToNumber, parseQuotaValue, parseQuotaValueCpu, parseQuotaValueMemoryAndStorage, prepareDataForManageableBreadcrumbs, prepareDataForManageableSidebar, prepareTemplate, prepareUrlsToFetchForDynamicRenderer, updateEntry, useApiResourceSingle, useApiResourceTypesByGroup, useApiResources, useApisResourceTypes, useBuiltinResourceSingle, useBuiltinResourceTypes, useBuiltinResources, useClusterList, useCrdData, useCrdResourceSingle, useCrdResources, useDirectUnknownResource, usePermissions };
50593
50672
  //# sourceMappingURL=openapi-k8s-toolkit.es.js.map