@dovetail-v2/refine 0.0.14 → 0.0.16

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.
Files changed (64) hide show
  1. package/dist/{MonacoYamlDiffEditor.2bd18ff6.js → MonacoYamlDiffEditor.4fe9fad1.js} +3 -3
  2. package/dist/{index.8d29d388.js → index.8dfa48ab.js} +1892 -1547
  3. package/dist/refine.js +82 -75
  4. package/dist/refine.umd.cjs +1806 -1461
  5. package/dist/style.css +5 -32595
  6. package/lib/src/Dovetail.d.ts +0 -2
  7. package/lib/src/components/CronJobDropdown/index.d.ts +2 -2
  8. package/lib/src/components/DrawerShow/DrawerShow.d.ts +4 -5
  9. package/lib/src/components/ErrorContent/index.d.ts +12 -0
  10. package/lib/src/components/EventsTable/EventsTable.d.ts +1 -3
  11. package/lib/src/components/K8sDropdown/index.d.ts +2 -2
  12. package/lib/src/components/ListPage/index.d.ts +1 -1
  13. package/lib/src/components/PageShow/PageShow.d.ts +5 -6
  14. package/lib/src/components/PodLog/index.d.ts +1 -1
  15. package/lib/src/components/ResourceCRUD/create/index.d.ts +5 -5
  16. package/lib/src/components/ResourceCRUD/list/index.d.ts +4 -5
  17. package/lib/src/components/ResourceCRUD/show/index.d.ts +5 -6
  18. package/lib/src/components/ShowContent/ShowContent.d.ts +5 -6
  19. package/lib/src/components/ShowContent/fields.d.ts +13 -14
  20. package/lib/src/components/Table/index.d.ts +6 -2
  21. package/lib/src/components/WorkloadDropdown/index.d.ts +2 -2
  22. package/lib/src/components/WorkloadReplicas/index.d.ts +1 -1
  23. package/lib/src/components/YamlForm/index.d.ts +6 -0
  24. package/lib/src/constants/k8s.d.ts +22 -0
  25. package/lib/src/contexts/component.d.ts +6 -0
  26. package/lib/src/contexts/global-store.d.ts +6 -0
  27. package/lib/src/contexts/index.d.ts +1 -0
  28. package/lib/src/hooks/index.d.ts +1 -0
  29. package/lib/src/hooks/useDownloadYAML.d.ts +2 -2
  30. package/lib/src/hooks/useEagleForm.d.ts +5 -0
  31. package/lib/src/hooks/useEagleTable/columns.d.ts +13 -14
  32. package/lib/src/hooks/useEagleTable/useEagleTable.d.ts +7 -8
  33. package/lib/src/hooks/useGlobalStore.d.ts +3 -0
  34. package/lib/src/hooks/useSchema.d.ts +9 -2
  35. package/lib/src/i18n.d.ts +6 -0
  36. package/lib/src/index.d.ts +2 -1
  37. package/lib/src/locales/en-US/index.d.ts +3 -0
  38. package/lib/src/locales/zh-CN/index.d.ts +3 -0
  39. package/lib/src/main.d.ts +2 -0
  40. package/lib/src/model/pod-model.d.ts +2 -0
  41. package/lib/src/models/cronjob-model.d.ts +14 -0
  42. package/lib/src/models/event-model.d.ts +8 -0
  43. package/lib/src/models/index.d.ts +9 -0
  44. package/lib/src/models/job-model.d.ts +15 -0
  45. package/lib/src/models/pod-metrics-model.d.ts +9 -0
  46. package/lib/src/models/pod-model.d.ts +20 -0
  47. package/lib/src/models/resource-model.d.ts +21 -0
  48. package/lib/src/models/types/index.d.ts +1 -0
  49. package/lib/src/models/types/metric.d.ts +25 -0
  50. package/lib/src/models/workload-base-model.d.ts +13 -0
  51. package/lib/src/models/workload-model.d.ts +17 -0
  52. package/lib/src/pages/configmaps/index.d.ts +3 -3
  53. package/lib/src/pages/jobs/index.d.ts +3 -4
  54. package/lib/src/pages/secrets/index.d.ts +3 -3
  55. package/lib/src/pages/services/index.d.ts +3 -3
  56. package/lib/src/plugins/index.d.ts +2 -0
  57. package/lib/src/plugins/model-plugin.d.ts +12 -0
  58. package/lib/src/plugins/relation-plugin.d.ts +27 -0
  59. package/lib/src/plugins/type.d.ts +8 -0
  60. package/lib/src/types/index.d.ts +0 -1
  61. package/lib/src/types/resource.d.ts +6 -20
  62. package/lib/src/utils/match-selector.d.ts +3 -0
  63. package/lib/src/utils/selector.d.ts +1 -1
  64. package/package.json +13 -4
@@ -10,15 +10,15 @@ import { parse, stringify } from "qs";
10
10
  import { useLocation, useHistory, useParams, matchPath, Link, Route, NavLink, Router } from "react-router-dom";
11
11
  import { useUIKit, Typo, Icon, kitContext } from "@cloudtower/eagle";
12
12
  import yaml from "js-yaml";
13
- import { relationPlugin, GlobalStore, dataProvider, liveProvider } from "k8s-api-provider";
14
- import { isObject, get, merge, cloneDeep, set, omit as omit$1 } from "lodash-es";
13
+ import { isObject, get, merge } from "lodash-es";
15
14
  import { useForm } from "sunflower-antd";
16
- import { EditPen16PrimaryIcon, TrashBinDelete16Icon, Download16GradientBlueIcon, MoreEllipsis316BoldBlueIcon, SettingsGear16GradientGrayIcon, CheckmarkDoneSuccessCorrect16BoldGreenIcon, XmarkFailed16BoldRedIcon, DynamicResourceSchedule16BlueIcon, HierarchyTriangleRight16GrayIcon, HierarchyTriangleRight16BlueIcon, ClipboardCopy16GradientGrayIcon, ClipboardCopy16GradientBlueIcon, Retry16GradientGrayIcon, Retry16GradientBlueIcon, EditPen16GradientGrayIcon, EditPen16GradientBlueIcon, Showdiff16GradientGrayIcon, Showdiff16GradientBlueIcon, XmarkFailedSeriousWarningFill16RedIcon, VmResume16Icon, SuspendedPause16GradientGrayIcon, Resume24Icon, SuspendedPause24GradientOrangeIcon } from "@cloudtower/icons-react";
15
+ import i18n from "i18next";
16
+ import { EditPen16PrimaryIcon, TrashBinDelete16Icon, Download16GradientBlueIcon, MoreEllipsis316BoldBlueIcon, CheckmarkDoneSuccessCorrect16BoldGreenIcon, XmarkFailed16BoldRedIcon, DynamicResourceSchedule16BlueIcon, HierarchyTriangleRight16GrayIcon, HierarchyTriangleRight16BlueIcon, ClipboardCopy16GradientGrayIcon, ClipboardCopy16GradientBlueIcon, Retry16GradientGrayIcon, Retry16GradientBlueIcon, EditPen16GradientGrayIcon, EditPen16GradientBlueIcon, Showdiff16GradientGrayIcon, Showdiff16GradientBlueIcon, XmarkFailedSeriousWarningFill16RedIcon, VmResume16Icon, SuspendedPause16GradientGrayIcon, Resume24Icon, SuspendedPause24GradientOrangeIcon } from "@cloudtower/icons-react";
17
17
  import * as monaco from "monaco-editor";
18
18
  import { setDiagnosticsOptions } from "monaco-yaml";
19
19
  import ReactDOM from "react-dom";
20
20
  import { Drawer } from "antd";
21
- import i18n from "i18next";
21
+ import { GlobalStore, dataProvider, liveProvider } from "k8s-api-provider";
22
22
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
23
23
  function getDefaultExportFromCjs(x) {
24
24
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -1056,7 +1056,7 @@ function useTranslation(ns) {
1056
1056
  });
1057
1057
  }
1058
1058
  function useK8sYamlEditor() {
1059
- function foldSymbol(editor, symbol) {
1059
+ const foldSymbol = useCallback(function(editor, symbol) {
1060
1060
  const model = editor.getModel();
1061
1061
  const matchs = (model == null ? void 0 : model.findMatches(
1062
1062
  symbol,
@@ -1078,8 +1078,8 @@ function useK8sYamlEditor() {
1078
1078
  reject(e);
1079
1079
  }
1080
1080
  });
1081
- }
1082
- async function fold(editor) {
1081
+ }, []);
1082
+ const fold = useCallback(async function(editor) {
1083
1083
  await editor.getAction("editor.unfoldAll").run();
1084
1084
  const symbols = [
1085
1085
  " annotations:",
@@ -1091,7 +1091,7 @@ function useK8sYamlEditor() {
1091
1091
  await foldSymbol(editor, symbol);
1092
1092
  }
1093
1093
  editor.setScrollPosition({ scrollTop: 0 });
1094
- }
1094
+ }, [foldSymbol]);
1095
1095
  return {
1096
1096
  fold
1097
1097
  };
@@ -1738,16 +1738,16 @@ var lodash = { exports: {} };
1738
1738
  }
1739
1739
  return result;
1740
1740
  }
1741
- function setToArray(set2) {
1742
- var index = -1, result = Array(set2.size);
1743
- set2.forEach(function(value) {
1741
+ function setToArray(set) {
1742
+ var index = -1, result = Array(set.size);
1743
+ set.forEach(function(value) {
1744
1744
  result[++index] = value;
1745
1745
  });
1746
1746
  return result;
1747
1747
  }
1748
- function setToPairs(set2) {
1749
- var index = -1, result = Array(set2.size);
1750
- set2.forEach(function(value) {
1748
+ function setToPairs(set) {
1749
+ var index = -1, result = Array(set.size);
1750
+ set.forEach(function(value) {
1751
1751
  result[++index] = [value, value];
1752
1752
  });
1753
1753
  return result;
@@ -2964,9 +2964,9 @@ var lodash = { exports: {} };
2964
2964
  isCommon = false;
2965
2965
  includes2 = arrayIncludesWith;
2966
2966
  } else if (length >= LARGE_ARRAY_SIZE) {
2967
- var set3 = iteratee2 ? null : createSet(array);
2968
- if (set3) {
2969
- return setToArray(set3);
2967
+ var set2 = iteratee2 ? null : createSet(array);
2968
+ if (set2) {
2969
+ return setToArray(set2);
2970
2970
  }
2971
2971
  isCommon = false;
2972
2972
  includes2 = cacheHas;
@@ -5091,7 +5091,7 @@ var lodash = { exports: {} };
5091
5091
  customizer = typeof customizer == "function" ? customizer : undefined$1;
5092
5092
  return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
5093
5093
  }
5094
- function cloneDeep2(value) {
5094
+ function cloneDeep(value) {
5095
5095
  return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
5096
5096
  }
5097
5097
  function cloneDeepWith(value, customizer) {
@@ -5495,7 +5495,7 @@ var lodash = { exports: {} };
5495
5495
  }
5496
5496
  return object2;
5497
5497
  }
5498
- function set2(object2, path, value) {
5498
+ function set(object2, path, value) {
5499
5499
  return object2 == null ? object2 : baseSet(object2, path, value);
5500
5500
  }
5501
5501
  function setWith(object2, path, value, customizer) {
@@ -6158,7 +6158,7 @@ var lodash = { exports: {} };
6158
6158
  lodash2.rest = rest;
6159
6159
  lodash2.reverse = reverse;
6160
6160
  lodash2.sampleSize = sampleSize;
6161
- lodash2.set = set2;
6161
+ lodash2.set = set;
6162
6162
  lodash2.setWith = setWith;
6163
6163
  lodash2.shuffle = shuffle;
6164
6164
  lodash2.slice = slice;
@@ -6217,7 +6217,7 @@ var lodash = { exports: {} };
6217
6217
  lodash2.ceil = ceil;
6218
6218
  lodash2.clamp = clamp;
6219
6219
  lodash2.clone = clone;
6220
- lodash2.cloneDeep = cloneDeep2;
6220
+ lodash2.cloneDeep = cloneDeep;
6221
6221
  lodash2.cloneDeepWith = cloneDeepWith;
6222
6222
  lodash2.cloneWith = cloneWith;
6223
6223
  lodash2.conformsTo = conformsTo;
@@ -6690,6 +6690,8 @@ class K8sOpenAPI {
6690
6690
  function useSchema(options) {
6691
6691
  var _a;
6692
6692
  const [schema, setSchema] = useState(null);
6693
+ const [loading, setLoading] = useState(false);
6694
+ const [error, setError] = useState(null);
6693
6695
  const useResourceResult = useResource();
6694
6696
  const resource = (options == null ? void 0 : options.resource) || useResourceResult.resource;
6695
6697
  const openapi = useMemo(
@@ -6699,14 +6701,31 @@ function useSchema(options) {
6699
6701
  },
6700
6702
  [(_a = resource == null ? void 0 : resource.meta) == null ? void 0 : _a.resourceBasePath]
6701
6703
  );
6702
- useEffect(() => {
6703
- (async function() {
6704
- var _a2;
6704
+ const fetchSchema = useCallback(async () => {
6705
+ var _a2;
6706
+ setLoading(true);
6707
+ setError(null);
6708
+ try {
6705
6709
  const schema2 = await openapi.findSchema((_a2 = resource == null ? void 0 : resource.meta) == null ? void 0 : _a2.kind);
6706
6710
  setSchema(schema2 || null);
6707
- })();
6711
+ setError(null);
6712
+ } catch (e) {
6713
+ setError(e);
6714
+ } finally {
6715
+ setLoading(false);
6716
+ }
6708
6717
  }, [resource, openapi]);
6709
- return schema;
6718
+ useEffect(() => {
6719
+ if (options == null ? void 0 : options.skip)
6720
+ return;
6721
+ fetchSchema();
6722
+ }, [fetchSchema]);
6723
+ return {
6724
+ schema,
6725
+ loading,
6726
+ error,
6727
+ fetchSchema
6728
+ };
6710
6729
  }
6711
6730
  function generateYamlBySchema(defaultValue, schema) {
6712
6731
  const typeObject = generateSchemaTypeValue(schema);
@@ -6750,6 +6769,10 @@ function generateYamlBySchema(defaultValue, schema) {
6750
6769
  const content = yaml.dump(merged);
6751
6770
  return content.replace(/(')(#.+?)(')/g, "$2").replace(/( +)(#)/g, "$2$1");
6752
6771
  }
6772
+ const GlobalStoreContext = createContext({});
6773
+ const useGlobalStore = () => {
6774
+ return useContext(GlobalStoreContext);
6775
+ };
6753
6776
  const useEagleForm = ({
6754
6777
  action,
6755
6778
  resource,
@@ -6788,8 +6811,16 @@ const useEagleForm = ({
6788
6811
  const [editorErrors, setEditorErrors] = useState([]);
6789
6812
  const [errorResponseBody, setErrorResponseBody] = useState(null);
6790
6813
  const useResourceResult = useResource();
6814
+ const { globalStore } = useGlobalStore();
6791
6815
  const kit = useUIKit();
6792
- const schema = useSchema();
6816
+ const {
6817
+ schema,
6818
+ loading: isLoadingSchema,
6819
+ error: loadSchemaError,
6820
+ fetchSchema
6821
+ } = useSchema({
6822
+ skip: editorOptions == null ? void 0 : editorOptions.isSkipSchema
6823
+ });
6793
6824
  const [formAnt] = kit.form.useForm();
6794
6825
  const formSF = useForm({
6795
6826
  form: formAnt
@@ -6885,9 +6916,7 @@ const useEagleForm = ({
6885
6916
  }
6886
6917
  }
6887
6918
  };
6888
- const initialValues = ((_c = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _c.data) ? {
6889
- ...relationPlugin.restoreItem(queryResult.data.data)
6890
- } : void 0;
6919
+ const initialValues = ((_c = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _c.data) ? globalStore == null ? void 0 : globalStore.restoreItem(queryResult.data.data) : void 0;
6891
6920
  if (initialValues) {
6892
6921
  pruneBeforeEdit(initialValues);
6893
6922
  }
@@ -6917,6 +6946,10 @@ const useEagleForm = ({
6917
6946
  editorProps,
6918
6947
  enableEditor,
6919
6948
  errorResponseBody,
6949
+ schema,
6950
+ isLoadingSchema,
6951
+ loadSchemaError,
6952
+ fetchSchema,
6920
6953
  switchEditor() {
6921
6954
  var _a2, _b2;
6922
6955
  if (enableEditor && ((_a2 = editor.current) == null ? void 0 : _a2.getEditorValue())) {
@@ -6939,13 +6972,13 @@ const useDeleteModal = (resource) => {
6939
6972
  const [id, setId] = useState("");
6940
6973
  const { t } = useTranslation();
6941
6974
  const modalProps = {
6942
- title: t("delete"),
6943
- okText: t("delete"),
6975
+ title: t("dovetail.delete"),
6976
+ okText: t("dovetail.delete"),
6944
6977
  okButtonProps: {
6945
6978
  danger: true
6946
6979
  },
6947
- cancelText: t("cancel"),
6948
- children: t("confirm_delete_text", {
6980
+ cancelText: t("dovetail.cancel"),
6981
+ children: t("dovetail.confirm_delete_text", {
6949
6982
  target: id,
6950
6983
  interpolation: { escapeValue: false }
6951
6984
  }),
@@ -7369,7 +7402,7 @@ const WorkloadReplicas = ({
7369
7402
  const currentReplicas = get(record, "spec.replicas", 0);
7370
7403
  const scale = (delta) => {
7371
7404
  const v = record.scale(currentReplicas + delta);
7372
- const id = v.id;
7405
+ const id = record.id;
7373
7406
  pruneBeforeEdit(v);
7374
7407
  mutate({
7375
7408
  id,
@@ -7393,6 +7426,188 @@ const WorkloadReplicas = ({
7393
7426
  })]
7394
7427
  });
7395
7428
  };
7429
+ const copy$1 = "Copy";
7430
+ const reset_arguments$1 = "Reset";
7431
+ const view_changes$1 = "Show Diff";
7432
+ const back_to_edit$1 = "Edit";
7433
+ const configure_file$1 = "Configuration";
7434
+ const yaml_format_wrong$1 = "Configuration is in an invalid YAML format.";
7435
+ const yaml_value_wrong$1 = "Configuration has invalid values.";
7436
+ const edit_yaml$1 = "Edit YAML";
7437
+ const copied$1 = "Copied";
7438
+ const already_reset$1 = "Already reset";
7439
+ const fetch_schema_fail$1 = "Failed to fetch schema.";
7440
+ const obtain_data_error$1 = "Having trouble getting data.";
7441
+ const retry$1 = "Retry";
7442
+ const dovetail$1 = {
7443
+ copy: copy$1,
7444
+ reset_arguments: reset_arguments$1,
7445
+ view_changes: view_changes$1,
7446
+ back_to_edit: back_to_edit$1,
7447
+ configure_file: configure_file$1,
7448
+ yaml_format_wrong: yaml_format_wrong$1,
7449
+ yaml_value_wrong: yaml_value_wrong$1,
7450
+ edit_yaml: edit_yaml$1,
7451
+ copied: copied$1,
7452
+ already_reset: already_reset$1,
7453
+ fetch_schema_fail: fetch_schema_fail$1,
7454
+ obtain_data_error: obtain_data_error$1,
7455
+ retry: retry$1
7456
+ };
7457
+ const EN = {
7458
+ dovetail: dovetail$1
7459
+ };
7460
+ const copy = "\u590D\u5236";
7461
+ const reset_arguments = "\u91CD\u7F6E";
7462
+ const view_changes = "\u67E5\u770B\u6539\u52A8";
7463
+ const back_to_edit = "\u7F16\u8F91";
7464
+ const configure_file = "\u914D\u7F6E\u5185\u5BB9";
7465
+ const yaml_format_wrong = "\u914D\u7F6E\u5185\u5BB9\u4E0D\u662F\u6709\u6548\u7684 yaml \u683C\u5F0F\u3002";
7466
+ const yaml_value_wrong = "\u914D\u7F6E\u5185\u5BB9\u4E2D\u5B58\u5728\u4E0D\u5408\u6CD5\u7684\u503C\u3002";
7467
+ const edit_yaml = "\u7F16\u8F91 YAML";
7468
+ const copied = "\u5DF2\u590D\u5236";
7469
+ const already_reset = "\u5DF2\u91CD\u7F6E";
7470
+ const cancel = "\u53D6\u6D88";
7471
+ const create = "\u521B\u5EFA";
7472
+ const confirm_delete_text = "\u786E\u5B9A\u8981\u5220\u9664 {{target}} \u5417\uFF1F";
7473
+ const edit = "\u7F16\u8F91";
7474
+ const namespace = "\u540D\u5B57\u7A7A\u95F4";
7475
+ const name = "\u540D\u79F0";
7476
+ const state = "\u72B6\u6001";
7477
+ const status = "\u72B6\u6001";
7478
+ const phase = "\u72B6\u6001";
7479
+ const image = "\u5BB9\u5668\u955C\u50CF";
7480
+ const replicas = "\u526F\u672C\u6570";
7481
+ const created_time = "\u521B\u5EFA\u65F6\u95F4";
7482
+ const label = "\u6807\u7B7E";
7483
+ const annotation = "\u6CE8\u91CA";
7484
+ const type = "\u7C7B\u578B";
7485
+ const event = "\u4E8B\u4EF6";
7486
+ const reason = "\u539F\u56E0";
7487
+ const object = "\u5BF9\u8C61";
7488
+ const note = "\u4E8B\u4EF6\u4FE1\u606F";
7489
+ const condition = "Condition";
7490
+ const download_yaml = "\u4E0B\u8F7D YAML";
7491
+ const detail = "\u8BE6\u60C5";
7492
+ const node_name = "\u4E3B\u673A\u540D\u79F0";
7493
+ const restarts = "\u91CD\u542F\u6B21\u6570";
7494
+ const updated_time = "\u66F4\u65B0\u65F6\u95F4";
7495
+ const message = "\u6D88\u606F";
7496
+ const save = "\u4FDD\u5B58";
7497
+ const more = "\u66F4\u591A";
7498
+ const workload = "\u5DE5\u4F5C\u8D1F\u8F7D";
7499
+ const all_namespaces = "\u6240\u6709\u540D\u5B57\u7A7A\u95F4";
7500
+ const empty = "\u65E0\u53EF\u663E\u793A\u7684\u6570\u636E";
7501
+ const schedule = "\u8C03\u5EA6\u65F6\u95F4\u8868";
7502
+ const lastScheduleTime = "\u4E0A\u6B21\u8C03\u5EA6\u65F6\u95F4";
7503
+ const duration = "\u6301\u7EED\u65F6\u95F4";
7504
+ const completions = "\u5B8C\u6210 Job \u5386\u53F2\u6570";
7505
+ const started = "\u5F00\u59CB\u65F6\u95F4";
7506
+ const ready = "\u5C31\u7EEA";
7507
+ const init_container = "\u521D\u59CB\u5316\u5BB9\u5668";
7508
+ const container = "\u5BB9\u5668";
7509
+ const redeploy = "\u91CD\u65B0\u90E8\u7F72";
7510
+ const data = "\u6570\u636E";
7511
+ const suspend = "\u6682\u505C";
7512
+ const resume = "\u91CD\u65B0\u5F00\u59CB";
7513
+ const cluster = "\u96C6\u7FA4";
7514
+ const storage = "\u5B58\u50A8";
7515
+ const network = "\u7F51\u7EDC";
7516
+ const clusterIp = "\u96C6\u7FA4 IP";
7517
+ const sessionAffinity = "\u4F1A\u8BDD\u4FDD\u6301";
7518
+ const log = "\u65E5\u5FD7";
7519
+ const select_container = "\u9009\u62E9\u5BB9\u5668";
7520
+ const wrap = "\u6298\u53E0";
7521
+ const resume_log = "\u7EE7\u7EED";
7522
+ const log_new_lines = "\uFF0C\u5E76\u5C55\u793A {{ count }} \u884C\u65B0\u65E5\u5FD7";
7523
+ const fetch_schema_fail = "\u83B7\u53D6 schema \u5931\u8D25\u3002";
7524
+ const obtain_data_error = "\u83B7\u53D6\u6570\u636E\u65F6\u9047\u5230\u95EE\u9898\u3002";
7525
+ const retry = "\u91CD\u8BD5";
7526
+ const dovetail = {
7527
+ copy,
7528
+ reset_arguments,
7529
+ view_changes,
7530
+ back_to_edit,
7531
+ configure_file,
7532
+ yaml_format_wrong,
7533
+ yaml_value_wrong,
7534
+ edit_yaml,
7535
+ copied,
7536
+ already_reset,
7537
+ cancel,
7538
+ "delete": "\u5220\u9664",
7539
+ create,
7540
+ confirm_delete_text,
7541
+ edit,
7542
+ namespace,
7543
+ name,
7544
+ state,
7545
+ status,
7546
+ phase,
7547
+ image,
7548
+ replicas,
7549
+ created_time,
7550
+ label,
7551
+ annotation,
7552
+ type,
7553
+ event,
7554
+ reason,
7555
+ object,
7556
+ note,
7557
+ condition,
7558
+ download_yaml,
7559
+ detail,
7560
+ node_name,
7561
+ restarts,
7562
+ updated_time,
7563
+ message,
7564
+ save,
7565
+ more,
7566
+ workload,
7567
+ all_namespaces,
7568
+ empty,
7569
+ schedule,
7570
+ lastScheduleTime,
7571
+ duration,
7572
+ completions,
7573
+ started,
7574
+ ready,
7575
+ init_container,
7576
+ container,
7577
+ redeploy,
7578
+ data,
7579
+ suspend,
7580
+ resume,
7581
+ cluster,
7582
+ storage,
7583
+ network,
7584
+ clusterIp,
7585
+ sessionAffinity,
7586
+ log,
7587
+ select_container,
7588
+ wrap,
7589
+ resume_log,
7590
+ log_new_lines,
7591
+ fetch_schema_fail,
7592
+ obtain_data_error,
7593
+ retry
7594
+ };
7595
+ const ZH = {
7596
+ dovetail
7597
+ };
7598
+ const resources = {
7599
+ "en-US": EN,
7600
+ "zh-CN": ZH
7601
+ };
7602
+ i18n.use(initReactI18next).init({
7603
+ supportedLngs: ["en-US", "zh-CN"],
7604
+ resources,
7605
+ ns: Object.keys(resources["zh-CN"]),
7606
+ defaultNS: "dovetail",
7607
+ fallbackLng: ["en-US", "zh-CN"],
7608
+ lng: "zh-CN",
7609
+ nsSeparator: "."
7610
+ });
7396
7611
  const NameLink = (props) => {
7397
7612
  var _a;
7398
7613
  const { name: name2, id, resource } = props;
@@ -7429,13 +7644,13 @@ const CommonSorter = (dataIndex) => (a, b) => {
7429
7644
  return 1;
7430
7645
  return -1;
7431
7646
  };
7432
- const NameColumnRenderer = (i18n2, resource = "") => {
7647
+ const NameColumnRenderer = (resource = "") => {
7433
7648
  const dataIndex = ["metadata", "name"];
7434
7649
  return {
7435
7650
  key: "name",
7436
7651
  display: true,
7437
7652
  dataIndex,
7438
- title: i18n2.t("name"),
7653
+ title: i18n.t("dovetail.name"),
7439
7654
  sortable: true,
7440
7655
  sorter: CommonSorter(dataIndex),
7441
7656
  render: (v, record) => {
@@ -7443,50 +7658,60 @@ const NameColumnRenderer = (i18n2, resource = "") => {
7443
7658
  }
7444
7659
  };
7445
7660
  };
7446
- const NameSpaceColumnRenderer = (i18n2) => {
7661
+ const NameSpaceColumnRenderer = () => {
7447
7662
  const dataIndex = ["metadata", "namespace"];
7448
7663
  return {
7449
7664
  key: "namespace",
7450
7665
  display: true,
7451
7666
  dataIndex,
7452
- title: i18n2.t("namespace"),
7667
+ title: i18n.t("dovetail.namespace"),
7453
7668
  sortable: true,
7454
7669
  sorter: CommonSorter(dataIndex)
7455
7670
  };
7456
7671
  };
7457
- const PhaseColumnRenderer = (i18n2) => {
7672
+ const PhaseColumnRenderer = () => {
7458
7673
  const dataIndex = ["status", "phase"];
7459
7674
  return {
7460
7675
  key: "phase",
7461
7676
  display: true,
7462
7677
  dataIndex,
7463
- title: i18n2.t("phase"),
7678
+ title: i18n.t("dovetail.phase"),
7464
7679
  sortable: true,
7465
7680
  sorter: CommonSorter(dataIndex),
7466
7681
  render: (v) => /* @__PURE__ */ jsxRuntime.exports.jsx(StateTag, { state: v })
7467
7682
  };
7468
7683
  };
7469
- const WorkloadImageColumnRenderer = (i18n2) => {
7684
+ const WorkloadImageColumnRenderer = () => {
7470
7685
  const dataIndex = ["imageNames"];
7471
7686
  return {
7472
7687
  key: "image",
7473
7688
  display: true,
7474
7689
  dataIndex,
7475
- title: i18n2.t("image"),
7690
+ title: i18n.t("dovetail.image"),
7476
7691
  sortable: true,
7477
7692
  sorter: CommonSorter(dataIndex),
7478
- render(value) {
7479
- return /* @__PURE__ */ jsxRuntime.exports.jsx(ImageNames, { value });
7693
+ render(value, record) {
7694
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(ImageNames, { value: record.imageNames });
7480
7695
  }
7481
7696
  };
7482
7697
  };
7483
- const ReplicasColumnRenderer = (i18n2) => {
7698
+ const WorkloadRestartsColumnRenderer = () => {
7699
+ const dataIndex = ["restarts"];
7700
+ return {
7701
+ key: "restarts",
7702
+ display: true,
7703
+ dataIndex,
7704
+ title: i18n.t("dovetail.restarts"),
7705
+ sortable: false
7706
+ };
7707
+ };
7708
+ const ReplicasColumnRenderer = () => {
7484
7709
  const dataIndex = ["status", "replicas"];
7485
7710
  return {
7486
7711
  key: "replicas",
7487
7712
  display: true,
7488
7713
  dataIndex,
7489
- title: i18n2.t("replicas"),
7714
+ title: i18n.t("dovetail.replicas"),
7490
7715
  sortable: true,
7491
7716
  sorter: CommonSorter(dataIndex),
7492
7717
  render: (_, record) => {
@@ -7494,13 +7719,13 @@ const ReplicasColumnRenderer = (i18n2) => {
7494
7719
  }
7495
7720
  };
7496
7721
  };
7497
- const AgeColumnRenderer = (i18n2) => {
7722
+ const AgeColumnRenderer = () => {
7498
7723
  const dataIndex = ["metadata", "creationTimestamp"];
7499
7724
  return {
7500
7725
  key: "creationTimestamp",
7501
7726
  display: true,
7502
7727
  dataIndex,
7503
- title: i18n2.t("created_time"),
7728
+ title: i18n.t("dovetail.created_time"),
7504
7729
  sortable: true,
7505
7730
  sorter: (a, b) => {
7506
7731
  const valA = new Date(lodash.exports.get(a, dataIndex));
@@ -7516,55 +7741,56 @@ const AgeColumnRenderer = (i18n2) => {
7516
7741
  }
7517
7742
  };
7518
7743
  };
7519
- const NodeNameColumnRenderer = (i18n2) => {
7744
+ const NodeNameColumnRenderer = (options) => {
7520
7745
  const dataIndex = ["spec", "nodeName"];
7521
7746
  return {
7522
7747
  key: "node",
7523
7748
  display: true,
7524
7749
  dataIndex,
7525
- title: i18n2.t("node_name"),
7750
+ title: i18n.t("dovetail.node_name"),
7526
7751
  sortable: true,
7527
- sorter: CommonSorter(dataIndex)
7752
+ sorter: CommonSorter(dataIndex),
7753
+ ...options
7528
7754
  };
7529
7755
  };
7530
- const RestartCountColumnRenderer = (i18n2) => {
7756
+ const RestartCountColumnRenderer = () => {
7531
7757
  const dataIndex = ["restartCount"];
7532
7758
  return {
7533
7759
  key: "restartCount",
7534
7760
  display: true,
7535
7761
  dataIndex,
7536
- title: i18n2.t("restarts"),
7762
+ title: i18n.t("dovetail.restarts"),
7537
7763
  sortable: true,
7538
7764
  sorter: CommonSorter(dataIndex)
7539
7765
  };
7540
7766
  };
7541
- const CompletionsCountColumnRenderer = (i18n2) => {
7767
+ const CompletionsCountColumnRenderer = () => {
7542
7768
  const dataIndex = ["completionsDisplay"];
7543
7769
  return {
7544
7770
  key: "completions",
7545
7771
  display: true,
7546
7772
  dataIndex,
7547
- title: i18n2.t("completions"),
7773
+ title: i18n.t("completions"),
7548
7774
  sortable: true,
7549
7775
  sorter: CommonSorter(dataIndex)
7550
7776
  };
7551
7777
  };
7552
- const DurationColumnRenderer = (i18n2) => {
7778
+ const DurationColumnRenderer = () => {
7553
7779
  const dataIndex = ["durationDisplay"];
7554
7780
  return {
7555
7781
  key: "duration",
7556
7782
  display: true,
7557
7783
  dataIndex,
7558
- title: i18n2.t("duration"),
7784
+ title: i18n.t("dovetail.duration"),
7559
7785
  sortable: true,
7560
7786
  sorter: CommonSorter(dataIndex)
7561
7787
  };
7562
7788
  };
7563
- const ServiceTypeColumnRenderer = (i18n2) => {
7564
- const dataIndex = ["rawYaml", "spec", "type"];
7789
+ const ServiceTypeColumnRenderer = () => {
7790
+ const dataIndex = ["spec", "type"];
7565
7791
  return {
7566
7792
  key: "type",
7567
- title: i18n2.t("dovetail.type"),
7793
+ title: i18n.t("dovetail.type"),
7568
7794
  display: true,
7569
7795
  dataIndex,
7570
7796
  sortable: true,
@@ -7586,6 +7812,7 @@ function download(filename, content) {
7586
7812
  function useDownloadYAML() {
7587
7813
  return function(options) {
7588
7814
  const { name: name2, item } = options;
7815
+ console.log("download", item);
7589
7816
  const content = yaml.dump(item);
7590
7817
  download(`${name2}.yaml`, content);
7591
7818
  };
@@ -7611,8 +7838,9 @@ function useEdit() {
7611
7838
  return { edit: edit2 };
7612
7839
  }
7613
7840
  function K8sDropdown(props) {
7614
- const { data: data2 } = props;
7841
+ const { record } = props;
7615
7842
  const kit = useUIKit();
7843
+ const { globalStore } = useGlobalStore();
7616
7844
  const useResourceResult = useResource();
7617
7845
  const resource = useResourceResult.resource;
7618
7846
  const { edit: edit2 } = useEdit();
@@ -7630,11 +7858,11 @@ function K8sDropdown(props) {
7630
7858
  kit.menuItem,
7631
7859
  {
7632
7860
  onClick: () => {
7633
- if (data2.id) {
7634
- edit2(data2.id);
7861
+ if (record.id) {
7862
+ edit2(record.id);
7635
7863
  }
7636
7864
  },
7637
- children: /* @__PURE__ */ jsxRuntime.exports.jsx(Icon, { src: EditPen16PrimaryIcon, children: t("edit") })
7865
+ children: /* @__PURE__ */ jsxRuntime.exports.jsx(Icon, { src: EditPen16PrimaryIcon, children: t("dovetail.edit") })
7638
7866
  }
7639
7867
  ),
7640
7868
  /* @__PURE__ */ jsxRuntime.exports.jsx(
@@ -7642,9 +7870,9 @@ function K8sDropdown(props) {
7642
7870
  {
7643
7871
  danger: true,
7644
7872
  onClick: () => {
7645
- openDeleteConfirmModal(data2.id);
7873
+ openDeleteConfirmModal(record.id);
7646
7874
  },
7647
- children: /* @__PURE__ */ jsxRuntime.exports.jsx(Icon, { src: TrashBinDelete16Icon, children: t("delete") })
7875
+ children: /* @__PURE__ */ jsxRuntime.exports.jsx(Icon, { src: TrashBinDelete16Icon, children: t("dovetail.delete") })
7648
7876
  }
7649
7877
  ),
7650
7878
  /* @__PURE__ */ jsxRuntime.exports.jsx(
@@ -7652,14 +7880,14 @@ function K8sDropdown(props) {
7652
7880
  {
7653
7881
  onClick: () => {
7654
7882
  var _a;
7655
- if (data2.id) {
7883
+ if (record.id) {
7656
7884
  download2({
7657
- name: ((_a = data2.metadata) == null ? void 0 : _a.name) || data2.kind || "",
7658
- item: data2
7885
+ name: ((_a = record.metadata) == null ? void 0 : _a.name) || record.kind || "",
7886
+ item: (globalStore == null ? void 0 : globalStore.restoreItem(record)) || record
7659
7887
  });
7660
7888
  }
7661
7889
  },
7662
- children: /* @__PURE__ */ jsxRuntime.exports.jsx(Icon, { src: Download16GradientBlueIcon, children: t("download_yaml") })
7890
+ children: /* @__PURE__ */ jsxRuntime.exports.jsx(Icon, { src: Download16GradientBlueIcon, children: t("dovetail.download_yaml") })
7663
7891
  }
7664
7892
  ),
7665
7893
  props.children
@@ -7852,9 +8080,13 @@ const useEagleTable = (params) => {
7852
8080
  const { columns, tableProps, formatter, Dropdown = K8sDropdown } = params;
7853
8081
  const [selectedKeys, setSelectedKeys] = useState([]);
7854
8082
  const [currentPage, setCurrentPage] = useState((tableProps == null ? void 0 : tableProps.currentPage) || 1);
8083
+ const { resource } = useResource();
7855
8084
  const { value: nsFilter } = useNamespacesFilter();
7856
8085
  const useTableParams = useMemo(() => {
7857
8086
  const mergedParams = merge(params.useTableParams, {
8087
+ pagination: {
8088
+ mode: "off"
8089
+ },
7858
8090
  filters: {
7859
8091
  permanent: [
7860
8092
  {
@@ -7874,20 +8106,13 @@ const useEagleTable = (params) => {
7874
8106
  },
7875
8107
  [setCurrentPage]
7876
8108
  );
7877
- const actionColumn = {
7878
- key: "action",
7879
- display: true,
7880
- dataIndex: [],
7881
- title: () => /* @__PURE__ */ jsxRuntime.exports.jsx(Icon, { src: SettingsGear16GradientGrayIcon }),
7882
- render: (_, record) => {
7883
- return /* @__PURE__ */ jsxRuntime.exports.jsx(Dropdown, { data: record });
7884
- }
7885
- };
7886
- const finalDataSource = (_a = table.tableQueryResult.data) == null ? void 0 : _a.data.map(formatter);
8109
+ const data2 = (_a = table.tableQueryResult.data) == null ? void 0 : _a.data;
8110
+ const finalDataSource = formatter ? data2 == null ? void 0 : data2.map(formatter) : data2;
7887
8111
  const finalProps = {
8112
+ tableKey: (resource == null ? void 0 : resource.name) || "table",
7888
8113
  loading: table.tableQueryResult.isLoading,
7889
- dataSource: finalDataSource || [],
7890
- columns: [...columns, actionColumn],
8114
+ data: finalDataSource || [],
8115
+ columns,
7891
8116
  refetch: () => null,
7892
8117
  error: false,
7893
8118
  rowKey: "id",
@@ -7896,7 +8121,8 @@ const useEagleTable = (params) => {
7896
8121
  onPageChange,
7897
8122
  onSelect: (keys) => {
7898
8123
  setSelectedKeys(keys);
7899
- }
8124
+ },
8125
+ RowMenu: Dropdown
7900
8126
  };
7901
8127
  return { tableProps: finalProps, selectedKeys, ...table };
7902
8128
  };
@@ -8003,7 +8229,6 @@ function KeyValueInput(props) {
8003
8229
  const onValueChange = useCallback(
8004
8230
  (event2) => {
8005
8231
  var _a;
8006
- console.log(event2);
8007
8232
  const value = event2.target.value;
8008
8233
  (_a = props.onChange) == null ? void 0 : _a.call(props, {
8009
8234
  ...item,
@@ -8056,7 +8281,6 @@ function KeyValueListWidget(props) {
8056
8281
  {
8057
8282
  item,
8058
8283
  onChange: (newItem) => {
8059
- console.log(newItem);
8060
8284
  const temp = [...items];
8061
8285
  temp.splice(index, 1, newItem);
8062
8286
  onChange(temp);
@@ -8104,9 +8328,9 @@ function addId(arr, idKey) {
8104
8328
  });
8105
8329
  }
8106
8330
  const ErrorContent_1t51xnx = "";
8107
- const ErrorWrapper = "eckm4od";
8108
- const ErrorContent = "e1hl982n";
8109
- const WidgetErrorContent = (props) => {
8331
+ const ErrorWrapper$1 = "eckm4od";
8332
+ const ErrorContent$1 = "e1hl982n";
8333
+ const WidgetErrorContent$1 = (props) => {
8110
8334
  const {
8111
8335
  refetch
8112
8336
  } = props;
@@ -8115,10 +8339,10 @@ const WidgetErrorContent = (props) => {
8115
8339
  t
8116
8340
  } = useTranslation();
8117
8341
  return /* @__PURE__ */ jsxRuntime.exports.jsx("div", {
8118
- className: ErrorWrapper,
8342
+ className: ErrorWrapper$1,
8119
8343
  style: props.style,
8120
8344
  children: /* @__PURE__ */ jsxRuntime.exports.jsxs("div", {
8121
- className: ErrorContent,
8345
+ className: ErrorContent$1,
8122
8346
  children: [/* @__PURE__ */ jsxRuntime.exports.jsx("p", {
8123
8347
  className: cx_default(Typo.Label.l1_regular_title, "title"),
8124
8348
  children: props.errorText || t("dovetail.obtain_data_error")
@@ -8142,28 +8366,28 @@ const ConditionsTable = ({ conditions = [] }) => {
8142
8366
  key: "type",
8143
8367
  display: true,
8144
8368
  dataIndex: "type",
8145
- title: t("condition"),
8369
+ title: t("dovetail.condition"),
8146
8370
  sortable: true
8147
8371
  },
8148
8372
  {
8149
8373
  key: "status",
8150
8374
  display: true,
8151
8375
  dataIndex: "status",
8152
- title: t("status"),
8376
+ title: t("dovetail.status"),
8153
8377
  sortable: true
8154
8378
  },
8155
8379
  {
8156
8380
  key: "reason",
8157
8381
  display: true,
8158
8382
  dataIndex: "reason",
8159
- title: t("reason"),
8383
+ title: t("dovetail.reason"),
8160
8384
  sortable: true
8161
8385
  },
8162
8386
  {
8163
8387
  key: "lastUpdateTime",
8164
8388
  display: true,
8165
8389
  dataIndex: "lastUpdateTime",
8166
- title: t("updated_time"),
8390
+ title: t("dovetail.updated_time"),
8167
8391
  sortable: true,
8168
8392
  render: (value, record) => {
8169
8393
  const time = value || record.lastTransitionTime;
@@ -8174,12 +8398,12 @@ const ConditionsTable = ({ conditions = [] }) => {
8174
8398
  key: "message",
8175
8399
  display: true,
8176
8400
  dataIndex: "message",
8177
- title: t("message"),
8401
+ title: t("dovetail.message"),
8178
8402
  sortable: true
8179
8403
  }
8180
8404
  ];
8181
8405
  if (conditionsWithId.length === 0) {
8182
- return /* @__PURE__ */ jsxRuntime.exports.jsx(WidgetErrorContent, { errorText: t("dovetail.empty"), style: { padding: "15px 0" } });
8406
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(WidgetErrorContent$1, { errorText: t("dovetail.empty"), style: { padding: "15px 0" } });
8183
8407
  }
8184
8408
  return /* @__PURE__ */ jsxRuntime.exports.jsx(
8185
8409
  kit.table,
@@ -8192,1028 +8416,574 @@ const ConditionsTable = ({ conditions = [] }) => {
8192
8416
  }
8193
8417
  );
8194
8418
  };
8195
- function getSecondsDiff(startDate, endDate) {
8196
- return Math.round(Math.abs(Date.parse(endDate) - Date.parse(startDate)) / 1e3);
8419
+ function memoize(fn) {
8420
+ var cache = /* @__PURE__ */ Object.create(null);
8421
+ return function(arg) {
8422
+ if (cache[arg] === void 0)
8423
+ cache[arg] = fn(arg);
8424
+ return cache[arg];
8425
+ };
8197
8426
  }
8198
- function elapsedTime(seconds) {
8199
- if (!seconds) {
8200
- return {};
8427
+ var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
8428
+ var isPropValid = /* @__PURE__ */ memoize(
8429
+ function(prop) {
8430
+ return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110 && prop.charCodeAt(2) < 91;
8201
8431
  }
8202
- if (seconds < 120) {
8203
- return {
8204
- diff: 1,
8205
- label: `${seconds}s`
8206
- };
8432
+ );
8433
+ var isCapital = (ch) => ch.toUpperCase() === ch;
8434
+ var filterKey = (keys) => (key) => keys.indexOf(key) === -1;
8435
+ var omit = (obj, keys) => {
8436
+ const res = {};
8437
+ Object.keys(obj).filter(filterKey(keys)).forEach((key) => {
8438
+ res[key] = obj[key];
8439
+ });
8440
+ return res;
8441
+ };
8442
+ function filterProps(asIs, props, omitKeys) {
8443
+ const filteredProps = omit(props, omitKeys);
8444
+ if (!asIs) {
8445
+ const interopValidAttr = typeof isPropValid === "function" ? { default: isPropValid } : isPropValid;
8446
+ Object.keys(filteredProps).forEach((key) => {
8447
+ if (!interopValidAttr.default(key)) {
8448
+ delete filteredProps[key];
8449
+ }
8450
+ });
8207
8451
  }
8208
- const minutes = Math.floor(seconds / 60);
8209
- if (minutes < 10) {
8210
- return {
8211
- diff: 1,
8212
- label: `${minutes}m${seconds - minutes * 60}s`
8213
- };
8214
- }
8215
- const hours = Math.floor(seconds / 3600);
8216
- if (hours < 3) {
8217
- return {
8218
- diff: 60,
8219
- label: `${minutes}m`
8220
- };
8221
- }
8222
- const days = Math.floor(seconds / (3600 * 24));
8223
- if (days > 1) {
8224
- return {
8225
- diff: 60,
8226
- label: `${days}d${hours - days * 24}h`
8227
- };
8228
- }
8229
- if (hours > 7) {
8230
- return {
8231
- diff: 60,
8232
- label: `${hours}h`
8233
- };
8234
- }
8235
- return {
8236
- diff: 60,
8237
- label: `${hours}h${minutes - hours * 60}m`
8238
- };
8452
+ return filteredProps;
8239
8453
  }
8240
- const BASE_INIT_VALUE = {
8241
- metadata: {
8242
- name: "",
8243
- namespace: "default",
8244
- annotations: {},
8245
- labels: {}
8246
- }
8247
- };
8248
- const DEFAULT_MATCH_LABEL = "sks.user.kubesmart.smtx.io/app";
8249
- const BASE_CONTAINER_INIT_VALUE = {
8250
- name: "container-0",
8251
- imagePullPolicy: "Always",
8252
- image: ""
8253
- };
8254
- const BASE_WORKLOAD_SPEC_INIT_VALUE = {
8255
- affinity: {},
8256
- imagePullSecrets: [],
8257
- initContainers: [],
8258
- volumes: []
8259
- };
8260
- const DEPLOYMENT_INIT_VALUE = {
8261
- apiVersion: "apps/v1",
8262
- kind: "Deployment",
8263
- ...BASE_INIT_VALUE,
8264
- spec: {
8265
- replicas: 1,
8266
- selector: {
8267
- matchLabels: {
8268
- [DEFAULT_MATCH_LABEL]: ""
8269
- }
8270
- },
8271
- template: {
8272
- metadata: {
8273
- labels: {
8274
- [DEFAULT_MATCH_LABEL]: ""
8275
- }
8276
- },
8277
- spec: {
8278
- containers: [BASE_CONTAINER_INIT_VALUE],
8279
- restartPolicy: "Always",
8280
- ...BASE_WORKLOAD_SPEC_INIT_VALUE
8281
- }
8454
+ var warnIfInvalid = (value, componentName) => {
8455
+ if (process.env.NODE_ENV !== "production") {
8456
+ if (typeof value === "string" || typeof value === "number" && isFinite(value)) {
8457
+ return;
8282
8458
  }
8459
+ const stringified = typeof value === "object" ? JSON.stringify(value) : String(value);
8460
+ console.warn(
8461
+ `An interpolation evaluated to '${stringified}' in the component '${componentName}', which is probably a mistake. You should explicitly cast or transform the value to a string.`
8462
+ );
8283
8463
  }
8284
8464
  };
8285
- const CRONJOB_INIT_VALUE = {
8286
- apiVersion: "batch/v1beta1",
8287
- kind: "CronJob",
8288
- ...BASE_INIT_VALUE,
8289
- spec: {
8290
- schedule: "",
8291
- jobTemplate: {
8292
- metadata: {
8293
- labels: {}
8294
- },
8295
- spec: {
8296
- template: {
8297
- spec: {
8298
- containers: [BASE_CONTAINER_INIT_VALUE],
8299
- restartPolicy: "Never",
8300
- ...BASE_WORKLOAD_SPEC_INIT_VALUE
8301
- }
8302
- }
8303
- }
8465
+ var idx = 0;
8466
+ function styled(tag) {
8467
+ var _a;
8468
+ let mockedClass = "";
8469
+ if (process.env.NODE_ENV === "test") {
8470
+ mockedClass += `mocked-styled-${idx++}`;
8471
+ if ((_a = tag == null ? void 0 : tag.__linaria) == null ? void 0 : _a.className) {
8472
+ mockedClass += ` ${tag.__linaria.className}`;
8304
8473
  }
8305
8474
  }
8306
- };
8307
- const DAEMONSET_INIT_VALUE = {
8308
- apiVersion: "apps/v1",
8309
- kind: "DaemonSet",
8310
- ...BASE_INIT_VALUE,
8311
- spec: {
8312
- replicas: 1,
8313
- selector: {
8314
- matchLabels: {
8315
- [DEFAULT_MATCH_LABEL]: ""
8475
+ return (options) => {
8476
+ if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test") {
8477
+ if (Array.isArray(options)) {
8478
+ throw new Error(
8479
+ 'Using the "styled" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly. See https://github.com/callstack/linaria#setup'
8480
+ );
8316
8481
  }
8317
- },
8318
- template: {
8319
- metadata: {
8320
- labels: {
8321
- [DEFAULT_MATCH_LABEL]: ""
8482
+ }
8483
+ const render = (props, ref) => {
8484
+ const { as: component = tag, class: className = mockedClass } = props;
8485
+ const shouldKeepProps = options.propsAsIs === void 0 ? !(typeof component === "string" && component.indexOf("-") === -1 && !isCapital(component[0])) : options.propsAsIs;
8486
+ const filteredProps = filterProps(shouldKeepProps, props, [
8487
+ "as",
8488
+ "class"
8489
+ ]);
8490
+ filteredProps.ref = ref;
8491
+ filteredProps.className = options.atomic ? cx_default(options.class, filteredProps.className || className) : cx_default(filteredProps.className || className, options.class);
8492
+ const { vars } = options;
8493
+ if (vars) {
8494
+ const style = {};
8495
+ for (const name2 in vars) {
8496
+ const variable = vars[name2];
8497
+ const result = variable[0];
8498
+ const unit = variable[1] || "";
8499
+ const value = typeof result === "function" ? result(props) : result;
8500
+ warnIfInvalid(value, options.name);
8501
+ style[`--${name2}`] = `${value}${unit}`;
8322
8502
  }
8323
- },
8324
- spec: {
8325
- containers: [BASE_CONTAINER_INIT_VALUE],
8326
- restartPolicy: "Always",
8327
- ...BASE_WORKLOAD_SPEC_INIT_VALUE
8503
+ const ownStyle = filteredProps.style || {};
8504
+ const keys = Object.keys(ownStyle);
8505
+ if (keys.length > 0) {
8506
+ keys.forEach((key) => {
8507
+ style[key] = ownStyle[key];
8508
+ });
8509
+ }
8510
+ filteredProps.style = style;
8328
8511
  }
8329
- }
8330
- }
8331
- };
8332
- const JOB_INIT_VALUE = {
8333
- apiVersion: "batch/v1",
8334
- kind: "Job",
8335
- ...BASE_INIT_VALUE,
8336
- spec: {
8337
- replicas: 1,
8338
- selector: {
8339
- matchLabels: {}
8340
- },
8341
- template: {
8342
- metadata: {
8343
- labels: {}
8344
- },
8345
- spec: {
8346
- containers: [BASE_CONTAINER_INIT_VALUE],
8347
- restartPolicy: "Never",
8348
- ...BASE_WORKLOAD_SPEC_INIT_VALUE
8512
+ if (tag.__linaria && tag !== component) {
8513
+ filteredProps.as = component;
8514
+ return React.createElement(tag, filteredProps);
8349
8515
  }
8350
- }
8516
+ return React.createElement(component, filteredProps);
8517
+ };
8518
+ const Result = React.forwardRef ? React.forwardRef(render) : (props) => {
8519
+ const rest = omit(props, ["innerRef"]);
8520
+ return render(rest, props.innerRef);
8521
+ };
8522
+ Result.displayName = options.name;
8523
+ Result.__linaria = {
8524
+ className: options.class || mockedClass,
8525
+ extends: tag
8526
+ };
8527
+ return Result;
8528
+ };
8529
+ }
8530
+ var styled_default = process.env.NODE_ENV !== "production" ? new Proxy(styled, {
8531
+ get(o, prop) {
8532
+ return o(prop);
8351
8533
  }
8352
- };
8353
- const STATEFULSET_INIT_VALUE = {
8354
- apiVersion: "apps/v1",
8355
- kind: "StatefulSet",
8356
- ...BASE_INIT_VALUE,
8357
- spec: {
8358
- replicas: 1,
8359
- selector: {
8360
- matchLabels: {
8361
- [DEFAULT_MATCH_LABEL]: ""
8362
- }
8363
- },
8364
- template: {
8365
- metadata: {
8366
- labels: {
8367
- [DEFAULT_MATCH_LABEL]: ""
8534
+ }) : styled;
8535
+ const TableWidgets_ny30pi = "";
8536
+ const AuxiliaryLine = /* @__PURE__ */ styled_default("div")({
8537
+ name: "AuxiliaryLine",
8538
+ class: "ax1qopv",
8539
+ propsAsIs: false
8540
+ });
8541
+ const index_dmbxj3 = "";
8542
+ const TableContainerStyle = "t1upn1sz";
8543
+ function Table(props) {
8544
+ const kit = useUIKit();
8545
+ const {
8546
+ t
8547
+ } = useTranslation();
8548
+ const {
8549
+ loading,
8550
+ error,
8551
+ data: dataSource,
8552
+ rowKey,
8553
+ columns,
8554
+ scroll,
8555
+ currentPage,
8556
+ currentSize,
8557
+ RowMenu,
8558
+ refetch,
8559
+ onSelect,
8560
+ onPageChange,
8561
+ onSizeChange
8562
+ } = props;
8563
+ const auxiliaryLineRef = useRef(null);
8564
+ const wrapperRef = useRef(null);
8565
+ const pagination = useMemo(() => ({
8566
+ current: currentPage,
8567
+ pageSize: currentSize,
8568
+ onChange: onPageChange
8569
+ }), [currentPage, currentSize, onPageChange]);
8570
+ const finalColumns = useMemo(() => {
8571
+ if (RowMenu) {
8572
+ const actionColumn = {
8573
+ key: "_action_",
8574
+ display: true,
8575
+ dataIndex: [],
8576
+ title: "",
8577
+ render: (_, record) => {
8578
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(RowMenu, {
8579
+ record
8580
+ });
8368
8581
  }
8369
- },
8370
- spec: {
8371
- containers: [BASE_CONTAINER_INIT_VALUE],
8372
- restartPolicy: "Always",
8373
- ...BASE_WORKLOAD_SPEC_INIT_VALUE
8374
- }
8582
+ };
8583
+ return [...columns, actionColumn];
8375
8584
  }
8376
- }
8377
- };
8378
- const POD_INIT_VALUE = {
8379
- apiVersion: "v1",
8380
- kind: "Pod",
8381
- ...BASE_INIT_VALUE,
8382
- spec: {
8383
- containers: [BASE_CONTAINER_INIT_VALUE]
8384
- }
8385
- };
8386
- const TIMESTAMP_LABEL = "sks.user.kubesmart.smtx.io/timestamp";
8387
- function shortenedImage(image2) {
8388
- return (image2 || "").replace(/^(index\.)?docker.io\/(library\/)?/, "").replace(/:latest$/, "").replace(/^(.*@sha256:)([0-9a-f]{8})[0-9a-f]+$/i, "$1$2\u2026");
8389
- }
8390
- class ResourceModel {
8391
- constructor(rawYaml) {
8392
- __publicField(this, "id");
8393
- __publicField(this, "apiVersion");
8394
- __publicField(this, "kind");
8395
- __publicField(this, "metadata");
8396
- this.rawYaml = rawYaml;
8397
- this.id = rawYaml.id;
8398
- this.apiVersion = rawYaml.apiVersion;
8399
- this.kind = rawYaml.kind;
8400
- this.metadata = rawYaml.metadata;
8401
- }
8402
- get name() {
8403
- var _a;
8404
- return (_a = this.rawYaml.metadata) == null ? void 0 : _a.name;
8405
- }
8406
- get namespace() {
8407
- var _a;
8408
- return (_a = this.rawYaml.metadata) == null ? void 0 : _a.namespace;
8409
- }
8410
- get labels() {
8411
- var _a;
8412
- return (_a = this.rawYaml.metadata) == null ? void 0 : _a.labels;
8413
- }
8414
- get annotations() {
8415
- var _a;
8416
- return (_a = this.rawYaml.metadata) == null ? void 0 : _a.annotations;
8417
- }
8418
- }
8419
- class WorkloadModel extends ResourceModel {
8420
- constructor(rawYaml) {
8421
- super(rawYaml);
8422
- this.rawYaml = rawYaml;
8423
- }
8424
- get status() {
8425
- return this.rawYaml.status;
8426
- }
8427
- get spec() {
8428
- return this.rawYaml.spec;
8429
- }
8430
- get imageNames() {
8431
- var _a, _b, _c, _d;
8432
- const containers = this.rawYaml.spec && "jobTemplate" in this.rawYaml.spec ? (_b = (_a = this.rawYaml.spec.jobTemplate.spec) == null ? void 0 : _a.template.spec) == null ? void 0 : _b.containers : this.rawYaml.spec && "template" in this.rawYaml.spec ? (_d = (_c = this.rawYaml.spec) == null ? void 0 : _c.template.spec) == null ? void 0 : _d.containers : [];
8433
- return (containers == null ? void 0 : containers.map((container2) => shortenedImage(container2.image || ""))) || [];
8434
- }
8435
- get restartCount() {
8436
- return 0;
8437
- }
8438
- redeploy() {
8439
- const newOne = cloneDeep(this.rawYaml);
8440
- const path = "spec.template.metadata.annotations";
8441
- const annotations = get(newOne, path, {});
8442
- set(newOne, path, {
8443
- ...annotations,
8444
- [TIMESTAMP_LABEL]: new Date().toISOString().replace(/\.\d+Z$/, "Z")
8585
+ return columns;
8586
+ }, [columns, RowMenu]);
8587
+ if (loading) {
8588
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(kit.loading, {});
8589
+ } else if (error) {
8590
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(WidgetErrorContent$1, {
8591
+ errorText: t("dovetail.retry_when_access_data_failed"),
8592
+ refetch,
8593
+ style: {
8594
+ padding: "15px 0"
8595
+ }
8596
+ });
8597
+ } else if (dataSource.length === 0) {
8598
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(WidgetErrorContent$1, {
8599
+ errorText: t("dovetail.empty"),
8600
+ style: {
8601
+ padding: "15px 0"
8602
+ }
8445
8603
  });
8446
- return newOne;
8447
8604
  }
8448
- scale(value) {
8449
- const newOne = cloneDeep(this.rawYaml);
8450
- if (newOne.kind === "Deployment" || newOne.kind === "StatefulSet") {
8451
- set(newOne, "spec.replicas", value);
8605
+ return /* @__PURE__ */ jsxRuntime.exports.jsxs("div", {
8606
+ ref: wrapperRef,
8607
+ className: cx_default(TableContainerStyle, props.className, "table-wrapper"),
8608
+ children: [/* @__PURE__ */ jsxRuntime.exports.jsx(kit.table, {
8609
+ tableLayout: "fixed",
8610
+ rowSelection: onSelect ? {
8611
+ onChange: (keys, rows) => {
8612
+ onSelect == null ? void 0 : onSelect(keys, rows);
8613
+ }
8614
+ } : void 0,
8615
+ columns: finalColumns,
8616
+ dataSource,
8617
+ pagination,
8618
+ error,
8619
+ loading,
8620
+ rowKey,
8621
+ wrapper: wrapperRef,
8622
+ scroll
8623
+ }), /* @__PURE__ */ jsxRuntime.exports.jsx(AuxiliaryLine, {
8624
+ ref: auxiliaryLineRef
8625
+ }), /* @__PURE__ */ jsxRuntime.exports.jsx(kit.pagination, {
8626
+ current: currentPage,
8627
+ size: currentSize,
8628
+ count: dataSource.length,
8629
+ onChange: onPageChange,
8630
+ onSizeChange
8631
+ })]
8632
+ });
8633
+ }
8634
+ function CreateButton() {
8635
+ const { resource } = useResource();
8636
+ const navigation = useNavigation();
8637
+ const go = useGo();
8638
+ const kit = useUIKit();
8639
+ const { t } = useTranslation();
8640
+ const onClick = useCallback(() => {
8641
+ if (resource == null ? void 0 : resource.name) {
8642
+ go({
8643
+ to: navigation.createUrl(resource.name),
8644
+ options: {
8645
+ keepQuery: true
8646
+ }
8647
+ });
8452
8648
  }
8453
- return newOne;
8454
- }
8649
+ }, [resource == null ? void 0 : resource.name]);
8650
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(kit.button, { type: "primary", onClick, children: t("dovetail.create") });
8455
8651
  }
8456
- class JobModel extends WorkloadModel {
8457
- constructor(rawYaml) {
8458
- super(rawYaml);
8459
- this.rawYaml = rawYaml;
8460
- }
8461
- get duration() {
8462
- var _a, _b;
8463
- const completionTime = (_a = this.rawYaml.status) == null ? void 0 : _a.completionTime;
8464
- const startTime = (_b = this.rawYaml.status) == null ? void 0 : _b.startTime;
8465
- if (!completionTime && startTime) {
8466
- return getSecondsDiff(startTime, Date.now().toString());
8652
+ const useDeleteManyModal = (resource, ids) => {
8653
+ const { mutate } = useDeleteMany();
8654
+ const [visible, setVisible] = useState(false);
8655
+ const { t } = useTranslation();
8656
+ const modalProps = {
8657
+ title: t("dovetail.delete"),
8658
+ okText: t("dovetail.delete"),
8659
+ okButtonProps: {
8660
+ danger: true
8661
+ },
8662
+ cancelText: t("dovetail.cancel"),
8663
+ children: t("dovetail.confirm_delete_text", {
8664
+ target: ids,
8665
+ interpolation: { escapeValue: false }
8666
+ }),
8667
+ onOk() {
8668
+ mutate({
8669
+ resource,
8670
+ ids
8671
+ });
8672
+ setVisible(false);
8673
+ },
8674
+ onCancel() {
8675
+ setVisible(false);
8467
8676
  }
8468
- if (completionTime && startTime) {
8469
- return getSecondsDiff(startTime, completionTime);
8677
+ };
8678
+ return { modalProps, visible, setVisible };
8679
+ };
8680
+ const DeleteManyButton = (props) => {
8681
+ const { resource } = useResource();
8682
+ const kit = useUIKit();
8683
+ const { t } = useTranslation();
8684
+ const { modalProps, visible, setVisible } = useDeleteManyModal(
8685
+ (resource == null ? void 0 : resource.name) || "",
8686
+ props.ids
8687
+ );
8688
+ const onClick = useCallback(() => {
8689
+ setVisible(true);
8690
+ }, [setVisible]);
8691
+ return /* @__PURE__ */ jsxRuntime.exports.jsxs(jsxRuntime.exports.Fragment, { children: [
8692
+ /* @__PURE__ */ jsxRuntime.exports.jsx(kit.button, { type: "primary", danger: true, onClick, children: t("dovetail.delete") }),
8693
+ visible ? /* @__PURE__ */ jsxRuntime.exports.jsx(kit.modal, { ...modalProps }) : null
8694
+ ] });
8695
+ };
8696
+ const TableToolBar_1a3t35p = "";
8697
+ const ToolbarStyle$1 = "t1v3ienx";
8698
+ const TableToolBar = ({
8699
+ title,
8700
+ selectedKeys,
8701
+ hideCreate
8702
+ }) => {
8703
+ const kit = useUIKit();
8704
+ return /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.space, {
8705
+ className: cx_default(ToolbarStyle$1, "table-toolbar"),
8706
+ children: [/* @__PURE__ */ jsxRuntime.exports.jsx("span", {
8707
+ className: Typo.Display.d2_bold_title,
8708
+ children: title
8709
+ }), /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.space, {
8710
+ children: [selectedKeys.length > 0 ? /* @__PURE__ */ jsxRuntime.exports.jsx(DeleteManyButton, {
8711
+ ids: selectedKeys
8712
+ }) : void 0, !hideCreate ? /* @__PURE__ */ jsxRuntime.exports.jsx(CreateButton, {}) : null]
8713
+ })]
8714
+ });
8715
+ };
8716
+ const index_1hr2h38 = "";
8717
+ function matchOwner(job, owner) {
8718
+ var _a;
8719
+ let match = false;
8720
+ for (const o of ((_a = job.metadata) == null ? void 0 : _a.ownerReferences) || []) {
8721
+ if (o.apiVersion === owner.apiVersion && o.kind === owner.kind && o.name === owner.name && job.namespace === owner.namespace) {
8722
+ match = true;
8470
8723
  }
8471
- return 0;
8472
- }
8473
- get durationDisplay() {
8474
- return elapsedTime(this.duration).label;
8475
- }
8476
- get completionsDisplay() {
8477
- var _a, _b;
8478
- return `${((_a = this.rawYaml.status) == null ? void 0 : _a.succeeded) || 0}/${(_b = this.rawYaml.spec) == null ? void 0 : _b.completions}`;
8479
8724
  }
8725
+ return match;
8480
8726
  }
8481
- const UNITS = ["", "K", "M", "G", "T", "P"];
8482
- const FRACTIONAL = ["", "m", "u", "n", "p", "f"];
8483
- function formatSi(inValue, options) {
8727
+ const CronjobJobsTable = ({
8728
+ owner
8729
+ }) => {
8730
+ const kit = useUIKit();
8731
+ const [selectedKeys, setSelectedKeys] = useState([]);
8732
+ const [currentPage, setCurrentPage] = useState(1);
8484
8733
  const {
8485
- increment = 1e3,
8486
- suffix = null,
8487
- firstSuffix = null,
8488
- startingExponent = 0,
8489
- minExponent = 0,
8490
- maxPrecision = 2,
8491
- atLeastOne = true
8492
- } = options || {};
8493
- let val = inValue;
8494
- let exp = startingExponent;
8495
- while (val >= increment && exp + 1 < UNITS.length || exp < minExponent) {
8496
- val = val / increment;
8497
- exp++;
8498
- }
8499
- let out = 0;
8500
- if (val < 10 && maxPrecision >= 2) {
8501
- out = Math.round(val * 100) / 100;
8502
- } else if (val < 100 && maxPrecision >= 1) {
8503
- out = Math.round(val * 10) / 10;
8504
- } else {
8505
- out = Math.round(val);
8506
- }
8507
- if (atLeastOne && out === 0) {
8508
- out = 1;
8509
- }
8510
- let outStr = String(out);
8511
- if (exp === 0 && firstSuffix !== null) {
8512
- outStr += `${firstSuffix}`;
8513
- } else {
8514
- outStr += `${UNITS[exp]}${suffix}` || "";
8515
- }
8516
- return outStr;
8517
- }
8518
- function parseSi(inValue, increment = null, allowFractional = true) {
8519
- if (!inValue || typeof inValue !== "string" || !inValue.length) {
8520
- return NaN;
8521
- }
8522
- inValue = inValue.replace(/,/g, "");
8523
- let [, valStr, unit, incStr] = inValue.match(/^([0-9.-]+)\s*([^0-9.-]?)([^0-9.-]?)/) || [];
8524
- const val = parseFloat(valStr);
8525
- if (!unit) {
8526
- return val;
8527
- }
8528
- if (unit.charCodeAt(0) === 181) {
8529
- unit = "u";
8530
- }
8531
- const divide = FRACTIONAL.includes(unit);
8532
- const multiply = UNITS.includes(unit.toUpperCase());
8533
- if (increment === null) {
8534
- if ((multiply || divide) && incStr === "i") {
8535
- increment = 1024;
8536
- } else {
8537
- increment = 1e3;
8734
+ data: data2
8735
+ } = useList({
8736
+ resource: "jobs",
8737
+ meta: {
8738
+ resourceBasePath: "/apis/batch/v1",
8739
+ kind: "Job"
8538
8740
  }
8741
+ });
8742
+ const dataSource = useMemo(() => {
8743
+ return data2 == null ? void 0 : data2.data.filter((p) => {
8744
+ return owner ? matchOwner(p, owner) : true;
8745
+ });
8746
+ }, [data2 == null ? void 0 : data2.data, owner]);
8747
+ const columns = [PhaseColumnRenderer(), NameColumnRenderer("jobs"), NameSpaceColumnRenderer(), WorkloadImageColumnRenderer(), CompletionsCountColumnRenderer(), DurationColumnRenderer(), AgeColumnRenderer()];
8748
+ return /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.space, {
8749
+ direction: "vertical",
8750
+ className: "c16agr8o",
8751
+ children: [/* @__PURE__ */ jsxRuntime.exports.jsx(TableToolBar, {
8752
+ title: "Jobs",
8753
+ selectedKeys,
8754
+ hideCreate: true
8755
+ }), /* @__PURE__ */ jsxRuntime.exports.jsx(Table, {
8756
+ tableKey: "cronjobs",
8757
+ loading: !dataSource,
8758
+ data: dataSource || [],
8759
+ columns,
8760
+ onSelect: (keys) => setSelectedKeys(keys),
8761
+ rowKey: "id",
8762
+ error: false,
8763
+ currentPage,
8764
+ onPageChange: (p) => setCurrentPage(p),
8765
+ currentSize: 10,
8766
+ refetch: () => null
8767
+ })]
8768
+ });
8769
+ };
8770
+ const KeyValue = ({ value }) => {
8771
+ const kit = useUIKit();
8772
+ if (!value || Object.keys.length === 0) {
8773
+ return /* @__PURE__ */ jsxRuntime.exports.jsx("div", { children: "Empty" });
8539
8774
  }
8540
- if (divide && allowFractional) {
8541
- const exp = FRACTIONAL.indexOf(unit);
8542
- return val / Math.pow(increment, exp);
8543
- }
8544
- if (multiply) {
8545
- const exp = UNITS.indexOf(unit.toUpperCase());
8546
- return val * Math.pow(increment, exp);
8547
- }
8548
- return val;
8549
- }
8550
- class PodModel extends WorkloadModel {
8551
- constructor(rawYaml) {
8552
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8553
- super(rawYaml);
8554
- __publicField(this, "request");
8555
- __publicField(this, "limit");
8556
- this.rawYaml = rawYaml;
8557
- let cpuRequestNum = 0;
8558
- let memoryRequestNum = 0;
8559
- let cpuLimitNum = 0;
8560
- let memoryLimitNum = 0;
8561
- for (const container2 of ((_a = rawYaml.spec) == null ? void 0 : _a.containers) || []) {
8562
- cpuRequestNum += parseSi(((_c = (_b = container2.resources) == null ? void 0 : _b.requests) == null ? void 0 : _c.cpu) || "0");
8563
- memoryRequestNum += parseSi(((_e = (_d = container2.resources) == null ? void 0 : _d.requests) == null ? void 0 : _e.memory) || "0");
8564
- cpuLimitNum += parseSi(((_g = (_f = container2.resources) == null ? void 0 : _f.limits) == null ? void 0 : _g.cpu) || "0");
8565
- memoryLimitNum += parseSi(((_i = (_h = container2.resources) == null ? void 0 : _h.limits) == null ? void 0 : _i.memory) || "0");
8566
- }
8567
- this.request = {
8568
- cpu: {
8569
- value: cpuRequestNum,
8570
- si: formatSi(cpuRequestNum, {
8571
- suffix: "m"
8572
- })
8573
- },
8574
- memory: {
8575
- value: memoryRequestNum,
8576
- si: formatSi(memoryRequestNum, {
8577
- suffix: "i"
8578
- })
8579
- }
8580
- };
8581
- this.limit = {
8582
- cpu: {
8583
- value: cpuLimitNum,
8584
- si: formatSi(cpuLimitNum, {
8585
- suffix: "m"
8586
- })
8587
- },
8588
- memory: {
8589
- value: memoryLimitNum,
8590
- si: formatSi(memoryLimitNum, {
8591
- suffix: "i"
8592
- })
8593
- }
8775
+ const data2 = Object.keys(value).map((key) => {
8776
+ return {
8777
+ id: key,
8778
+ key,
8779
+ value: value[key]
8594
8780
  };
8595
- }
8596
- get imageNames() {
8597
- var _a;
8598
- return ((_a = this.rawYaml.spec) == null ? void 0 : _a.containers.map(
8599
- (container2) => shortenedImage(container2.image || "")
8600
- )) || [];
8601
- }
8602
- get restartCount() {
8603
- var _a, _b;
8604
- if ((_a = this.rawYaml.status) == null ? void 0 : _a.containerStatuses) {
8605
- return ((_b = this.rawYaml.status) == null ? void 0 : _b.containerStatuses[0].restartCount) || 0;
8781
+ });
8782
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(
8783
+ kit.table,
8784
+ {
8785
+ loading: false,
8786
+ columns: [
8787
+ {
8788
+ key: "key",
8789
+ title: "Key",
8790
+ dataIndex: ["key"]
8791
+ },
8792
+ {
8793
+ key: "value",
8794
+ title: "Value",
8795
+ dataIndex: ["value"]
8796
+ }
8797
+ ],
8798
+ dataSource: data2
8606
8799
  }
8607
- return 0;
8608
- }
8609
- get readyDisplay() {
8610
- var _a, _b, _c;
8611
- return `${(_b = (_a = this.rawYaml.status) == null ? void 0 : _a.containerStatuses) == null ? void 0 : _b.filter((c) => c.ready).length}/${(_c = this.rawYaml.spec) == null ? void 0 : _c.containers.length}`;
8612
- }
8613
- }
8614
- class PodMetricsModel extends ResourceModel {
8615
- constructor(data2) {
8616
- super(data2);
8617
- __publicField(this, "usage");
8618
- this.data = data2;
8619
- let cpuUsageNum = 0;
8620
- let memoryUsageNum = 0;
8621
- for (const container2 of data2.containers) {
8622
- cpuUsageNum += parseSi(container2.usage.cpu || "0");
8623
- memoryUsageNum += parseSi(container2.usage.memory || "0");
8800
+ );
8801
+ };
8802
+ function matchSelector$1(pod, selector) {
8803
+ var _a, _b, _c;
8804
+ let match = true;
8805
+ for (const key in selector.matchLabels) {
8806
+ if (!((_b = (_a = pod.metadata) == null ? void 0 : _a.labels) == null ? void 0 : _b[key]) || ((_c = pod.metadata.labels) == null ? void 0 : _c[key]) !== selector.matchLabels[key]) {
8807
+ match = false;
8624
8808
  }
8625
- this.usage = {
8626
- cpu: {
8627
- value: cpuUsageNum,
8628
- si: formatSi(1e3 * cpuUsageNum, {
8629
- suffix: "m",
8630
- maxPrecision: 0
8631
- })
8632
- },
8633
- memory: {
8634
- value: memoryUsageNum,
8635
- si: formatSi(memoryUsageNum, {
8636
- suffix: "i",
8637
- maxPrecision: 0
8638
- })
8639
- }
8640
- };
8641
8809
  }
8810
+ return match;
8642
8811
  }
8643
- class CronJobModel extends WorkloadModel {
8644
- constructor(data2) {
8645
- super(data2);
8646
- this.data = data2;
8647
- }
8648
- suspend() {
8649
- const newOne = cloneDeep(this.data);
8650
- if (this.data.kind === "CronJob") {
8651
- set(newOne, "spec.suspend", true);
8812
+ const WorkloadPodsTable_z2tsj7 = "";
8813
+ const WorkloadPodsTable = ({
8814
+ selector
8815
+ }) => {
8816
+ const kit = useUIKit();
8817
+ const [selectedKeys, setSelectedKeys] = useState([]);
8818
+ const [currentPage, setCurrentPage] = useState(1);
8819
+ const {
8820
+ data: data2
8821
+ } = useList({
8822
+ resource: "pods",
8823
+ meta: {
8824
+ resourceBasePath: "/api/v1",
8825
+ kind: "Pod"
8652
8826
  }
8653
- return newOne;
8654
- }
8655
- resume() {
8656
- const newOne = cloneDeep(this.data);
8657
- if (this.data.kind === "CronJob") {
8658
- set(newOne, "spec.suspend", false);
8827
+ });
8828
+ const dataSource = useMemo(() => {
8829
+ return data2 == null ? void 0 : data2.data.filter((p) => {
8830
+ return selector ? matchSelector$1(p, selector) : true;
8831
+ });
8832
+ }, [data2 == null ? void 0 : data2.data, selector]);
8833
+ const columns = [PhaseColumnRenderer(), NameColumnRenderer("pods"), NodeNameColumnRenderer(), WorkloadImageColumnRenderer(), RestartCountColumnRenderer()];
8834
+ return /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.space, {
8835
+ direction: "vertical",
8836
+ className: "c1dicff8",
8837
+ children: [/* @__PURE__ */ jsxRuntime.exports.jsx(TableToolBar, {
8838
+ title: "",
8839
+ selectedKeys,
8840
+ hideCreate: true
8841
+ }), /* @__PURE__ */ jsxRuntime.exports.jsx(Table, {
8842
+ tableKey: "pods",
8843
+ loading: !dataSource,
8844
+ data: dataSource || [],
8845
+ columns,
8846
+ onSelect: (keys) => setSelectedKeys(keys),
8847
+ rowKey: "id",
8848
+ error: false,
8849
+ currentPage,
8850
+ onPageChange: (p) => setCurrentPage(p),
8851
+ currentSize: 10,
8852
+ refetch: () => null
8853
+ })]
8854
+ });
8855
+ };
8856
+ const ImageField = () => {
8857
+ return {
8858
+ key: "Image",
8859
+ title: i18n.t("dovetail.image"),
8860
+ path: ["imageNames"],
8861
+ render(value) {
8862
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(ImageNames, { value });
8659
8863
  }
8660
- return newOne;
8661
- }
8662
- }
8663
- function memoize(fn) {
8664
- var cache = /* @__PURE__ */ Object.create(null);
8665
- return function(arg) {
8666
- if (cache[arg] === void 0)
8667
- cache[arg] = fn(arg);
8668
- return cache[arg];
8669
8864
  };
8670
- }
8671
- var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
8672
- var isPropValid = /* @__PURE__ */ memoize(
8673
- function(prop) {
8674
- return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110 && prop.charCodeAt(2) < 91;
8675
- }
8676
- );
8677
- var isCapital = (ch) => ch.toUpperCase() === ch;
8678
- var filterKey = (keys) => (key) => keys.indexOf(key) === -1;
8679
- var omit = (obj, keys) => {
8680
- const res = {};
8681
- Object.keys(obj).filter(filterKey(keys)).forEach((key) => {
8682
- res[key] = obj[key];
8683
- });
8684
- return res;
8685
8865
  };
8686
- function filterProps(asIs, props, omitKeys) {
8687
- const filteredProps = omit(props, omitKeys);
8688
- if (!asIs) {
8689
- const interopValidAttr = typeof isPropValid === "function" ? { default: isPropValid } : isPropValid;
8690
- Object.keys(filteredProps).forEach((key) => {
8691
- if (!interopValidAttr.default(key)) {
8692
- delete filteredProps[key];
8693
- }
8694
- });
8695
- }
8696
- return filteredProps;
8697
- }
8698
- var warnIfInvalid = (value, componentName) => {
8699
- if (process.env.NODE_ENV !== "production") {
8700
- if (typeof value === "string" || typeof value === "number" && isFinite(value)) {
8701
- return;
8866
+ const ReplicaField = () => {
8867
+ return {
8868
+ key: "Replicas",
8869
+ title: i18n.t("dovetail.replicas"),
8870
+ path: ["status", "replicas"],
8871
+ render: (_, record) => {
8872
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(WorkloadReplicas, { record });
8702
8873
  }
8703
- const stringified = typeof value === "object" ? JSON.stringify(value) : String(value);
8704
- console.warn(
8705
- `An interpolation evaluated to '${stringified}' in the component '${componentName}', which is probably a mistake. You should explicitly cast or transform the value to a string.`
8706
- );
8707
- }
8874
+ };
8708
8875
  };
8709
- var idx = 0;
8710
- function styled(tag) {
8711
- var _a;
8712
- let mockedClass = "";
8713
- if (process.env.NODE_ENV === "test") {
8714
- mockedClass += `mocked-styled-${idx++}`;
8715
- if ((_a = tag == null ? void 0 : tag.__linaria) == null ? void 0 : _a.className) {
8716
- mockedClass += ` ${tag.__linaria.className}`;
8876
+ const ConditionsField = () => {
8877
+ return {
8878
+ key: "Conditions",
8879
+ title: i18n.t("dovetail.condition"),
8880
+ path: ["status", "conditions"],
8881
+ render: (value) => {
8882
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(ConditionsTable, { conditions: value });
8717
8883
  }
8718
- }
8719
- return (options) => {
8720
- if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test") {
8721
- if (Array.isArray(options)) {
8722
- throw new Error(
8723
- 'Using the "styled" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly. See https://github.com/callstack/linaria#setup'
8724
- );
8725
- }
8726
- }
8727
- const render = (props, ref) => {
8728
- const { as: component = tag, class: className = mockedClass } = props;
8729
- const shouldKeepProps = options.propsAsIs === void 0 ? !(typeof component === "string" && component.indexOf("-") === -1 && !isCapital(component[0])) : options.propsAsIs;
8730
- const filteredProps = filterProps(shouldKeepProps, props, [
8731
- "as",
8732
- "class"
8733
- ]);
8734
- filteredProps.ref = ref;
8735
- filteredProps.className = options.atomic ? cx_default(options.class, filteredProps.className || className) : cx_default(filteredProps.className || className, options.class);
8736
- const { vars } = options;
8737
- if (vars) {
8738
- const style2 = {};
8739
- for (const name2 in vars) {
8740
- const variable = vars[name2];
8741
- const result = variable[0];
8742
- const unit = variable[1] || "";
8743
- const value = typeof result === "function" ? result(props) : result;
8744
- warnIfInvalid(value, options.name);
8745
- style2[`--${name2}`] = `${value}${unit}`;
8884
+ };
8885
+ };
8886
+ const PodsField = () => {
8887
+ return {
8888
+ key: "pods",
8889
+ title: "Pods",
8890
+ path: [],
8891
+ render: (_, record) => {
8892
+ var _a, _b;
8893
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(
8894
+ WorkloadPodsTable,
8895
+ {
8896
+ selector: (_b = (_a = record.metadata.relations) == null ? void 0 : _a.find((r) => {
8897
+ return r.kind === "Pod" && r.type === "creates";
8898
+ })) == null ? void 0 : _b.selector
8746
8899
  }
8747
- const ownStyle = filteredProps.style || {};
8748
- const keys = Object.keys(ownStyle);
8749
- if (keys.length > 0) {
8750
- keys.forEach((key) => {
8751
- style2[key] = ownStyle[key];
8752
- });
8900
+ );
8901
+ }
8902
+ };
8903
+ };
8904
+ const JobsField = () => {
8905
+ return {
8906
+ key: "jobs",
8907
+ title: "Jobs",
8908
+ path: [],
8909
+ render: (_, record) => {
8910
+ var _a, _b, _c;
8911
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(
8912
+ CronjobJobsTable,
8913
+ {
8914
+ owner: {
8915
+ apiVersion: record.apiVersion || "",
8916
+ kind: record.kind || "",
8917
+ name: ((_a = record.metadata) == null ? void 0 : _a.name) || "",
8918
+ namespace: ((_b = record.metadata) == null ? void 0 : _b.namespace) || "",
8919
+ uid: ((_c = record.metadata) == null ? void 0 : _c.uid) || ""
8920
+ }
8753
8921
  }
8754
- filteredProps.style = style2;
8755
- }
8756
- if (tag.__linaria && tag !== component) {
8757
- filteredProps.as = component;
8758
- return React.createElement(tag, filteredProps);
8759
- }
8760
- return React.createElement(component, filteredProps);
8761
- };
8762
- const Result = React.forwardRef ? React.forwardRef(render) : (props) => {
8763
- const rest = omit(props, ["innerRef"]);
8764
- return render(rest, props.innerRef);
8765
- };
8766
- Result.displayName = options.name;
8767
- Result.__linaria = {
8768
- className: options.class || mockedClass,
8769
- extends: tag
8770
- };
8771
- return Result;
8922
+ );
8923
+ }
8772
8924
  };
8773
- }
8774
- var styled_default = process.env.NODE_ENV !== "production" ? new Proxy(styled, {
8775
- get(o, prop) {
8776
- return o(prop);
8777
- }
8778
- }) : styled;
8779
- const TableWidgets_ny30pi = "";
8780
- const AuxiliaryLine = /* @__PURE__ */ styled_default("div")({
8781
- name: "AuxiliaryLine",
8782
- class: "ax1qopv",
8783
- propsAsIs: false
8784
- });
8785
- const index_dmbxj3 = "";
8786
- const TableContainerStyle = "t1upn1sz";
8787
- function Table(props) {
8788
- const kit = useUIKit();
8789
- const {
8790
- t
8791
- } = useTranslation();
8792
- const {
8793
- loading,
8794
- error,
8795
- dataSource,
8796
- rowKey,
8797
- columns,
8798
- scroll,
8799
- currentPage,
8800
- currentSize,
8801
- refetch,
8802
- onSelect,
8803
- onPageChange,
8804
- onSizeChange
8805
- } = props;
8806
- const auxiliaryLineRef = useRef(null);
8807
- const wrapperRef = useRef(null);
8808
- const pagination = useMemo(() => ({
8809
- current: currentPage,
8810
- pageSize: currentSize,
8811
- onChange: onPageChange
8812
- }), [currentPage, currentSize, onPageChange]);
8813
- if (loading) {
8814
- return /* @__PURE__ */ jsxRuntime.exports.jsx(kit.loading, {});
8815
- } else if (error) {
8816
- return /* @__PURE__ */ jsxRuntime.exports.jsx(WidgetErrorContent, {
8817
- errorText: t("dovetail.retry_when_access_data_failed"),
8818
- refetch,
8819
- style: {
8820
- padding: "15px 0"
8821
- }
8822
- });
8823
- } else if (dataSource.length === 0) {
8824
- return /* @__PURE__ */ jsxRuntime.exports.jsx(WidgetErrorContent, {
8825
- errorText: t("dovetail.empty"),
8826
- style: {
8827
- padding: "15px 0"
8925
+ };
8926
+ const DataField = () => {
8927
+ return {
8928
+ key: "data",
8929
+ title: i18n.t("dovetail.data"),
8930
+ path: ["data"],
8931
+ render: (val) => {
8932
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(KeyValue, { value: val });
8933
+ }
8934
+ };
8935
+ };
8936
+ const SecretDataField = () => {
8937
+ return {
8938
+ key: "data",
8939
+ title: i18n.t("dovetail.data"),
8940
+ path: ["data"],
8941
+ render: (val) => {
8942
+ const decodeVal = {};
8943
+ for (const key in val) {
8944
+ decodeVal[key] = atob(val[key]);
8828
8945
  }
8829
- });
8830
- }
8831
- return /* @__PURE__ */ jsxRuntime.exports.jsxs("div", {
8832
- ref: wrapperRef,
8833
- className: cx_default(TableContainerStyle, props.className, "table-wrapper"),
8834
- children: [/* @__PURE__ */ jsxRuntime.exports.jsx(kit.table, {
8835
- tableLayout: "fixed",
8836
- rowSelection: onSelect ? {
8837
- onChange: (keys, rows) => {
8838
- onSelect == null ? void 0 : onSelect(keys, rows);
8839
- }
8840
- } : void 0,
8841
- columns,
8842
- dataSource,
8843
- pagination,
8844
- error,
8845
- loading,
8846
- rowKey,
8847
- wrapper: wrapperRef,
8848
- scroll
8849
- }), /* @__PURE__ */ jsxRuntime.exports.jsx(AuxiliaryLine, {
8850
- ref: auxiliaryLineRef
8851
- }), /* @__PURE__ */ jsxRuntime.exports.jsx(kit.pagination, {
8852
- current: currentPage,
8853
- size: currentSize,
8854
- count: dataSource.length,
8855
- onChange: onPageChange,
8856
- onSizeChange
8857
- })]
8858
- });
8859
- }
8860
- function CreateButton() {
8861
- const { resource } = useResource();
8862
- const navigation = useNavigation();
8863
- const go = useGo();
8864
- const kit = useUIKit();
8865
- const { t } = useTranslation();
8866
- const onClick = useCallback(() => {
8867
- if (resource == null ? void 0 : resource.name) {
8868
- go({
8869
- to: navigation.createUrl(resource.name),
8870
- options: {
8871
- keepQuery: true
8872
- }
8873
- });
8946
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(KeyValue, { value: decodeVal });
8874
8947
  }
8875
- }, [resource == null ? void 0 : resource.name]);
8876
- return /* @__PURE__ */ jsxRuntime.exports.jsx(kit.button, { type: "primary", onClick, children: t("create") });
8877
- }
8878
- const useDeleteManyModal = (resource, ids) => {
8879
- const { mutate } = useDeleteMany();
8880
- const [visible, setVisible] = useState(false);
8881
- const { t } = useTranslation();
8882
- const modalProps = {
8883
- title: t("delete"),
8884
- okText: t("delete"),
8885
- okButtonProps: {
8886
- danger: true
8887
- },
8888
- cancelText: t("cancel"),
8889
- children: t("confirm_delete_text", {
8890
- target: ids,
8891
- interpolation: { escapeValue: false }
8892
- }),
8893
- onOk() {
8894
- mutate({
8895
- resource,
8896
- ids
8897
- });
8898
- setVisible(false);
8899
- },
8900
- onCancel() {
8901
- setVisible(false);
8948
+ };
8949
+ };
8950
+ const StartTimeField = () => {
8951
+ return {
8952
+ key: "started",
8953
+ title: i18n.t("dovetail.started"),
8954
+ path: ["status", "startTime"],
8955
+ render(value) {
8956
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(Time, { date: value });
8902
8957
  }
8903
8958
  };
8904
- return { modalProps, visible, setVisible };
8905
8959
  };
8906
- const DeleteManyButton = (props) => {
8907
- const { resource } = useResource();
8908
- const kit = useUIKit();
8909
- const { t } = useTranslation();
8910
- const { modalProps, visible, setVisible } = useDeleteManyModal(
8911
- (resource == null ? void 0 : resource.name) || "",
8912
- props.ids
8913
- );
8914
- const onClick = useCallback(() => {
8915
- setVisible(true);
8916
- }, [setVisible]);
8917
- return /* @__PURE__ */ jsxRuntime.exports.jsxs(jsxRuntime.exports.Fragment, { children: [
8918
- /* @__PURE__ */ jsxRuntime.exports.jsx(kit.button, { type: "primary", danger: true, onClick, children: t("delete") }),
8919
- visible ? /* @__PURE__ */ jsxRuntime.exports.jsx(kit.modal, { ...modalProps }) : null
8920
- ] });
8960
+ const ServiceTypeField = () => {
8961
+ return {
8962
+ key: "type",
8963
+ title: i18n.t("dovetail.type"),
8964
+ path: ["spec", "type"]
8965
+ };
8921
8966
  };
8922
- const TableToolBar_1a3t35p = "";
8923
- const ToolbarStyle$1 = "t1v3ienx";
8924
- const TableToolBar = ({
8925
- title,
8926
- selectedKeys,
8927
- hideCreate
8928
- }) => {
8929
- const kit = useUIKit();
8930
- return /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.space, {
8931
- className: cx_default(ToolbarStyle$1, "table-toolbar"),
8932
- children: [/* @__PURE__ */ jsxRuntime.exports.jsx("span", {
8933
- className: Typo.Display.d2_bold_title,
8934
- children: title
8935
- }), /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.space, {
8936
- children: [selectedKeys.length > 0 ? /* @__PURE__ */ jsxRuntime.exports.jsx(DeleteManyButton, {
8937
- ids: selectedKeys
8938
- }) : void 0, !hideCreate ? /* @__PURE__ */ jsxRuntime.exports.jsx(CreateButton, {}) : null]
8939
- })]
8940
- });
8941
- };
8942
- const index_1hr2h38 = "";
8943
- function matchOwner(job, owner) {
8944
- var _a;
8945
- let match = false;
8946
- for (const o of ((_a = job.metadata) == null ? void 0 : _a.ownerReferences) || []) {
8947
- if (o.apiVersion === owner.apiVersion && o.kind === owner.kind && o.name === owner.name && job.namespace === owner.namespace) {
8948
- match = true;
8949
- }
8950
- }
8951
- return match;
8952
- }
8953
- const CronjobJobsTable = ({
8954
- owner
8955
- }) => {
8956
- const kit = useUIKit();
8957
- const {
8958
- i18n: i18n2
8959
- } = useTranslation();
8960
- const [selectedKeys, setSelectedKeys] = useState([]);
8961
- const [currentPage, setCurrentPage] = useState(1);
8962
- const {
8963
- data: data2
8964
- } = useList({
8965
- resource: "jobs",
8966
- meta: {
8967
- resourceBasePath: "/apis/batch/v1",
8968
- kind: "Job"
8969
- }
8970
- });
8971
- const dataSource = useMemo(() => {
8972
- return data2 == null ? void 0 : data2.data.map((p) => new JobModel(p)).filter((p) => {
8973
- return owner ? matchOwner(p, owner) : true;
8974
- });
8975
- }, [data2 == null ? void 0 : data2.data, owner]);
8976
- const columns = [PhaseColumnRenderer(i18n2), NameColumnRenderer(i18n2, "jobs"), NameSpaceColumnRenderer(i18n2), WorkloadImageColumnRenderer(i18n2), CompletionsCountColumnRenderer(i18n2), DurationColumnRenderer(i18n2), AgeColumnRenderer(i18n2)];
8977
- return /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.space, {
8978
- direction: "vertical",
8979
- className: "c16agr8o",
8980
- children: [/* @__PURE__ */ jsxRuntime.exports.jsx(TableToolBar, {
8981
- title: "Jobs",
8982
- selectedKeys,
8983
- hideCreate: true
8984
- }), /* @__PURE__ */ jsxRuntime.exports.jsx(Table, {
8985
- loading: !dataSource,
8986
- dataSource: dataSource || [],
8987
- columns,
8988
- onSelect: (keys) => setSelectedKeys(keys),
8989
- rowKey: "id",
8990
- error: false,
8991
- currentPage,
8992
- onPageChange: (p) => setCurrentPage(p),
8993
- currentSize: 10,
8994
- refetch: () => null
8995
- })]
8996
- });
8997
- };
8998
- const KeyValue = ({ value }) => {
8999
- const kit = useUIKit();
9000
- if (!value || Object.keys.length === 0) {
9001
- return /* @__PURE__ */ jsxRuntime.exports.jsx("div", { children: "Empty" });
9002
- }
9003
- const data2 = Object.keys(value).map((key) => {
9004
- return {
9005
- id: key,
9006
- key,
9007
- value: value[key]
9008
- };
9009
- });
9010
- return /* @__PURE__ */ jsxRuntime.exports.jsx(
9011
- kit.table,
9012
- {
9013
- loading: false,
9014
- columns: [
9015
- {
9016
- key: "key",
9017
- title: "Key",
9018
- dataIndex: ["key"]
9019
- },
9020
- {
9021
- key: "value",
9022
- title: "Value",
9023
- dataIndex: ["value"]
9024
- }
9025
- ],
9026
- dataSource: data2
9027
- }
9028
- );
9029
- };
9030
- function matchSelector(pod, selector) {
9031
- var _a, _b, _c;
9032
- let match = true;
9033
- for (const key in selector.matchLabels) {
9034
- if (!((_b = (_a = pod.metadata) == null ? void 0 : _a.labels) == null ? void 0 : _b[key]) || ((_c = pod.metadata.labels) == null ? void 0 : _c[key]) !== selector.matchLabels[key]) {
9035
- match = false;
9036
- }
9037
- }
9038
- return match;
9039
- }
9040
- const WorkloadPodsTable_z2tsj7 = "";
9041
- const WorkloadPodsTable = ({
9042
- selector
9043
- }) => {
9044
- const kit = useUIKit();
9045
- const {
9046
- i18n: i18n2
9047
- } = useTranslation();
9048
- const [selectedKeys, setSelectedKeys] = useState([]);
9049
- const [currentPage, setCurrentPage] = useState(1);
9050
- const {
9051
- data: data2
9052
- } = useList({
9053
- resource: "pods",
9054
- meta: {
9055
- resourceBasePath: "/api/v1",
9056
- kind: "Pod"
9057
- }
9058
- });
9059
- const dataSource = useMemo(() => {
9060
- return data2 == null ? void 0 : data2.data.map((p) => new PodModel(p)).filter((p) => {
9061
- return selector ? matchSelector(p, selector) : true;
9062
- });
9063
- }, [data2 == null ? void 0 : data2.data, selector]);
9064
- const columns = [PhaseColumnRenderer(i18n2), NameColumnRenderer(i18n2, "pods"), NodeNameColumnRenderer(i18n2), WorkloadImageColumnRenderer(i18n2), RestartCountColumnRenderer(i18n2)];
9065
- return /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.space, {
9066
- direction: "vertical",
9067
- className: "c1dicff8",
9068
- children: [/* @__PURE__ */ jsxRuntime.exports.jsx(TableToolBar, {
9069
- title: "",
9070
- selectedKeys,
9071
- hideCreate: true
9072
- }), /* @__PURE__ */ jsxRuntime.exports.jsx(Table, {
9073
- loading: !dataSource,
9074
- dataSource: dataSource || [],
9075
- columns,
9076
- onSelect: (keys) => setSelectedKeys(keys),
9077
- rowKey: "id",
9078
- error: false,
9079
- currentPage,
9080
- onPageChange: (p) => setCurrentPage(p),
9081
- currentSize: 10,
9082
- refetch: () => null
9083
- })]
9084
- });
9085
- };
9086
- const ImageField = (i18n2) => {
9087
- return {
9088
- key: "Image",
9089
- title: i18n2.t("image"),
9090
- path: ["imageNames"],
9091
- render(value) {
9092
- return /* @__PURE__ */ jsxRuntime.exports.jsx(ImageNames, { value });
9093
- }
9094
- };
9095
- };
9096
- const ReplicaField = (i18n2) => {
9097
- return {
9098
- key: "Replicas",
9099
- title: i18n2.t("replicas"),
9100
- path: ["status", "replicas"],
9101
- render: (_, record) => {
9102
- return /* @__PURE__ */ jsxRuntime.exports.jsx(WorkloadReplicas, { record });
9103
- }
9104
- };
9105
- };
9106
- const ConditionsField = (i18n2) => {
9107
- return {
9108
- key: "Conditions",
9109
- title: i18n2.t("condition"),
9110
- path: ["status", "conditions"],
9111
- render: (value) => {
9112
- return /* @__PURE__ */ jsxRuntime.exports.jsx(ConditionsTable, { conditions: value });
9113
- }
9114
- };
9115
- };
9116
- const PodsField = (_) => {
9117
- return {
9118
- key: "pods",
9119
- title: "Pods",
9120
- path: [],
9121
- render: (_2, record) => {
9122
- var _a, _b;
9123
- return /* @__PURE__ */ jsxRuntime.exports.jsx(
9124
- WorkloadPodsTable,
9125
- {
9126
- selector: (_b = (_a = record.metadata.relations) == null ? void 0 : _a.find((r) => {
9127
- return r.kind === "Pod" && r.type === "creates";
9128
- })) == null ? void 0 : _b.selector
9129
- }
9130
- );
9131
- }
9132
- };
9133
- };
9134
- const JobsField = (_) => {
9135
- return {
9136
- key: "jobs",
9137
- title: "Jobs",
9138
- path: [],
9139
- render: (_2, record) => {
9140
- var _a, _b, _c;
9141
- return /* @__PURE__ */ jsxRuntime.exports.jsx(
9142
- CronjobJobsTable,
9143
- {
9144
- owner: {
9145
- apiVersion: record.apiVersion || "",
9146
- kind: record.kind || "",
9147
- name: ((_a = record.metadata) == null ? void 0 : _a.name) || "",
9148
- namespace: ((_b = record.metadata) == null ? void 0 : _b.namespace) || "",
9149
- uid: ((_c = record.metadata) == null ? void 0 : _c.uid) || ""
9150
- }
9151
- }
9152
- );
9153
- }
9154
- };
9155
- };
9156
- const DataField = (i18n2) => {
9157
- return {
9158
- key: "data",
9159
- title: i18n2.t("data"),
9160
- path: ["rawYaml", "data"],
9161
- render: (val) => {
9162
- return /* @__PURE__ */ jsxRuntime.exports.jsx(KeyValue, { value: val });
9163
- }
9164
- };
9165
- };
9166
- const SecretDataField = (i18n2) => {
9167
- return {
9168
- key: "data",
9169
- title: i18n2.t("data"),
9170
- path: ["rawYaml", "data"],
9171
- render: (val) => {
9172
- const decodeVal = {};
9173
- for (const key in val) {
9174
- decodeVal[key] = atob(val[key]);
9175
- }
9176
- return /* @__PURE__ */ jsxRuntime.exports.jsx(KeyValue, { value: decodeVal });
9177
- }
9178
- };
9179
- };
9180
- const StartTimeField = (i18n2) => {
9181
- return {
9182
- key: "started",
9183
- title: i18n2.t("started"),
9184
- path: ["status", "startTime"],
9185
- render(value) {
9186
- return /* @__PURE__ */ jsxRuntime.exports.jsx(Time, { date: value });
9187
- }
9188
- };
9189
- };
9190
- const ServiceTypeField = (i18n2) => {
9191
- return {
9192
- key: "type",
9193
- title: i18n2.t("dovetail.type"),
9194
- path: ["rawYaml", "spec", "type"]
9195
- };
9196
- };
9197
- const ClusterIpField = (i18n2) => {
8967
+ const ClusterIpField = () => {
9198
8968
  return {
9199
8969
  key: "clusterIp",
9200
- title: i18n2.t("dovetail.clusterIp"),
9201
- path: ["rawYaml", "spec", "clusterIP"]
8970
+ title: i18n.t("dovetail.clusterIp"),
8971
+ path: ["spec", "clusterIP"]
9202
8972
  };
9203
8973
  };
9204
- const SessionAffinityField = (i18n2) => {
8974
+ const SessionAffinityField = () => {
9205
8975
  return {
9206
8976
  key: "clusterIp",
9207
- title: i18n2.t("dovetail.sessionAffinity"),
9208
- path: ["rawYaml", "spec", "sessionAffinity"]
8977
+ title: i18n.t("dovetail.sessionAffinity"),
8978
+ path: ["spec", "sessionAffinity"]
9209
8979
  };
9210
8980
  };
9211
- const ServicePodsField = (_) => {
8981
+ const ServicePodsField = () => {
9212
8982
  return {
9213
8983
  key: "pods",
9214
8984
  title: "Pods",
9215
8985
  path: [],
9216
- render: (_2, record) => {
8986
+ render: (_, record) => {
9217
8987
  var _a, _b;
9218
8988
  return /* @__PURE__ */ jsxRuntime.exports.jsx(
9219
8989
  WorkloadPodsTable,
@@ -9387,87 +9157,65 @@ const MonacoYamlEditor$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
9387
9157
  __proto__: null,
9388
9158
  default: MonacoYamlEditor$1
9389
9159
  }, Symbol.toStringTag, { value: "Module" }));
9390
- const index_m52iq6 = "";
9391
- const TagWrapper = "t13a6vox";
9392
- const TagStyle = "t12ikbmp";
9393
- const Tags = (props) => {
9394
- const {
9395
- value
9396
- } = props;
9397
- const kit = useUIKit();
9398
- const tags = Object.keys(value).map((key) => {
9399
- return /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.tag, {
9400
- className: TagStyle,
9401
- title: `${key}:${value[key]}`,
9402
- children: [key, ":", value[key]]
9403
- }, key);
9404
- });
9405
- return /* @__PURE__ */ jsxRuntime.exports.jsx(kit.space, {
9406
- className: TagWrapper,
9407
- size: 8,
9408
- children: tags
9409
- });
9410
- };
9411
9160
  const EventsTable = ({}) => {
9412
- useUIKit();
9413
9161
  const { i18n: i18n2 } = useTranslation();
9414
9162
  const [currentPage, setCurrentPage] = useState(1);
9415
- const parsed = useParsed();
9416
9163
  const { data: data2, isLoading } = useList({
9417
9164
  resource: "events",
9418
9165
  meta: { resourceBasePath: "/apis/events.k8s.io/v1", kind: "Event" }
9419
9166
  });
9167
+ const parsed = useParsed();
9420
9168
  const columns = useMemo(
9421
9169
  () => [
9422
- NameSpaceColumnRenderer(i18n2),
9170
+ NameSpaceColumnRenderer(),
9423
9171
  {
9424
9172
  key: "type",
9425
9173
  display: true,
9426
- dataIndex: ["rawYaml", "type"],
9427
- title: i18n2.t("type"),
9174
+ dataIndex: ["type"],
9175
+ title: i18n2.t("dovetail.type"),
9428
9176
  sortable: true,
9429
- sorter: CommonSorter(["rawYaml", "type"])
9177
+ sorter: CommonSorter(["type"])
9430
9178
  },
9431
9179
  {
9432
9180
  key: "reason",
9433
9181
  display: true,
9434
- dataIndex: ["rawYaml", "reason"],
9435
- title: i18n2.t("reason"),
9182
+ dataIndex: ["reason"],
9183
+ title: i18n2.t("dovetail.reason"),
9436
9184
  sortable: true,
9437
- sorter: CommonSorter(["rawYaml", "reason"])
9185
+ sorter: CommonSorter(["reason"])
9438
9186
  },
9439
9187
  {
9440
9188
  key: "object",
9441
9189
  display: true,
9442
- dataIndex: ["rawYaml", "regarding", "name"],
9443
- title: i18n2.t("object"),
9190
+ dataIndex: ["regarding", "name"],
9191
+ title: i18n2.t("dovetail.object"),
9444
9192
  sortable: true,
9445
- sorter: CommonSorter(["rawYaml", "regarding", "name"])
9193
+ sorter: CommonSorter(["regarding", "name"])
9446
9194
  },
9447
9195
  {
9448
9196
  key: "note",
9449
9197
  display: true,
9450
- dataIndex: ["rawYaml", "note"],
9451
- title: i18n2.t("note"),
9198
+ dataIndex: ["note"],
9199
+ title: i18n2.t("dovetail.note"),
9452
9200
  sortable: true,
9453
- sorter: CommonSorter(["rawYaml", "note"])
9201
+ sorter: CommonSorter(["note"])
9454
9202
  },
9455
- AgeColumnRenderer(i18n2)
9203
+ AgeColumnRenderer()
9456
9204
  ],
9457
9205
  [i18n2]
9458
9206
  );
9459
- const dataSource = useMemo(
9460
- () => addId((data2 == null ? void 0 : data2.data) || [], "metadata.uid").filter((d) => {
9207
+ const dataSource = useMemo(() => {
9208
+ return data2 == null ? void 0 : data2.data.filter((d) => {
9461
9209
  const objectId = `${d.regarding.namespace}/${d.regarding.name}`;
9462
9210
  return objectId === parsed.id;
9463
- }).map((d) => new ResourceModel(d)),
9464
- [data2 == null ? void 0 : data2.data, parsed]
9465
- );
9211
+ });
9212
+ }, [data2 == null ? void 0 : data2.data, parsed]);
9466
9213
  return /* @__PURE__ */ jsxRuntime.exports.jsx(
9467
9214
  Table,
9468
9215
  {
9216
+ tableKey: "events",
9469
9217
  loading: isLoading,
9470
- dataSource: dataSource || [],
9218
+ data: dataSource || [],
9471
9219
  columns,
9472
9220
  rowKey: "id",
9473
9221
  error: false,
@@ -9478,6 +9226,27 @@ const EventsTable = ({}) => {
9478
9226
  }
9479
9227
  );
9480
9228
  };
9229
+ const index_m52iq6 = "";
9230
+ const TagWrapper = "t13a6vox";
9231
+ const TagStyle = "t12ikbmp";
9232
+ const Tags = (props) => {
9233
+ const {
9234
+ value
9235
+ } = props;
9236
+ const kit = useUIKit();
9237
+ const tags = Object.keys(value).map((key) => {
9238
+ return /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.tag, {
9239
+ className: TagStyle,
9240
+ title: `${key}:${value[key]}`,
9241
+ children: [key, ":", value[key]]
9242
+ }, key);
9243
+ });
9244
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(kit.space, {
9245
+ className: TagWrapper,
9246
+ size: 8,
9247
+ children: tags
9248
+ });
9249
+ };
9481
9250
  const ShowContent_10jwllm = "";
9482
9251
  const TopBarStyle = "t9agep2";
9483
9252
  const ShowContentStyle = "so89gfi";
@@ -9490,6 +9259,9 @@ const ShowContent = (props) => {
9490
9259
  Dropdown = K8sDropdown
9491
9260
  } = props;
9492
9261
  const kit = useUIKit();
9262
+ const {
9263
+ globalStore
9264
+ } = useGlobalStore();
9493
9265
  const parsed = useParsed();
9494
9266
  const {
9495
9267
  resource
@@ -9512,14 +9284,15 @@ const ShowContent = (props) => {
9512
9284
  if (!(data2 == null ? void 0 : data2.data)) {
9513
9285
  return null;
9514
9286
  }
9515
- const record = formatter(data2 == null ? void 0 : data2.data);
9287
+ const model = data2.data;
9288
+ const record = formatter ? formatter(model) : data2 == null ? void 0 : data2.data;
9516
9289
  const FirstLineFields = [{
9517
9290
  key: "NameSpace",
9518
- title: t("namespace"),
9291
+ title: t("dovetail.namespace"),
9519
9292
  path: ["metadata", "namespace"]
9520
9293
  }, {
9521
9294
  key: "Age",
9522
- title: t("created_time"),
9295
+ title: t("dovetail.created_time"),
9523
9296
  path: ["metadata", "creationTimestamp"],
9524
9297
  render(value) {
9525
9298
  return /* @__PURE__ */ jsxRuntime.exports.jsx(Time, {
@@ -9529,7 +9302,7 @@ const ShowContent = (props) => {
9529
9302
  }];
9530
9303
  const SecondLineFields = [{
9531
9304
  key: "Labels",
9532
- title: t("label"),
9305
+ title: t("dovetail.label"),
9533
9306
  path: ["metadata", "labels"],
9534
9307
  render: (value) => {
9535
9308
  if (!value) {
@@ -9541,7 +9314,7 @@ const ShowContent = (props) => {
9541
9314
  }
9542
9315
  }, {
9543
9316
  key: "Annotations",
9544
- title: t("annotation"),
9317
+ title: t("dovetail.annotation"),
9545
9318
  path: ["metadata", "annotations"],
9546
9319
  render: (value) => {
9547
9320
  if (!value) {
@@ -9590,13 +9363,13 @@ const ShowContent = (props) => {
9590
9363
  onChange: (e) => setMode(e.target.value),
9591
9364
  children: [/* @__PURE__ */ jsxRuntime.exports.jsx(kit.radioButton, {
9592
9365
  value: "detail",
9593
- children: t("detail")
9366
+ children: t("dovetail.detail")
9594
9367
  }), /* @__PURE__ */ jsxRuntime.exports.jsx(kit.radioButton, {
9595
9368
  value: "yaml",
9596
9369
  children: "YAML"
9597
9370
  })]
9598
9371
  }), /* @__PURE__ */ jsxRuntime.exports.jsx(Dropdown, {
9599
- data: record
9372
+ record
9600
9373
  })]
9601
9374
  })]
9602
9375
  });
@@ -9627,7 +9400,7 @@ const ShowContent = (props) => {
9627
9400
  children: content
9628
9401
  }, field.key);
9629
9402
  }), /* @__PURE__ */ jsxRuntime.exports.jsx(kit.tabsTabPane, {
9630
- tab: t("event"),
9403
+ tab: t("dovetail.event"),
9631
9404
  children: /* @__PURE__ */ jsxRuntime.exports.jsx(EventsTable, {})
9632
9405
  }, "event")]
9633
9406
  });
@@ -9637,7 +9410,7 @@ const ShowContent = (props) => {
9637
9410
  }),
9638
9411
  ["yaml"]: /* @__PURE__ */ jsxRuntime.exports.jsx(MonacoYamlEditor$1, {
9639
9412
  className: EditorStyle$1,
9640
- defaultValue: yaml.dump(omit$1(relationPlugin.restoreItem(data2.data), "id")),
9413
+ defaultValue: yaml.dump(globalStore == null ? void 0 : globalStore.restoreItem(model)),
9641
9414
  schema: {},
9642
9415
  onEditorCreate: (editor) => {
9643
9416
  fold(editor);
@@ -9691,7 +9464,7 @@ const PodContainersTable = ({
9691
9464
  {
9692
9465
  key: "state",
9693
9466
  dataIndex: ["state"],
9694
- title: i18n2.t("state"),
9467
+ title: i18n2.t("dovetail.state"),
9695
9468
  sortable: true,
9696
9469
  sorter: CommonSorter(["state"]),
9697
9470
  render: (v) => /* @__PURE__ */ jsxRuntime.exports.jsx(StateTag, { state: Object.keys(v)[0] })
@@ -9699,7 +9472,7 @@ const PodContainersTable = ({
9699
9472
  {
9700
9473
  key: "ready",
9701
9474
  dataIndex: ["ready"],
9702
- title: i18n2.t("ready"),
9475
+ title: i18n2.t("dovetail.ready"),
9703
9476
  sortable: true,
9704
9477
  sorter: CommonSorter(["ready"]),
9705
9478
  render: (v) => /* @__PURE__ */ jsxRuntime.exports.jsx(
@@ -9712,21 +9485,21 @@ const PodContainersTable = ({
9712
9485
  {
9713
9486
  key: "name",
9714
9487
  dataIndex: ["name"],
9715
- title: i18n2.t("name"),
9488
+ title: i18n2.t("dovetail.name"),
9716
9489
  sortable: true,
9717
9490
  sorter: CommonSorter(["name"])
9718
9491
  },
9719
9492
  {
9720
9493
  key: "image",
9721
9494
  dataIndex: ["image"],
9722
- title: i18n2.t("image"),
9495
+ title: i18n2.t("dovetail.image"),
9723
9496
  sortable: true,
9724
9497
  sorter: CommonSorter(["image"])
9725
9498
  },
9726
9499
  {
9727
9500
  key: "init",
9728
9501
  dataIndex: [],
9729
- title: i18n2.t("init_container"),
9502
+ title: i18n2.t("dovetail.init_container"),
9730
9503
  render: (_, record) => {
9731
9504
  const isInit = initContainerStatuses.some(
9732
9505
  (c) => c.containerID === record.containerID
@@ -9740,14 +9513,14 @@ const PodContainersTable = ({
9740
9513
  {
9741
9514
  key: "restartCount",
9742
9515
  dataIndex: ["restartCount"],
9743
- title: i18n2.t("restarts"),
9516
+ title: i18n2.t("dovetail.restarts"),
9744
9517
  sortable: true,
9745
9518
  sorter: CommonSorter(["restartCount"])
9746
9519
  },
9747
9520
  {
9748
9521
  key: "started",
9749
9522
  dataIndex: ["state", "running", "startedAt"],
9750
- title: i18n2.t("started"),
9523
+ title: i18n2.t("dovetail.started"),
9751
9524
  sortable: true,
9752
9525
  sorter: CommonSorter(["state", "running", "startedAt"]),
9753
9526
  render: (value) => {
@@ -9775,16 +9548,16 @@ const PodContainersTable = ({
9775
9548
  );
9776
9549
  };
9777
9550
  function WorkloadDropdown(props) {
9778
- const { data: data2 } = props;
9551
+ const { record } = props;
9779
9552
  const kit = useUIKit();
9780
9553
  const { resource } = useResource();
9781
9554
  const { mutate } = useUpdate();
9782
9555
  const { t } = useTranslation();
9783
- return /* @__PURE__ */ jsxRuntime.exports.jsx(K8sDropdown, { data: data2, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
9556
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(K8sDropdown, { record, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
9784
9557
  kit.menu.Item,
9785
9558
  {
9786
9559
  onClick: () => {
9787
- const v = data2.redeploy();
9560
+ const v = record.redeploy();
9788
9561
  const id = v.id;
9789
9562
  pruneBeforeEdit(v);
9790
9563
  mutate({
@@ -9797,6 +9570,7 @@ function WorkloadDropdown(props) {
9797
9570
  }
9798
9571
  ) });
9799
9572
  }
9573
+ const ComponentContext = createContext({});
9800
9574
  const index_3lw8k1 = "";
9801
9575
  const ListPageStyle = "laykzsq";
9802
9576
  const TableStyle = "t1ng0psc";
@@ -9806,12 +9580,16 @@ function ListPage(props) {
9806
9580
  selectedKeys,
9807
9581
  tableProps
9808
9582
  } = props;
9583
+ const {
9584
+ Table: TableComponent
9585
+ } = useContext(ComponentContext);
9586
+ const Table$1 = TableComponent || Table;
9809
9587
  return /* @__PURE__ */ jsxRuntime.exports.jsxs("div", {
9810
9588
  className: ListPageStyle,
9811
9589
  children: [/* @__PURE__ */ jsxRuntime.exports.jsx(TableToolBar, {
9812
9590
  title,
9813
9591
  selectedKeys
9814
- }), /* @__PURE__ */ jsxRuntime.exports.jsx(Table, {
9592
+ }), /* @__PURE__ */ jsxRuntime.exports.jsx(Table$1, {
9815
9593
  ...tableProps,
9816
9594
  className: TableStyle,
9817
9595
  scroll: {
@@ -9822,13 +9600,12 @@ function ListPage(props) {
9822
9600
  }
9823
9601
  function ResourceList(props) {
9824
9602
  const { formatter, name: name2, columns, Dropdown } = props;
9825
- const { i18n: i18n2 } = useTranslation();
9826
9603
  const { tableProps, selectedKeys } = useEagleTable({
9827
9604
  useTableParams: {},
9828
9605
  columns: [
9829
- PhaseColumnRenderer(i18n2),
9830
- NameColumnRenderer(i18n2),
9831
- NameSpaceColumnRenderer(i18n2),
9606
+ NameColumnRenderer(),
9607
+ PhaseColumnRenderer(),
9608
+ NameSpaceColumnRenderer(),
9832
9609
  ...columns
9833
9610
  ],
9834
9611
  tableProps: {
@@ -9850,6 +9627,46 @@ function ResourceShow(props) {
9850
9627
  }
9851
9628
  );
9852
9629
  }
9630
+ const index_1kmu85y = "";
9631
+ const ErrorWrapper = /* @__PURE__ */ styled_default("div")({
9632
+ name: "ErrorWrapper",
9633
+ class: "egn3dbn",
9634
+ propsAsIs: false
9635
+ });
9636
+ const ErrorContent = /* @__PURE__ */ styled_default("div")({
9637
+ name: "ErrorContent",
9638
+ class: "e136jgy8",
9639
+ propsAsIs: false
9640
+ });
9641
+ const WidgetErrorContent = (props) => {
9642
+ const {
9643
+ refetch,
9644
+ errorText,
9645
+ hiddenRetry
9646
+ } = props;
9647
+ const kit = useContext(kitContext);
9648
+ const {
9649
+ t
9650
+ } = useTranslation();
9651
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(ErrorWrapper, {
9652
+ className: props.className,
9653
+ style: props.style,
9654
+ children: /* @__PURE__ */ jsxRuntime.exports.jsxs(ErrorContent, {
9655
+ children: [/* @__PURE__ */ jsxRuntime.exports.jsx("p", {
9656
+ className: cx_default(Typo.Label.l1_regular_title, "title"),
9657
+ children: errorText || t("dovetail.obtain_data_error")
9658
+ }), hiddenRetry ? null : /* @__PURE__ */ jsxRuntime.exports.jsx(kit.button, {
9659
+ size: "small",
9660
+ type: "ordinary",
9661
+ onClick: (e) => {
9662
+ e.stopPropagation();
9663
+ refetch == null ? void 0 : refetch();
9664
+ },
9665
+ children: t("dovetail.retry")
9666
+ })]
9667
+ })
9668
+ });
9669
+ };
9853
9670
  const index_12sfrn = "";
9854
9671
  const Style = "s1bsn3us";
9855
9672
  const Separator = () => {
@@ -9858,7 +9675,7 @@ const Separator = () => {
9858
9675
  });
9859
9676
  };
9860
9677
  const MonacoYamlEditor = React.lazy(() => Promise.resolve().then(() => MonacoYamlEditor$2));
9861
- const MonacoYamlDiffEditor = React.lazy(() => import("./MonacoYamlDiffEditor.2bd18ff6.js"));
9678
+ const MonacoYamlDiffEditor = React.lazy(() => import("./MonacoYamlDiffEditor.4fe9fad1.js"));
9862
9679
  const YamlEditorComponent = forwardRef(
9863
9680
  function YamlEditorComponent2(props, ref) {
9864
9681
  const {
@@ -9891,8 +9708,8 @@ const YamlEditorComponent = forwardRef(
9891
9708
  (_b = (_a = editorInstance.current) == null ? void 0 : _a.getModel()) == null ? void 0 : _b.setValue(value2);
9892
9709
  },
9893
9710
  getEditorValue: () => {
9894
- var _a;
9895
- return ((_a = editorInstance.current) == null ? void 0 : _a.getValue()) || "";
9711
+ var _a, _b;
9712
+ return (_b = (_a = editorInstance.current) == null ? void 0 : _a.getValue()) != null ? _b : "";
9896
9713
  },
9897
9714
  getEditorInstance: () => editorInstance.current || null
9898
9715
  };
@@ -10108,6 +9925,172 @@ function copyToClipboard(text) {
10108
9925
  document.execCommand("copy");
10109
9926
  document.body.removeChild(input);
10110
9927
  }
9928
+ const BASE_INIT_VALUE = {
9929
+ metadata: {
9930
+ name: "",
9931
+ namespace: "default",
9932
+ annotations: {},
9933
+ labels: {}
9934
+ }
9935
+ };
9936
+ const DEFAULT_MATCH_LABEL = "sks.user.kubesmart.smtx.io/app";
9937
+ const BASE_CONTAINER_INIT_VALUE = {
9938
+ name: "container-0",
9939
+ imagePullPolicy: "Always",
9940
+ image: ""
9941
+ };
9942
+ const BASE_WORKLOAD_SPEC_INIT_VALUE = {
9943
+ affinity: {},
9944
+ imagePullSecrets: [],
9945
+ initContainers: [],
9946
+ volumes: []
9947
+ };
9948
+ const DEPLOYMENT_INIT_VALUE = {
9949
+ apiVersion: "apps/v1",
9950
+ kind: "Deployment",
9951
+ ...BASE_INIT_VALUE,
9952
+ spec: {
9953
+ replicas: 1,
9954
+ selector: {
9955
+ matchLabels: {
9956
+ [DEFAULT_MATCH_LABEL]: ""
9957
+ }
9958
+ },
9959
+ template: {
9960
+ metadata: {
9961
+ labels: {
9962
+ [DEFAULT_MATCH_LABEL]: ""
9963
+ }
9964
+ },
9965
+ spec: {
9966
+ containers: [BASE_CONTAINER_INIT_VALUE],
9967
+ restartPolicy: "Always",
9968
+ ...BASE_WORKLOAD_SPEC_INIT_VALUE
9969
+ }
9970
+ }
9971
+ }
9972
+ };
9973
+ const CRONJOB_INIT_VALUE = {
9974
+ apiVersion: "batch/v1",
9975
+ kind: "CronJob",
9976
+ ...BASE_INIT_VALUE,
9977
+ spec: {
9978
+ schedule: "",
9979
+ jobTemplate: {
9980
+ metadata: {
9981
+ labels: {}
9982
+ },
9983
+ spec: {
9984
+ template: {
9985
+ spec: {
9986
+ containers: [BASE_CONTAINER_INIT_VALUE],
9987
+ restartPolicy: "Never",
9988
+ ...BASE_WORKLOAD_SPEC_INIT_VALUE
9989
+ }
9990
+ }
9991
+ }
9992
+ }
9993
+ }
9994
+ };
9995
+ const DAEMONSET_INIT_VALUE = {
9996
+ apiVersion: "apps/v1",
9997
+ kind: "DaemonSet",
9998
+ ...BASE_INIT_VALUE,
9999
+ spec: {
10000
+ replicas: 1,
10001
+ selector: {
10002
+ matchLabels: {
10003
+ [DEFAULT_MATCH_LABEL]: ""
10004
+ }
10005
+ },
10006
+ template: {
10007
+ metadata: {
10008
+ labels: {
10009
+ [DEFAULT_MATCH_LABEL]: ""
10010
+ }
10011
+ },
10012
+ spec: {
10013
+ containers: [BASE_CONTAINER_INIT_VALUE],
10014
+ restartPolicy: "Always",
10015
+ ...BASE_WORKLOAD_SPEC_INIT_VALUE
10016
+ }
10017
+ }
10018
+ }
10019
+ };
10020
+ const JOB_INIT_VALUE = {
10021
+ apiVersion: "batch/v1",
10022
+ kind: "Job",
10023
+ ...BASE_INIT_VALUE,
10024
+ spec: {
10025
+ replicas: 1,
10026
+ selector: {
10027
+ matchLabels: {}
10028
+ },
10029
+ template: {
10030
+ metadata: {
10031
+ labels: {}
10032
+ },
10033
+ spec: {
10034
+ containers: [BASE_CONTAINER_INIT_VALUE],
10035
+ restartPolicy: "Never",
10036
+ ...BASE_WORKLOAD_SPEC_INIT_VALUE
10037
+ }
10038
+ }
10039
+ }
10040
+ };
10041
+ const STATEFULSET_INIT_VALUE = {
10042
+ apiVersion: "apps/v1",
10043
+ kind: "StatefulSet",
10044
+ ...BASE_INIT_VALUE,
10045
+ spec: {
10046
+ replicas: 1,
10047
+ selector: {
10048
+ matchLabels: {
10049
+ [DEFAULT_MATCH_LABEL]: ""
10050
+ }
10051
+ },
10052
+ template: {
10053
+ metadata: {
10054
+ labels: {
10055
+ [DEFAULT_MATCH_LABEL]: ""
10056
+ }
10057
+ },
10058
+ spec: {
10059
+ containers: [BASE_CONTAINER_INIT_VALUE],
10060
+ restartPolicy: "Always",
10061
+ ...BASE_WORKLOAD_SPEC_INIT_VALUE
10062
+ }
10063
+ }
10064
+ }
10065
+ };
10066
+ const POD_INIT_VALUE = {
10067
+ apiVersion: "v1",
10068
+ kind: "Pod",
10069
+ ...BASE_INIT_VALUE,
10070
+ spec: {
10071
+ containers: [BASE_CONTAINER_INIT_VALUE]
10072
+ }
10073
+ };
10074
+ const SERVICE_INIT_VALUE = {
10075
+ "apiVersion": "v1",
10076
+ "kind": "Service",
10077
+ ...BASE_INIT_VALUE,
10078
+ "spec": {
10079
+ "selector": {},
10080
+ "clusterIP": null,
10081
+ "ports": [
10082
+ {
10083
+ "name": "",
10084
+ "port": null,
10085
+ "protocol": "TCP",
10086
+ "targetPort": null
10087
+ }
10088
+ ],
10089
+ "sessionAffinity": "None",
10090
+ "type": "ClusterIP"
10091
+ }
10092
+ };
10093
+ const TIMESTAMP_LABEL = "sks.user.kubesmart.smtx.io/timestamp";
10111
10094
  function getCommonErrors(response, i18n2) {
10112
10095
  var _a;
10113
10096
  if (!((response == null ? void 0 : response.message) || (response == null ? void 0 : response.code) || (response == null ? void 0 : response.reason) || (response == null ? void 0 : response.details) || (response == null ? void 0 : response.graphQLErrors))) {
@@ -10155,60 +10138,89 @@ function getCommonErrors(response, i18n2) {
10155
10138
  )
10156
10139
  ];
10157
10140
  }
10158
- const index_1tozzph = "";
10159
- const EditorStyle = "e5ks0bl";
10141
+ const index_1mpguu8 = "";
10142
+ const FormStyle = "f5ks0bl";
10143
+ const EditorStyle = "e1tqaxpu";
10144
+ var SchemaStrategy = /* @__PURE__ */ ((SchemaStrategy2) => {
10145
+ SchemaStrategy2["Required"] = "Required";
10146
+ SchemaStrategy2["Optional"] = "Optional";
10147
+ SchemaStrategy2["None"] = "None";
10148
+ return SchemaStrategy2;
10149
+ })(SchemaStrategy || {});
10160
10150
  function YamlForm(props) {
10161
10151
  var _a, _b;
10152
+ const {
10153
+ schemaStrategy = "Optional"
10154
+ } = props;
10162
10155
  const {
10163
10156
  formProps,
10164
10157
  saveButtonProps,
10165
10158
  editorProps,
10166
10159
  errorResponseBody,
10167
- mutationResult
10168
- } = useEagleForm();
10160
+ mutationResult,
10161
+ isLoadingSchema,
10162
+ fetchSchema
10163
+ } = useEagleForm({
10164
+ editorOptions: {
10165
+ isSkipSchema: schemaStrategy === "None"
10166
+ },
10167
+ liveMode: "off"
10168
+ });
10169
10169
  const kit = useUIKit();
10170
10170
  const {
10171
10171
  t,
10172
10172
  i18n: i18n2
10173
10173
  } = useTranslation();
10174
10174
  const responseErrors = errorResponseBody ? getCommonErrors(errorResponseBody, i18n2) : [];
10175
+ const schema = useMemo(() => {
10176
+ return editorProps.schema || {};
10177
+ }, [editorProps.schema]);
10175
10178
  return /* @__PURE__ */ jsxRuntime.exports.jsx(FormLayout, {
10176
10179
  children: /* @__PURE__ */ jsxRuntime.exports.jsx(kit.form, {
10177
10180
  ...formProps,
10178
10181
  initialValues: (_b = (_a = formProps.initialValues) != null ? _a : props.initialValues) != null ? _b : BASE_INIT_VALUE,
10179
10182
  layout: "horizontal",
10180
- children: editorProps.schema ? /* @__PURE__ */ jsxRuntime.exports.jsxs(jsxRuntime.exports.Fragment, {
10181
- children: [/* @__PURE__ */ jsxRuntime.exports.jsx(kit.form.Item, {
10182
- style: {
10183
- flex: 1
10184
- },
10185
- children: /* @__PURE__ */ jsxRuntime.exports.jsx(YamlEditorComponent, {
10186
- ...editorProps,
10187
- className: EditorStyle,
10188
- schema: editorProps.schema,
10189
- collapsable: false
10190
- })
10191
- }), /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.form.Item, {
10192
- children: [mutationResult.error && /* @__PURE__ */ jsxRuntime.exports.jsx(kit.alert, {
10193
- message: errorResponseBody ? /* @__PURE__ */ jsxRuntime.exports.jsx("ul", {
10194
- children: responseErrors.map((error, index) => /* @__PURE__ */ jsxRuntime.exports.jsxs("li", {
10195
- children: [responseErrors.length > 1 ? index + 1 + ". " : "", error]
10196
- }, error))
10197
- }) : mutationResult.error.message,
10198
- type: "error",
10199
- style: {
10200
- marginTop: 16
10201
- }
10202
- }), /* @__PURE__ */ jsxRuntime.exports.jsx(kit.button, {
10203
- ...saveButtonProps,
10204
- type: "primary",
10183
+ className: FormStyle,
10184
+ children: (() => {
10185
+ if (isLoadingSchema) {
10186
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(kit.loading, {});
10187
+ }
10188
+ return editorProps.schema || schemaStrategy !== "Required" ? /* @__PURE__ */ jsxRuntime.exports.jsxs(jsxRuntime.exports.Fragment, {
10189
+ children: [/* @__PURE__ */ jsxRuntime.exports.jsx(kit.form.Item, {
10205
10190
  style: {
10206
- marginTop: 16
10191
+ flex: 1
10207
10192
  },
10208
- children: t("save")
10193
+ children: /* @__PURE__ */ jsxRuntime.exports.jsx(YamlEditorComponent, {
10194
+ ...editorProps,
10195
+ className: EditorStyle,
10196
+ schema,
10197
+ collapsable: false
10198
+ })
10199
+ }), /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.form.Item, {
10200
+ children: [mutationResult.error && /* @__PURE__ */ jsxRuntime.exports.jsx(kit.alert, {
10201
+ message: errorResponseBody ? /* @__PURE__ */ jsxRuntime.exports.jsx("ul", {
10202
+ children: responseErrors.map((error, index) => /* @__PURE__ */ jsxRuntime.exports.jsxs("li", {
10203
+ children: [responseErrors.length > 1 ? index + 1 + ". " : "", error]
10204
+ }, error))
10205
+ }) : mutationResult.error.message,
10206
+ type: "error",
10207
+ style: {
10208
+ marginTop: 16
10209
+ }
10210
+ }), /* @__PURE__ */ jsxRuntime.exports.jsx(kit.button, {
10211
+ ...saveButtonProps,
10212
+ type: "primary",
10213
+ style: {
10214
+ marginTop: 16
10215
+ },
10216
+ children: t("dovetail.save")
10217
+ })]
10209
10218
  })]
10210
- })]
10211
- }) : /* @__PURE__ */ jsxRuntime.exports.jsx(kit.loading, {})
10219
+ }) : /* @__PURE__ */ jsxRuntime.exports.jsx(WidgetErrorContent, {
10220
+ errorText: t("dovetail.fetch_schema_fail"),
10221
+ refetch: fetchSchema
10222
+ });
10223
+ })()
10212
10224
  })
10213
10225
  });
10214
10226
  }
@@ -10228,25 +10240,23 @@ function ResourceForm(props) {
10228
10240
  }
10229
10241
  const ResourceCRUD = (props) => {
10230
10242
  const { configs, urlPrefix } = props;
10231
- const { i18n: i18n2 } = useTranslation();
10232
10243
  return /* @__PURE__ */ jsxRuntime.exports.jsx(jsxRuntime.exports.Fragment, { children: configs.map((config) => {
10233
10244
  var _a, _b;
10234
- const formatter = config.formatter || ((v) => new ResourceModel(v));
10235
10245
  return /* @__PURE__ */ jsxRuntime.exports.jsxs(React.Fragment, { children: [
10236
10246
  /* @__PURE__ */ jsxRuntime.exports.jsx(Route, { path: `${urlPrefix}/${config.name}`, exact: true, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
10237
10247
  ResourceList,
10238
10248
  {
10239
10249
  name: config.kind,
10240
- formatter,
10241
- columns: ((_a = config.columns) == null ? void 0 : _a.call(config, i18n2)) || [],
10250
+ formatter: config.formatter,
10251
+ columns: ((_a = config.columns) == null ? void 0 : _a.call(config)) || [],
10242
10252
  Dropdown: config.Dropdown
10243
10253
  }
10244
10254
  ) }),
10245
10255
  /* @__PURE__ */ jsxRuntime.exports.jsx(Route, { path: `${urlPrefix}/${config.name}/show`, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
10246
10256
  ResourceShow,
10247
10257
  {
10248
- formatter,
10249
- filedGroups: ((_b = config.showFields) == null ? void 0 : _b.call(config, i18n2)) || [],
10258
+ formatter: config.formatter,
10259
+ filedGroups: ((_b = config.showFields) == null ? void 0 : _b.call(config)) || [],
10250
10260
  Dropdown: config.Dropdown
10251
10261
  }
10252
10262
  ) }),
@@ -10256,19 +10266,19 @@ const ResourceCRUD = (props) => {
10256
10266
  }) });
10257
10267
  };
10258
10268
  function CronJobDropdown(props) {
10259
- var _a;
10260
- const { data: data2 } = props;
10269
+ const { record } = props;
10270
+ const { spec } = record;
10261
10271
  const kit = useUIKit();
10262
10272
  const { resource } = useResource();
10263
10273
  const { mutate } = useUpdate();
10264
10274
  const { t } = useTranslation();
10265
- const suspended = Boolean((_a = data2.spec) == null ? void 0 : _a.suspend);
10266
- return /* @__PURE__ */ jsxRuntime.exports.jsx(K8sDropdown, { data: data2, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
10275
+ const suspended = Boolean(spec == null ? void 0 : spec.suspend);
10276
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(K8sDropdown, { record, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
10267
10277
  kit.menu.Item,
10268
10278
  {
10269
10279
  onClick: () => {
10270
- const v = suspended ? data2.resume() : data2.suspend();
10271
- const id = v.id;
10280
+ const v = suspended ? record.resume() : record.suspend();
10281
+ const id = record.id;
10272
10282
  pruneBeforeEdit(v);
10273
10283
  mutate({
10274
10284
  id,
@@ -10280,35 +10290,104 @@ function CronJobDropdown(props) {
10280
10290
  }
10281
10291
  ) });
10282
10292
  }
10283
- const index_1wzdp7m = "";
10284
- const WrapperStyle = "wfg6u6g";
10285
- const InnerBar = ({
10286
- usage,
10287
- requestNum,
10288
- limitNum
10289
- }) => {
10290
- const usageNum = parseSi(usage);
10291
- const totalNum = limitNum || requestNum / 0.8;
10292
- const requestPercent = 100 * requestNum / totalNum;
10293
- const usageInRequestPercent = 100 * Math.min(usageNum / requestNum, 1);
10294
- const usageInRequestToLimitPercent = 100 * Math.min(Math.max(usageNum - requestNum, 0) / (totalNum - requestNum), 1);
10295
- const noLimit = limitNum === 0;
10296
- return /* @__PURE__ */ jsxRuntime.exports.jsxs("div", {
10297
- className: "usage-bar",
10298
- style: {
10299
- marginLeft: 4
10300
- },
10301
- children: [/* @__PURE__ */ jsxRuntime.exports.jsx("div", {
10302
- className: "request-anchor",
10303
- style: {
10304
- left: `${requestPercent}%`
10305
- }
10306
- }), /* @__PURE__ */ jsxRuntime.exports.jsx("div", {
10307
- className: "request-bar",
10308
- style: {
10309
- width: `${requestPercent}%`
10310
- },
10311
- children: /* @__PURE__ */ jsxRuntime.exports.jsx("div", {
10293
+ const UNITS = ["", "K", "M", "G", "T", "P"];
10294
+ const FRACTIONAL = ["", "m", "u", "n", "p", "f"];
10295
+ function formatSi(inValue, options) {
10296
+ const {
10297
+ increment = 1e3,
10298
+ suffix = null,
10299
+ firstSuffix = null,
10300
+ startingExponent = 0,
10301
+ minExponent = 0,
10302
+ maxPrecision = 2,
10303
+ atLeastOne = true
10304
+ } = options || {};
10305
+ let val = inValue;
10306
+ let exp = startingExponent;
10307
+ while (val >= increment && exp + 1 < UNITS.length || exp < minExponent) {
10308
+ val = val / increment;
10309
+ exp++;
10310
+ }
10311
+ let out = 0;
10312
+ if (val < 10 && maxPrecision >= 2) {
10313
+ out = Math.round(val * 100) / 100;
10314
+ } else if (val < 100 && maxPrecision >= 1) {
10315
+ out = Math.round(val * 10) / 10;
10316
+ } else {
10317
+ out = Math.round(val);
10318
+ }
10319
+ if (atLeastOne && out === 0) {
10320
+ out = 1;
10321
+ }
10322
+ let outStr = String(out);
10323
+ if (exp === 0 && firstSuffix !== null) {
10324
+ outStr += `${firstSuffix}`;
10325
+ } else {
10326
+ outStr += `${UNITS[exp]}${suffix}` || "";
10327
+ }
10328
+ return outStr;
10329
+ }
10330
+ function parseSi(inValue, increment = null, allowFractional = true) {
10331
+ if (!inValue || typeof inValue !== "string" || !inValue.length) {
10332
+ return NaN;
10333
+ }
10334
+ inValue = inValue.replace(/,/g, "");
10335
+ let [, valStr, unit, incStr] = inValue.match(/^([0-9.-]+)\s*([^0-9.-]?)([^0-9.-]?)/) || [];
10336
+ const val = parseFloat(valStr);
10337
+ if (!unit) {
10338
+ return val;
10339
+ }
10340
+ if (unit.charCodeAt(0) === 181) {
10341
+ unit = "u";
10342
+ }
10343
+ const divide = FRACTIONAL.includes(unit);
10344
+ const multiply = UNITS.includes(unit.toUpperCase());
10345
+ if (increment === null) {
10346
+ if ((multiply || divide) && incStr === "i") {
10347
+ increment = 1024;
10348
+ } else {
10349
+ increment = 1e3;
10350
+ }
10351
+ }
10352
+ if (divide && allowFractional) {
10353
+ const exp = FRACTIONAL.indexOf(unit);
10354
+ return val / Math.pow(increment, exp);
10355
+ }
10356
+ if (multiply) {
10357
+ const exp = UNITS.indexOf(unit.toUpperCase());
10358
+ return val * Math.pow(increment, exp);
10359
+ }
10360
+ return val;
10361
+ }
10362
+ const index_1wzdp7m = "";
10363
+ const WrapperStyle = "wfg6u6g";
10364
+ const InnerBar = ({
10365
+ usage,
10366
+ requestNum,
10367
+ limitNum
10368
+ }) => {
10369
+ const usageNum = parseSi(usage);
10370
+ const totalNum = limitNum || requestNum / 0.8;
10371
+ const requestPercent = 100 * requestNum / totalNum;
10372
+ const usageInRequestPercent = 100 * Math.min(usageNum / requestNum, 1);
10373
+ const usageInRequestToLimitPercent = 100 * Math.min(Math.max(usageNum - requestNum, 0) / (totalNum - requestNum), 1);
10374
+ const noLimit = limitNum === 0;
10375
+ return /* @__PURE__ */ jsxRuntime.exports.jsxs("div", {
10376
+ className: "usage-bar",
10377
+ style: {
10378
+ marginLeft: 4
10379
+ },
10380
+ children: [/* @__PURE__ */ jsxRuntime.exports.jsx("div", {
10381
+ className: "request-anchor",
10382
+ style: {
10383
+ left: `${requestPercent}%`
10384
+ }
10385
+ }), /* @__PURE__ */ jsxRuntime.exports.jsx("div", {
10386
+ className: "request-bar",
10387
+ style: {
10388
+ width: `${requestPercent}%`
10389
+ },
10390
+ children: /* @__PURE__ */ jsxRuntime.exports.jsx("div", {
10312
10391
  className: "usage-fill-bar",
10313
10392
  style: {
10314
10393
  width: `${usageInRequestPercent}%`
@@ -10352,7 +10431,7 @@ const DeleteButton = () => {
10352
10431
  (resource == null ? void 0 : resource.name) || ""
10353
10432
  );
10354
10433
  return /* @__PURE__ */ jsxRuntime.exports.jsxs(jsxRuntime.exports.Fragment, { children: [
10355
- /* @__PURE__ */ jsxRuntime.exports.jsx(kit.button, { type: "primary", danger: true, onClick: () => openDeleteConfirmModal(id || ""), children: t("delete") }),
10434
+ /* @__PURE__ */ jsxRuntime.exports.jsx(kit.button, { type: "primary", danger: true, onClick: () => openDeleteConfirmModal(id || ""), children: t("dovetail.delete") }),
10356
10435
  visible ? /* @__PURE__ */ jsxRuntime.exports.jsx(kit.modal, { ...modalProps }) : null
10357
10436
  ] });
10358
10437
  };
@@ -14823,7 +14902,7 @@ const escapeTextForHtml = (inputString) => inputString.replace(/[&<>"']/gm, (str
14823
14902
  return "&#x27;";
14824
14903
  }
14825
14904
  });
14826
- const LogViewerRow = memo(({ index, style: style2, data: data2, ansiUp }) => {
14905
+ const LogViewerRow = memo(({ index, style, data: data2, ansiUp }) => {
14827
14906
  const { parsedData, searchedWordIndexes, rowInFocus } = data2;
14828
14907
  const context = useContext(LogViewerContext);
14829
14908
  const getData = (index2) => parsedData ? parsedData[index2] : null;
@@ -14867,7 +14946,7 @@ const LogViewerRow = memo(({ index, style: style2, data: data2, ansiUp }) => {
14867
14946
  };
14868
14947
  return React.createElement(
14869
14948
  "div",
14870
- { style: style2, className: css(styles$1.logViewerListItem) },
14949
+ { style, className: css(styles$1.logViewerListItem) },
14871
14950
  React.createElement("span", { className: css(styles$1.logViewerIndex) }, getRowIndex(index)),
14872
14951
  React.createElement("span", { className: css(styles$1.logViewerText), style: { width: "fit-content" }, dangerouslySetInnerHTML: { __html: ansiUp.ansi_to_html(getFormattedData()) } })
14873
14952
  );
@@ -14995,19 +15074,19 @@ function createListComponent({ getItemOffset, getEstimatedTotalSize: getEstimate
14995
15074
  this._getItemStyle = (index) => {
14996
15075
  const { itemSize } = this.props;
14997
15076
  const itemStyleCache = this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && itemSize);
14998
- let style2;
15077
+ let style;
14999
15078
  if (itemStyleCache.hasOwnProperty(index)) {
15000
- style2 = itemStyleCache[index];
15079
+ style = itemStyleCache[index];
15001
15080
  } else {
15002
15081
  const offset = getItemOffset(this.props, index, this._instanceProps);
15003
15082
  const size = getItemSize(this.props, index, this._instanceProps);
15004
- itemStyleCache[index] = style2 = {
15083
+ itemStyleCache[index] = style = {
15005
15084
  position: "absolute",
15006
15085
  top: offset,
15007
15086
  height: size
15008
15087
  };
15009
15088
  }
15010
- return style2;
15089
+ return style;
15011
15090
  };
15012
15091
  this._getItemStyleCache = memoizeOne(() => ({}));
15013
15092
  this._onScrollVertical = (event2) => {
@@ -15124,7 +15203,7 @@ function createListComponent({ getItemOffset, getEstimatedTotalSize: getEstimate
15124
15203
  });
15125
15204
  }
15126
15205
  render() {
15127
- const { children, outerClassName, innerClassName, height, innerRef, innerElementType, innerTagName, itemCount, itemData, itemKey = defaultItemKey, outerElementType, outerTagName, style: style2, useIsScrolling, width, isTextWrapped, hasLineNumbers, indexWidth, ansiUp } = this.props;
15206
+ const { children, outerClassName, innerClassName, height, innerRef, innerElementType, innerTagName, itemCount, itemData, itemKey = defaultItemKey, outerElementType, outerTagName, style, useIsScrolling, width, isTextWrapped, hasLineNumbers, indexWidth, ansiUp } = this.props;
15128
15207
  const { isScrolling } = this.state;
15129
15208
  const onScroll = this._onScrollVertical;
15130
15209
  const [startIndex, stopIndex] = this._getRangeToRender();
@@ -15147,7 +15226,7 @@ function createListComponent({ getItemOffset, getEstimatedTotalSize: getEstimate
15147
15226
  onScroll,
15148
15227
  ref: this._outerRefSetter,
15149
15228
  tabIndex: 0,
15150
- style: Object.assign({ height, paddingTop: 0, paddingBottom: 0, WebkitOverflowScrolling: "touch", overflowX: isTextWrapped ? "hidden" : "auto" }, style2)
15229
+ style: Object.assign({ height, paddingTop: 0, paddingBottom: 0, WebkitOverflowScrolling: "touch", overflowX: isTextWrapped ? "hidden" : "auto" }, style)
15151
15230
  }, createElement(innerElementType || innerTagName || "div", {
15152
15231
  className: innerClassName,
15153
15232
  ref: innerRef,
@@ -15964,7 +16043,7 @@ const PodLog = ({
15964
16043
  var _a, _b, _c, _d, _e;
15965
16044
  const kit = useUIKit();
15966
16045
  const [selectedContainer, setSelectedContainer] = useState(((_b = (_a = pod.spec) == null ? void 0 : _a.containers[0]) == null ? void 0 : _b.name) || "");
15967
- const [follow, setFollow] = useState(true);
16046
+ const follow = true;
15968
16047
  const [logs, setLogs] = useState([]);
15969
16048
  const [currentItemCount, setCurrentItemCount] = useState(0);
15970
16049
  const [paused, setPaused] = useState(false);
@@ -16012,7 +16091,7 @@ const PodLog = ({
16012
16091
  signal
16013
16092
  } = abortControllerRef.current;
16014
16093
  let url = `${apiUrl}/api/v1/namespaces/${(_a2 = pod.metadata) == null ? void 0 : _a2.namespace}/pods/${(_b2 = pod.metadata) == null ? void 0 : _b2.name}/log?container=${selectedContainer}&tailLines=100&timestamps=true`;
16015
- if (follow) {
16094
+ {
16016
16095
  url += "&follow=true";
16017
16096
  }
16018
16097
  fetch(url, {
@@ -16037,270 +16116,529 @@ const PodLog = ({
16037
16116
  if (lastIndex === -1) {
16038
16117
  buffer += chunk;
16039
16118
  }
16040
- const total = buffer + chunk.slice(0, lastIndex);
16041
- buffer = chunk.slice(lastIndex + 1);
16042
- const formattedLogs = total.split("\n").filter(Boolean).map((line) => {
16043
- const [timestamps, ...content] = line.split(" ");
16044
- const t2 = new Date(timestamps).toLocaleString();
16045
- if (t2 === "Invalid Date") {
16046
- return line;
16047
- }
16048
- return `${t2} ${content.join(" ")}`;
16049
- }).join("\n");
16050
- setLogs((prevLogs) => prevLogs.concat(formattedLogs.split("\n")));
16051
- reader.read().then(processChunk);
16052
- };
16053
- reader.read().then(processChunk);
16119
+ const total = buffer + chunk.slice(0, lastIndex);
16120
+ buffer = chunk.slice(lastIndex + 1);
16121
+ const formattedLogs = total.split("\n").filter(Boolean).map((line) => {
16122
+ const [timestamps, ...content] = line.split(" ");
16123
+ const t2 = new Date(timestamps).toLocaleString();
16124
+ if (t2 === "Invalid Date") {
16125
+ return line;
16126
+ }
16127
+ return `${t2} ${content.join(" ")}`;
16128
+ }).join("\n");
16129
+ setLogs((prevLogs) => prevLogs.concat(formattedLogs.split("\n")));
16130
+ reader.read().then(processChunk);
16131
+ };
16132
+ reader.read().then(processChunk);
16133
+ });
16134
+ }, [follow, (_c = pod.metadata) == null ? void 0 : _c.namespace, (_d = pod.metadata) == null ? void 0 : _d.name, selectedContainer]);
16135
+ const stopFetchingLogs = useCallback(() => {
16136
+ if (abortControllerRef.current) {
16137
+ abortControllerRef.current.abort();
16138
+ abortControllerRef.current = null;
16139
+ }
16140
+ }, []);
16141
+ useEffect(() => {
16142
+ fetchLogs();
16143
+ return () => {
16144
+ stopFetchingLogs();
16145
+ };
16146
+ }, [fetchLogs, stopFetchingLogs]);
16147
+ return /* @__PURE__ */ jsxRuntime.exports.jsxs("div", {
16148
+ children: [/* @__PURE__ */ jsxRuntime.exports.jsxs("div", {
16149
+ className: ToolbarStyle,
16150
+ children: [/* @__PURE__ */ jsxRuntime.exports.jsxs(kit.select, {
16151
+ input: {
16152
+ onChange: (newValue) => {
16153
+ stopFetchingLogs();
16154
+ setSelectedContainer(newValue);
16155
+ setLogs([]);
16156
+ setPaused(false);
16157
+ setLinesBehind(0);
16158
+ },
16159
+ value: selectedContainer
16160
+ },
16161
+ children: [/* @__PURE__ */ jsxRuntime.exports.jsx(kit.option, {
16162
+ value: "",
16163
+ disabled: true,
16164
+ children: t("dovetail.select_container")
16165
+ }), (((_e = pod.spec) == null ? void 0 : _e.containers) || []).map((container2) => /* @__PURE__ */ jsxRuntime.exports.jsx(kit.option, {
16166
+ value: container2.name,
16167
+ children: container2.name
16168
+ }, container2.name))]
16169
+ }), /* @__PURE__ */ jsxRuntime.exports.jsx(kit.checkbox, {
16170
+ checked: wrap2,
16171
+ onChange: (e) => setWrap(e.target.checked),
16172
+ children: t("dovetail.wrap")
16173
+ }), /* @__PURE__ */ jsxRuntime.exports.jsx(kit.button, {
16174
+ onClick: () => setPaused((prev) => !prev),
16175
+ prefixIcon: paused ? /* @__PURE__ */ jsxRuntime.exports.jsx(Resume24Icon, {}) : /* @__PURE__ */ jsxRuntime.exports.jsx(SuspendedPause24GradientOrangeIcon, {}),
16176
+ children: paused ? t("dovetail.resume_log") : t("dovetail.suspend")
16177
+ })]
16178
+ }), /* @__PURE__ */ jsxRuntime.exports.jsx(LogViewer, {
16179
+ innerRef: logViewerRef,
16180
+ hasLineNumbers: true,
16181
+ height: 300,
16182
+ data: logs,
16183
+ theme: "light",
16184
+ isTextWrapped: wrap2,
16185
+ footer: paused && /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.button, {
16186
+ type: "primary",
16187
+ style: {
16188
+ borderRadius: 0
16189
+ },
16190
+ onClick: () => setPaused(false),
16191
+ children: [t("dovetail.resume_log"), linesBehind === 0 ? null : t("dovetail.log_new_lines", {
16192
+ count: linesBehind
16193
+ })]
16194
+ }),
16195
+ onScroll
16196
+ })]
16197
+ });
16198
+ };
16199
+ function getSecondsDiff(startDate, endDate) {
16200
+ return Math.round(Math.abs(Date.parse(endDate) - Date.parse(startDate)) / 1e3);
16201
+ }
16202
+ function elapsedTime(seconds) {
16203
+ if (!seconds) {
16204
+ return {};
16205
+ }
16206
+ if (seconds < 120) {
16207
+ return {
16208
+ diff: 1,
16209
+ label: `${seconds}s`
16210
+ };
16211
+ }
16212
+ const minutes = Math.floor(seconds / 60);
16213
+ if (minutes < 10) {
16214
+ return {
16215
+ diff: 1,
16216
+ label: `${minutes}m${seconds - minutes * 60}s`
16217
+ };
16218
+ }
16219
+ const hours = Math.floor(seconds / 3600);
16220
+ if (hours < 3) {
16221
+ return {
16222
+ diff: 60,
16223
+ label: `${minutes}m`
16224
+ };
16225
+ }
16226
+ const days = Math.floor(seconds / (3600 * 24));
16227
+ if (days > 1) {
16228
+ return {
16229
+ diff: 60,
16230
+ label: `${days}d${hours - days * 24}h`
16231
+ };
16232
+ }
16233
+ if (hours > 7) {
16234
+ return {
16235
+ diff: 60,
16236
+ label: `${hours}h`
16237
+ };
16238
+ }
16239
+ return {
16240
+ diff: 60,
16241
+ label: `${hours}h${minutes - hours * 60}m`
16242
+ };
16243
+ }
16244
+ function shortenedImage(image2) {
16245
+ return (image2 || "").replace(/^(index\.)?docker.io\/(library\/)?/, "").replace(/:latest$/, "").replace(/^(.*@sha256:)([0-9a-f]{8})[0-9a-f]+$/i, "$1$2\u2026");
16246
+ }
16247
+ class ResourceModel {
16248
+ constructor(_rawYaml, _globalStore) {
16249
+ __publicField(this, "id");
16250
+ __publicField(this, "apiVersion");
16251
+ __publicField(this, "kind");
16252
+ __publicField(this, "metadata");
16253
+ this._rawYaml = _rawYaml;
16254
+ this._globalStore = _globalStore;
16255
+ Object.keys(_rawYaml).forEach((key) => {
16256
+ Object.defineProperty(this, key, {
16257
+ value: _rawYaml[key]
16258
+ });
16259
+ });
16260
+ }
16261
+ async init() {
16262
+ }
16263
+ get name() {
16264
+ var _a;
16265
+ return (_a = this._rawYaml.metadata) == null ? void 0 : _a.name;
16266
+ }
16267
+ get namespace() {
16268
+ var _a;
16269
+ return (_a = this._rawYaml.metadata) == null ? void 0 : _a.namespace;
16270
+ }
16271
+ get labels() {
16272
+ var _a;
16273
+ return (_a = this._rawYaml.metadata) == null ? void 0 : _a.labels;
16274
+ }
16275
+ get annotations() {
16276
+ var _a;
16277
+ return (_a = this._rawYaml.metadata) == null ? void 0 : _a.annotations;
16278
+ }
16279
+ restore() {
16280
+ return this._rawYaml;
16281
+ }
16282
+ }
16283
+ class WorkloadBaseModel extends ResourceModel {
16284
+ constructor(_rawYaml, _globalStore) {
16285
+ super(_rawYaml, _globalStore);
16286
+ this._rawYaml = _rawYaml;
16287
+ this._globalStore = _globalStore;
16288
+ }
16289
+ get imageNames() {
16290
+ var _a, _b, _c, _d;
16291
+ const containers = this._rawYaml.spec && "jobTemplate" in this._rawYaml.spec ? (_b = (_a = this._rawYaml.spec.jobTemplate.spec) == null ? void 0 : _a.template.spec) == null ? void 0 : _b.containers : this._rawYaml.spec && "template" in this._rawYaml.spec ? (_d = (_c = this._rawYaml.spec) == null ? void 0 : _c.template.spec) == null ? void 0 : _d.containers : [];
16292
+ return (containers == null ? void 0 : containers.map((container2) => shortenedImage(container2.image || ""))) || [];
16293
+ }
16294
+ }
16295
+ class JobModel extends WorkloadBaseModel {
16296
+ constructor(_rawYaml, _globalStore) {
16297
+ super(_rawYaml, _globalStore);
16298
+ this._rawYaml = _rawYaml;
16299
+ this._globalStore = _globalStore;
16300
+ }
16301
+ get duration() {
16302
+ var _a, _b;
16303
+ const completionTime = (_a = this._rawYaml.status) == null ? void 0 : _a.completionTime;
16304
+ const startTime = (_b = this._rawYaml.status) == null ? void 0 : _b.startTime;
16305
+ if (!completionTime && startTime) {
16306
+ return getSecondsDiff(startTime, Date.now().toString());
16307
+ }
16308
+ if (completionTime && startTime) {
16309
+ return getSecondsDiff(startTime, completionTime);
16310
+ }
16311
+ return 0;
16312
+ }
16313
+ get durationDisplay() {
16314
+ return elapsedTime(this.duration).label;
16315
+ }
16316
+ get completionsDisplay() {
16317
+ var _a, _b;
16318
+ return `${((_a = this._rawYaml.status) == null ? void 0 : _a.succeeded) || 0}/${(_b = this._rawYaml.spec) == null ? void 0 : _b.completions}`;
16319
+ }
16320
+ }
16321
+ function matchSelector(pod, selector) {
16322
+ var _a, _b, _c;
16323
+ let match = true;
16324
+ for (const key in selector.matchLabels) {
16325
+ if (!((_b = (_a = pod.metadata) == null ? void 0 : _a.labels) == null ? void 0 : _b[key]) || ((_c = pod.metadata.labels) == null ? void 0 : _c[key]) !== selector.matchLabels[key]) {
16326
+ match = false;
16327
+ }
16328
+ }
16329
+ return match;
16330
+ }
16331
+ class WorkloadModel extends WorkloadBaseModel {
16332
+ constructor(_rawYaml, _globalStore) {
16333
+ super(_rawYaml, _globalStore);
16334
+ __publicField(this, "restarts", 0);
16335
+ this._rawYaml = _rawYaml;
16336
+ this._globalStore = _globalStore;
16337
+ }
16338
+ async init() {
16339
+ await this.getRestarts();
16340
+ }
16341
+ async getRestarts() {
16342
+ const pods = await this._globalStore.get("pods", {
16343
+ resourceBasePath: "/api/v1",
16344
+ kind: "Pod"
16345
+ });
16346
+ const myPods = pods.items.filter(
16347
+ (p) => {
16348
+ var _a, _b;
16349
+ return ((_a = this.spec) == null ? void 0 : _a.selector) ? matchSelector(p, (_b = this.spec) == null ? void 0 : _b.selector) : false;
16350
+ }
16351
+ );
16352
+ const result = lodash.exports.sumBy(myPods, "restartCount");
16353
+ this.restarts = result;
16354
+ }
16355
+ redeploy() {
16356
+ const rawYaml = this._globalStore.restoreItem(this);
16357
+ const newOne = lodash.exports.cloneDeep(rawYaml);
16358
+ const path = "spec.template.metadata.annotations";
16359
+ const annotations = lodash.exports.get(newOne, path, {});
16360
+ lodash.exports.set(newOne, path, {
16361
+ ...annotations,
16362
+ [TIMESTAMP_LABEL]: new Date().toISOString().replace(/\.\d+Z$/, "Z")
16363
+ });
16364
+ return newOne;
16365
+ }
16366
+ scale(value) {
16367
+ const rawYaml = this._globalStore.restoreItem(this);
16368
+ const newOne = lodash.exports.cloneDeep(rawYaml);
16369
+ if (newOne.kind === "Deployment" || newOne.kind === "StatefulSet") {
16370
+ lodash.exports.set(newOne, "spec.replicas", value);
16371
+ }
16372
+ return newOne;
16373
+ }
16374
+ }
16375
+ class PodModel extends WorkloadBaseModel {
16376
+ constructor(_rawYaml, _globalStore) {
16377
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
16378
+ super(_rawYaml, _globalStore);
16379
+ __publicField(this, "request");
16380
+ __publicField(this, "limit");
16381
+ this._rawYaml = _rawYaml;
16382
+ this._globalStore = _globalStore;
16383
+ let cpuRequestNum = 0;
16384
+ let memoryRequestNum = 0;
16385
+ let cpuLimitNum = 0;
16386
+ let memoryLimitNum = 0;
16387
+ for (const container2 of ((_a = _rawYaml.spec) == null ? void 0 : _a.containers) || []) {
16388
+ cpuRequestNum += parseSi(((_c = (_b = container2.resources) == null ? void 0 : _b.requests) == null ? void 0 : _c.cpu) || "0");
16389
+ memoryRequestNum += parseSi(((_e = (_d = container2.resources) == null ? void 0 : _d.requests) == null ? void 0 : _e.memory) || "0");
16390
+ cpuLimitNum += parseSi(((_g = (_f = container2.resources) == null ? void 0 : _f.limits) == null ? void 0 : _g.cpu) || "0");
16391
+ memoryLimitNum += parseSi(((_i = (_h = container2.resources) == null ? void 0 : _h.limits) == null ? void 0 : _i.memory) || "0");
16392
+ }
16393
+ this.request = {
16394
+ cpu: {
16395
+ value: cpuRequestNum,
16396
+ si: formatSi(cpuRequestNum, {
16397
+ suffix: "m"
16398
+ })
16399
+ },
16400
+ memory: {
16401
+ value: memoryRequestNum,
16402
+ si: formatSi(memoryRequestNum, {
16403
+ suffix: "i"
16404
+ })
16405
+ }
16406
+ };
16407
+ this.limit = {
16408
+ cpu: {
16409
+ value: cpuLimitNum,
16410
+ si: formatSi(cpuLimitNum, {
16411
+ suffix: "m"
16412
+ })
16413
+ },
16414
+ memory: {
16415
+ value: memoryLimitNum,
16416
+ si: formatSi(memoryLimitNum, {
16417
+ suffix: "i"
16418
+ })
16419
+ }
16420
+ };
16421
+ }
16422
+ get imageNames() {
16423
+ var _a;
16424
+ return ((_a = this._rawYaml.spec) == null ? void 0 : _a.containers.map(
16425
+ (container2) => shortenedImage(container2.image || "")
16426
+ )) || [];
16427
+ }
16428
+ get restartCount() {
16429
+ var _a, _b;
16430
+ if ((_a = this._rawYaml.status) == null ? void 0 : _a.containerStatuses) {
16431
+ return ((_b = this._rawYaml.status) == null ? void 0 : _b.containerStatuses[0].restartCount) || 0;
16432
+ }
16433
+ return 0;
16434
+ }
16435
+ get readyDisplay() {
16436
+ var _a, _b, _c;
16437
+ return `${(_b = (_a = this._rawYaml.status) == null ? void 0 : _a.containerStatuses) == null ? void 0 : _b.filter((c) => c.ready).length}/${(_c = this._rawYaml.spec) == null ? void 0 : _c.containers.length}`;
16438
+ }
16439
+ get readyContainerCount() {
16440
+ var _a, _b;
16441
+ return (_b = (_a = this._rawYaml.status) == null ? void 0 : _a.containerStatuses) == null ? void 0 : _b.filter((c) => c.ready).length;
16442
+ }
16443
+ get containerCount() {
16444
+ var _a;
16445
+ return (_a = this._rawYaml.spec) == null ? void 0 : _a.containers.length;
16446
+ }
16447
+ }
16448
+ class PodMetricsModel extends ResourceModel {
16449
+ constructor(_rawYaml, _globalStore) {
16450
+ super(_rawYaml, _globalStore);
16451
+ __publicField(this, "usage");
16452
+ this._rawYaml = _rawYaml;
16453
+ this._globalStore = _globalStore;
16454
+ let cpuUsageNum = 0;
16455
+ let memoryUsageNum = 0;
16456
+ for (const container2 of _rawYaml.containers) {
16457
+ cpuUsageNum += parseSi(container2.usage.cpu || "0");
16458
+ memoryUsageNum += parseSi(container2.usage.memory || "0");
16459
+ }
16460
+ this.usage = {
16461
+ cpu: {
16462
+ value: cpuUsageNum,
16463
+ si: formatSi(1e3 * cpuUsageNum, {
16464
+ suffix: "m",
16465
+ maxPrecision: 0
16466
+ })
16467
+ },
16468
+ memory: {
16469
+ value: memoryUsageNum,
16470
+ si: formatSi(memoryUsageNum, {
16471
+ suffix: "i",
16472
+ maxPrecision: 0
16473
+ })
16474
+ }
16475
+ };
16476
+ }
16477
+ }
16478
+ class CronJobModel extends WorkloadBaseModel {
16479
+ constructor(_rawYaml, _globalStore) {
16480
+ super(_rawYaml, _globalStore);
16481
+ this._rawYaml = _rawYaml;
16482
+ this._globalStore = _globalStore;
16483
+ }
16484
+ suspend() {
16485
+ const newOne = lodash.exports.cloneDeep(this._rawYaml);
16486
+ if (this._rawYaml.kind === "CronJob") {
16487
+ lodash.exports.set(newOne, "spec.suspend", true);
16488
+ }
16489
+ return newOne;
16490
+ }
16491
+ resume() {
16492
+ const newOne = lodash.exports.cloneDeep(this._rawYaml);
16493
+ if (this._rawYaml.kind === "CronJob") {
16494
+ lodash.exports.set(newOne, "spec.suspend", false);
16495
+ }
16496
+ return newOne;
16497
+ }
16498
+ }
16499
+ class EventModel extends ResourceModel {
16500
+ constructor(_rawYaml, _globalStore) {
16501
+ super(_rawYaml, _globalStore);
16502
+ this._rawYaml = _rawYaml;
16503
+ this._globalStore = _globalStore;
16504
+ this.id = _rawYaml.metadata.uid || _rawYaml.id;
16505
+ }
16506
+ }
16507
+ const ModelMap = {
16508
+ Deployment: WorkloadModel,
16509
+ DaemonSet: WorkloadModel,
16510
+ StatefulSet: WorkloadModel,
16511
+ CronJob: CronJobModel,
16512
+ Job: JobModel,
16513
+ Pod: PodModel,
16514
+ Event: EventModel
16515
+ };
16516
+ class ModelPlugin {
16517
+ constructor() {
16518
+ __publicField(this, "_globalStore");
16519
+ }
16520
+ init(globalStore) {
16521
+ this._globalStore = globalStore;
16522
+ }
16523
+ async processData(res) {
16524
+ const { kind, apiVersion } = res;
16525
+ const items = await Promise.all(
16526
+ res.items.map((item) => {
16527
+ const newItem = { ...item };
16528
+ newItem.kind = kind.replace(/List$/g, "");
16529
+ newItem.apiVersion = apiVersion;
16530
+ return this.processItem(newItem);
16531
+ })
16532
+ );
16533
+ return {
16534
+ ...res,
16535
+ items
16536
+ };
16537
+ }
16538
+ async processItem(item) {
16539
+ const Model = ModelMap[item.kind] || ResourceModel;
16540
+ const result = new Model(item, this._globalStore);
16541
+ await result.init();
16542
+ return result;
16543
+ }
16544
+ restoreData(res) {
16545
+ ({ ...res });
16546
+ res.items.map((item) => this.restoreItem(item));
16547
+ return res;
16548
+ }
16549
+ restoreItem(item) {
16550
+ return item._rawYaml;
16551
+ }
16552
+ }
16553
+ const modelPlugin = new ModelPlugin();
16554
+ class RelationPlugin {
16555
+ constructor() {
16556
+ __publicField(this, "globalStore");
16557
+ }
16558
+ init(globalStore) {
16559
+ this.globalStore = globalStore;
16560
+ }
16561
+ async processData(res) {
16562
+ const { kind, apiVersion } = res;
16563
+ const items = await Promise.all(
16564
+ res.items.map(
16565
+ (item) => this.processItem({
16566
+ ...item,
16567
+ kind: kind.replace(/List$/g, ""),
16568
+ apiVersion
16569
+ })
16570
+ )
16571
+ );
16572
+ return {
16573
+ ...res,
16574
+ items
16575
+ };
16576
+ }
16577
+ async processItem(item) {
16578
+ this.processPodSelector(item);
16579
+ return item;
16580
+ }
16581
+ restoreData(res) {
16582
+ res.items = res.items.map((item) => this.restoreItem(item));
16583
+ return res;
16584
+ }
16585
+ restoreItem(item) {
16586
+ return {
16587
+ ...item,
16588
+ metadata: lodash.exports.omit(item.metadata, "relations")
16589
+ };
16590
+ }
16591
+ processPodSelector(item) {
16592
+ const { spec, kind } = item;
16593
+ const selector = spec == null ? void 0 : spec.selector;
16594
+ if (!selector) {
16595
+ return item;
16596
+ }
16597
+ if (!kind || ![
16598
+ "Deployment",
16599
+ "DaemonSet",
16600
+ "StatefulSet",
16601
+ "ReplicaSet",
16602
+ "Job",
16603
+ "Service"
16604
+ ].includes(kind)) {
16605
+ return item;
16606
+ }
16607
+ if (!selector.matchLabels && !selector.matchExpressions) {
16608
+ selector.matchLabels = {};
16609
+ for (const key of Object.keys(selector)) {
16610
+ if (key === "matchLabels") {
16611
+ continue;
16612
+ }
16613
+ selector.matchLabels[key] = selector[key];
16614
+ delete selector[key];
16615
+ }
16616
+ }
16617
+ this.appendRelation(item, {
16618
+ kind: "Pod",
16619
+ apiVersion: "v1",
16620
+ type: kind === "Service" ? "selects" : "creates",
16621
+ selector,
16622
+ inbound: false
16054
16623
  });
16055
- }, [follow, (_c = pod.metadata) == null ? void 0 : _c.namespace, (_d = pod.metadata) == null ? void 0 : _d.name, selectedContainer]);
16056
- const stopFetchingLogs = useCallback(() => {
16057
- if (abortControllerRef.current) {
16058
- abortControllerRef.current.abort();
16059
- abortControllerRef.current = null;
16624
+ return item;
16625
+ }
16626
+ appendRelation(item, relation) {
16627
+ const metadata = item.metadata;
16628
+ if (!metadata.relations) {
16629
+ metadata.relations = [];
16060
16630
  }
16061
- }, []);
16062
- useEffect(() => {
16063
- fetchLogs();
16064
- return () => {
16065
- stopFetchingLogs();
16066
- };
16067
- }, [fetchLogs, stopFetchingLogs]);
16068
- return /* @__PURE__ */ jsxRuntime.exports.jsxs("div", {
16069
- children: [/* @__PURE__ */ jsxRuntime.exports.jsxs("div", {
16070
- className: ToolbarStyle,
16071
- children: [/* @__PURE__ */ jsxRuntime.exports.jsxs(kit.select, {
16072
- input: {
16073
- onChange: (newValue) => {
16074
- stopFetchingLogs();
16075
- setSelectedContainer(newValue);
16076
- setLogs([]);
16077
- setPaused(false);
16078
- setLinesBehind(0);
16079
- },
16080
- value: selectedContainer
16081
- },
16082
- children: [/* @__PURE__ */ jsxRuntime.exports.jsx(kit.option, {
16083
- value: "",
16084
- disabled: true,
16085
- children: t("select_container")
16086
- }), (((_e = pod.spec) == null ? void 0 : _e.containers) || []).map((container2) => /* @__PURE__ */ jsxRuntime.exports.jsx(kit.option, {
16087
- value: container2.name,
16088
- children: container2.name
16089
- }, container2.name))]
16090
- }), /* @__PURE__ */ jsxRuntime.exports.jsx(kit.checkbox, {
16091
- checked: wrap2,
16092
- onChange: (e) => setWrap(e.target.checked),
16093
- children: t("wrap")
16094
- }), /* @__PURE__ */ jsxRuntime.exports.jsx(kit.button, {
16095
- onClick: () => setPaused((prev) => !prev),
16096
- prefixIcon: paused ? /* @__PURE__ */ jsxRuntime.exports.jsx(Resume24Icon, {}) : /* @__PURE__ */ jsxRuntime.exports.jsx(SuspendedPause24GradientOrangeIcon, {}),
16097
- children: paused ? t("resume_log") : t("suspend")
16098
- })]
16099
- }), /* @__PURE__ */ jsxRuntime.exports.jsx(LogViewer, {
16100
- innerRef: logViewerRef,
16101
- hasLineNumbers: true,
16102
- height: 300,
16103
- data: logs,
16104
- theme: "light",
16105
- isTextWrapped: wrap2,
16106
- footer: paused && /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.button, {
16107
- type: "primary",
16108
- style: {
16109
- borderRadius: 0
16110
- },
16111
- onClick: () => setPaused(false),
16112
- children: [t("resume_log"), linesBehind === 0 ? null : t("log_new_lines", {
16113
- count: linesBehind
16114
- })]
16115
- }),
16116
- onScroll
16117
- })]
16118
- });
16119
- };
16120
- const copy$1 = "Copy";
16121
- const reset_arguments$1 = "Reset";
16122
- const view_changes$1 = "Show Diff";
16123
- const back_to_edit$1 = "Edit";
16124
- const configure_file$1 = "Configuration";
16125
- const yaml_format_wrong$1 = "Configuration is in an invalid YAML format.";
16126
- const yaml_value_wrong$1 = "Configuration has invalid values.";
16127
- const edit_yaml$1 = "Edit YAML";
16128
- const copied$1 = "Copied";
16129
- const already_reset$1 = "Already reset";
16130
- const dovetail$1 = {
16131
- copy: copy$1,
16132
- reset_arguments: reset_arguments$1,
16133
- view_changes: view_changes$1,
16134
- back_to_edit: back_to_edit$1,
16135
- configure_file: configure_file$1,
16136
- yaml_format_wrong: yaml_format_wrong$1,
16137
- yaml_value_wrong: yaml_value_wrong$1,
16138
- edit_yaml: edit_yaml$1,
16139
- copied: copied$1,
16140
- already_reset: already_reset$1
16141
- };
16142
- const EN = {
16143
- dovetail: dovetail$1
16144
- };
16145
- const copy = "\u590D\u5236";
16146
- const reset_arguments = "\u91CD\u7F6E";
16147
- const view_changes = "\u67E5\u770B\u6539\u52A8";
16148
- const back_to_edit = "\u7F16\u8F91";
16149
- const configure_file = "\u914D\u7F6E\u5185\u5BB9";
16150
- const yaml_format_wrong = "\u914D\u7F6E\u5185\u5BB9\u4E0D\u662F\u6709\u6548\u7684 yaml \u683C\u5F0F\u3002";
16151
- const yaml_value_wrong = "\u914D\u7F6E\u5185\u5BB9\u4E2D\u5B58\u5728\u4E0D\u5408\u6CD5\u7684\u503C\u3002";
16152
- const edit_yaml = "\u7F16\u8F91 YAML";
16153
- const copied = "\u5DF2\u590D\u5236";
16154
- const already_reset = "\u5DF2\u91CD\u7F6E";
16155
- const cancel = "\u53D6\u6D88";
16156
- const create = "\u521B\u5EFA";
16157
- const confirm_delete_text = "\u786E\u5B9A\u8981\u5220\u9664 {{target}} \u5417\uFF1F";
16158
- const edit = "\u7F16\u8F91";
16159
- const namespace = "\u540D\u5B57\u7A7A\u95F4";
16160
- const name = "\u540D\u5B57";
16161
- const state = "\u72B6\u6001";
16162
- const status = "\u72B6\u6001";
16163
- const phase = "\u72B6\u6001";
16164
- const image = "\u955C\u50CF";
16165
- const replicas = "\u526F\u672C\u6570";
16166
- const created_time = "\u521B\u5EFA\u65F6\u95F4";
16167
- const label = "\u6807\u7B7E";
16168
- const annotation = "\u6CE8\u91CA";
16169
- const type = "\u7C7B\u578B";
16170
- const event = "\u4E8B\u4EF6";
16171
- const reason = "\u539F\u56E0";
16172
- const object = "\u5BF9\u8C61";
16173
- const note = "\u4E8B\u4EF6\u4FE1\u606F";
16174
- const condition = "Condition";
16175
- const download_yaml = "\u4E0B\u8F7D YAML";
16176
- const detail = "\u8BE6\u60C5";
16177
- const node_name = "\u4E3B\u673A\u540D\u79F0";
16178
- const restarts = "\u91CD\u542F\u6B21\u6570";
16179
- const updated_time = "\u66F4\u65B0\u65F6\u95F4";
16180
- const message = "\u6D88\u606F";
16181
- const save = "\u4FDD\u5B58";
16182
- const more = "\u66F4\u591A";
16183
- const workload = "\u5DE5\u4F5C\u8D1F\u8F7D";
16184
- const all_namespaces = "\u6240\u6709\u540D\u5B57\u7A7A\u95F4";
16185
- const empty = "\u65E0\u53EF\u663E\u793A\u7684\u6570\u636E";
16186
- const schedule = "\u8C03\u5EA6";
16187
- const lastScheduleTime = "\u4E0A\u6B21\u8C03\u5EA6";
16188
- const duration = "\u6301\u7EED\u65F6\u95F4";
16189
- const completions = "\u5B8C\u6210 Job \u5386\u53F2\u6570";
16190
- const started = "\u5F00\u59CB\u65F6\u95F4";
16191
- const ready = "\u5C31\u7EEA";
16192
- const init_container = "\u521D\u59CB\u5316\u5BB9\u5668";
16193
- const container = "\u5BB9\u5668";
16194
- const redeploy = "\u91CD\u65B0\u90E8\u7F72";
16195
- const data = "\u6570\u636E";
16196
- const suspend = "\u6682\u505C";
16197
- const resume = "\u91CD\u65B0\u5F00\u59CB";
16198
- const cluster = "\u96C6\u7FA4";
16199
- const storage = "\u5B58\u50A8";
16200
- const network = "\u7F51\u7EDC";
16201
- const clusterIp = "\u96C6\u7FA4 IP";
16202
- const sessionAffinity = "\u4F1A\u8BDD\u4FDD\u6301";
16203
- const log = "\u65E5\u5FD7";
16204
- const select_container = "\u9009\u62E9\u5BB9\u5668";
16205
- const wrap = "\u6298\u53E0";
16206
- const resume_log = "\u7EE7\u7EED";
16207
- const log_new_lines = "\uFF0C\u5E76\u5C55\u793A {{ count }} \u884C\u65B0\u65E5\u5FD7";
16208
- const dovetail = {
16209
- copy,
16210
- reset_arguments,
16211
- view_changes,
16212
- back_to_edit,
16213
- configure_file,
16214
- yaml_format_wrong,
16215
- yaml_value_wrong,
16216
- edit_yaml,
16217
- copied,
16218
- already_reset,
16219
- cancel,
16220
- "delete": "\u5220\u9664",
16221
- create,
16222
- confirm_delete_text,
16223
- edit,
16224
- namespace,
16225
- name,
16226
- state,
16227
- status,
16228
- phase,
16229
- image,
16230
- replicas,
16231
- created_time,
16232
- label,
16233
- annotation,
16234
- type,
16235
- event,
16236
- reason,
16237
- object,
16238
- note,
16239
- condition,
16240
- download_yaml,
16241
- detail,
16242
- node_name,
16243
- restarts,
16244
- updated_time,
16245
- message,
16246
- save,
16247
- more,
16248
- workload,
16249
- all_namespaces,
16250
- empty,
16251
- schedule,
16252
- lastScheduleTime,
16253
- duration,
16254
- completions,
16255
- started,
16256
- ready,
16257
- init_container,
16258
- container,
16259
- redeploy,
16260
- data,
16261
- suspend,
16262
- resume,
16263
- cluster,
16264
- storage,
16265
- network,
16266
- clusterIp,
16267
- sessionAffinity,
16268
- log,
16269
- select_container,
16270
- wrap,
16271
- resume_log,
16272
- log_new_lines
16273
- };
16274
- const ZH = {
16275
- dovetail
16276
- };
16277
- const resources = {
16278
- "en-US": EN,
16279
- "zh-CN": ZH
16280
- };
16281
- i18n.use(initReactI18next).init({
16282
- supportedLngs: ["en-US", "zh-CN"],
16283
- resources,
16284
- ns: Object.keys(resources["zh-CN"]),
16285
- defaultNS: "dovetail",
16286
- fallbackLng: ["en-US", "zh-CN"],
16287
- lng: "zh-CN",
16288
- nsSeparator: "."
16289
- });
16631
+ metadata.relations.push(relation);
16632
+ return item;
16633
+ }
16634
+ }
16635
+ const relationPlugin = new RelationPlugin();
16636
+ const ProviderPlugins = [relationPlugin, modelPlugin];
16290
16637
  const styles = "";
16291
- const antd = "";
16292
- const style = "";
16293
16638
  const Dovetail = (props) => {
16294
- const {
16295
- resourcesConfig,
16296
- urlPrefix = "",
16297
- useHashUrl,
16298
- Layout: Layout2,
16299
- history,
16300
- globalStoreParams
16301
- } = props;
16639
+ const { resourcesConfig, urlPrefix = "", Layout: Layout2, history, globalStoreParams } = props;
16302
16640
  const globalStore = useMemo(() => {
16303
- return new GlobalStore(globalStoreParams);
16641
+ return new GlobalStore(globalStoreParams, ProviderPlugins);
16304
16642
  }, [globalStoreParams]);
16305
16643
  const notCustomResources = useMemo(() => {
16306
16644
  return resourcesConfig.filter((c) => !c.isCustom);
@@ -16315,7 +16653,7 @@ const Dovetail = (props) => {
16315
16653
  }
16316
16654
  return _content;
16317
16655
  }, [Layout2, notCustomResources, props.children, urlPrefix]);
16318
- return /* @__PURE__ */ jsxRuntime.exports.jsx(Router, { history, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
16656
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(Router, { history, children: /* @__PURE__ */ jsxRuntime.exports.jsx(GlobalStoreContext.Provider, { value: { globalStore }, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
16319
16657
  Refine,
16320
16658
  {
16321
16659
  dataProvider: {
@@ -16344,7 +16682,7 @@ const Dovetail = (props) => {
16344
16682
  }),
16345
16683
  children: content
16346
16684
  }
16347
- ) });
16685
+ ) }) });
16348
16686
  };
16349
16687
  var RESOURCE_GROUP = /* @__PURE__ */ ((RESOURCE_GROUP2) => {
16350
16688
  RESOURCE_GROUP2["WORKLOAD"] = "WORKLOAD";
@@ -16354,94 +16692,101 @@ var RESOURCE_GROUP = /* @__PURE__ */ ((RESOURCE_GROUP2) => {
16354
16692
  return RESOURCE_GROUP2;
16355
16693
  })(RESOURCE_GROUP || {});
16356
16694
  export {
16357
- JobsField as $,
16695
+ ConditionsField as $,
16358
16696
  AgeColumnRenderer as A,
16359
16697
  Breadcrumb as B,
16360
16698
  CommonSorter as C,
16361
16699
  DurationColumnRenderer as D,
16362
- ResourceCRUD as E,
16363
- WorkloadPodsTable as F,
16364
- CronJobDropdown as G,
16365
- ResourceUsageBar as H,
16700
+ ResourceShow as E,
16701
+ ResourceForm as F,
16702
+ ResourceCRUD as G,
16703
+ WorkloadPodsTable as H,
16366
16704
  ImageNames as I,
16367
- WorkloadReplicas as J,
16705
+ CronJobDropdown as J,
16368
16706
  KeyValueListWidget as K,
16369
- CronjobJobsTable as L,
16707
+ ResourceUsageBar as L,
16370
16708
  MetadataForm as M,
16371
16709
  NameColumnRenderer as N,
16372
- KeyValue as O,
16710
+ WorkloadReplicas as O,
16373
16711
  PhaseColumnRenderer as P,
16374
- Separator as Q,
16712
+ CronjobJobsTable as Q,
16375
16713
  ReplicasColumnRenderer as R,
16376
16714
  ServiceTypeColumnRenderer as S,
16377
- DeleteButton as T,
16378
- Layout as U,
16379
- ImageField as V,
16715
+ KeyValue as T,
16716
+ Separator as U,
16717
+ DeleteButton as V,
16380
16718
  WorkloadImageColumnRenderer as W,
16381
- ReplicaField as X,
16719
+ Layout as X,
16382
16720
  YamlEditorComponent as Y,
16383
- ConditionsField as Z,
16384
- PodsField as _,
16721
+ ImageField as Z,
16722
+ ReplicaField as _,
16385
16723
  useDeleteModal as a,
16386
- DataField as a0,
16387
- SecretDataField as a1,
16388
- StartTimeField as a2,
16389
- ServiceTypeField as a3,
16390
- ClusterIpField as a4,
16391
- SessionAffinityField as a5,
16392
- ServicePodsField as a6,
16393
- ShowContent as a7,
16394
- DeleteManyButton as a8,
16395
- ListPage as a9,
16396
- StateTag as aa,
16397
- DrawerShow as ab,
16398
- Menu as ac,
16399
- EditButton as ad,
16400
- NS_STORE_KEY as ae,
16401
- ALL_NS as af,
16402
- useNamespacesFilter as ag,
16403
- NamespacesFilter as ah,
16404
- Tags as ai,
16405
- PodLog as aj,
16406
- BASE_INIT_VALUE as ak,
16407
- DEPLOYMENT_INIT_VALUE as al,
16408
- CRONJOB_INIT_VALUE as am,
16409
- DAEMONSET_INIT_VALUE as an,
16410
- JOB_INIT_VALUE as ao,
16411
- STATEFULSET_INIT_VALUE as ap,
16412
- POD_INIT_VALUE as aq,
16413
- TIMESTAMP_LABEL as ar,
16414
- JobModel as as,
16415
- PodModel as at,
16416
- PodMetricsModel as au,
16417
- ResourceModel as av,
16418
- WorkloadModel as aw,
16419
- CronJobModel as ax,
16420
- Dovetail as ay,
16421
- RESOURCE_GROUP as az,
16724
+ PodsField as a0,
16725
+ JobsField as a1,
16726
+ DataField as a2,
16727
+ SecretDataField as a3,
16728
+ StartTimeField as a4,
16729
+ ServiceTypeField as a5,
16730
+ ClusterIpField as a6,
16731
+ SessionAffinityField as a7,
16732
+ ServicePodsField as a8,
16733
+ ShowContent as a9,
16734
+ WorkloadModel as aA,
16735
+ WorkloadBaseModel as aB,
16736
+ PodModel as aC,
16737
+ PodMetricsModel as aD,
16738
+ ResourceModel as aE,
16739
+ CronJobModel as aF,
16740
+ EventModel as aG,
16741
+ SchemaStrategy as aa,
16742
+ DeleteManyButton as ab,
16743
+ ListPage as ac,
16744
+ StateTag as ad,
16745
+ DrawerShow as ae,
16746
+ Menu as af,
16747
+ EditButton as ag,
16748
+ NS_STORE_KEY as ah,
16749
+ ALL_NS as ai,
16750
+ useNamespacesFilter as aj,
16751
+ NamespacesFilter as ak,
16752
+ Tags as al,
16753
+ PodLog as am,
16754
+ BASE_INIT_VALUE as an,
16755
+ DEPLOYMENT_INIT_VALUE as ao,
16756
+ CRONJOB_INIT_VALUE as ap,
16757
+ DAEMONSET_INIT_VALUE as aq,
16758
+ JOB_INIT_VALUE as ar,
16759
+ STATEFULSET_INIT_VALUE as as,
16760
+ POD_INIT_VALUE as at,
16761
+ SERVICE_INIT_VALUE as au,
16762
+ TIMESTAMP_LABEL as av,
16763
+ Dovetail as aw,
16764
+ RESOURCE_GROUP as ax,
16765
+ ComponentContext as ay,
16766
+ JobModel as az,
16422
16767
  NameSpaceColumnRenderer as b,
16423
- NodeNameColumnRenderer as c,
16424
- RestartCountColumnRenderer as d,
16425
- CompletionsCountColumnRenderer as e,
16426
- ColumnKeys as f,
16427
- useEagleTable as g,
16428
- useDownloadYAML as h,
16429
- useEdit as i,
16768
+ WorkloadRestartsColumnRenderer as c,
16769
+ NodeNameColumnRenderer as d,
16770
+ RestartCountColumnRenderer as e,
16771
+ CompletionsCountColumnRenderer as f,
16772
+ ColumnKeys as g,
16773
+ useEagleTable as h,
16774
+ useDownloadYAML as i,
16430
16775
  jsxRuntime as j,
16431
- NameInputWidget as k,
16432
- dnsSubDomainRules as l,
16433
- rfc1123LabelRules as m,
16434
- rfc1035LabelRules as n,
16435
- NamespaceSelectWidget as o,
16436
- namespaceRules as p,
16437
- PageShow as q,
16776
+ useEdit as k,
16777
+ useGlobalStore as l,
16778
+ NameInputWidget as m,
16779
+ dnsSubDomainRules as n,
16780
+ rfc1123LabelRules as o,
16781
+ rfc1035LabelRules as p,
16782
+ NamespaceSelectWidget as q,
16438
16783
  routerProvider as r,
16439
- ConditionsTable as s,
16440
- PodContainersTable as t,
16784
+ namespaceRules as s,
16785
+ PageShow as t,
16441
16786
  useSchema as u,
16442
- WorkloadDropdown as v,
16443
- CreateButton as w,
16444
- ResourceList as x,
16445
- ResourceShow as y,
16446
- ResourceForm as z
16787
+ ConditionsTable as v,
16788
+ PodContainersTable as w,
16789
+ WorkloadDropdown as x,
16790
+ CreateButton as y,
16791
+ ResourceList as z
16447
16792
  };