@dovetail-v2/refine 0.0.15 → 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 (55) hide show
  1. package/dist/{MonacoYamlDiffEditor.15656940.js → MonacoYamlDiffEditor.4fe9fad1.js} +1 -1
  2. package/dist/{index.82c82bb4.js → index.8dfa48ab.js} +656 -151
  3. package/dist/refine.js +72 -62
  4. package/dist/refine.umd.cjs +596 -91
  5. package/dist/style.css +1 -32594
  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 +1 -1
  9. package/lib/src/components/K8sDropdown/index.d.ts +2 -2
  10. package/lib/src/components/ListPage/index.d.ts +1 -1
  11. package/lib/src/components/PageShow/PageShow.d.ts +2 -2
  12. package/lib/src/components/PodLog/index.d.ts +1 -1
  13. package/lib/src/components/ResourceCRUD/create/index.d.ts +1 -1
  14. package/lib/src/components/ResourceCRUD/list/index.d.ts +2 -2
  15. package/lib/src/components/ResourceCRUD/show/index.d.ts +2 -2
  16. package/lib/src/components/ShowContent/ShowContent.d.ts +2 -2
  17. package/lib/src/components/ShowContent/fields.d.ts +1 -1
  18. package/lib/src/components/Table/index.d.ts +6 -2
  19. package/lib/src/components/WorkloadDropdown/index.d.ts +2 -2
  20. package/lib/src/components/WorkloadReplicas/index.d.ts +1 -1
  21. package/lib/src/contexts/component.d.ts +6 -0
  22. package/lib/src/contexts/global-store.d.ts +6 -0
  23. package/lib/src/contexts/index.d.ts +1 -0
  24. package/lib/src/hooks/index.d.ts +1 -0
  25. package/lib/src/hooks/useEagleTable/columns.d.ts +3 -3
  26. package/lib/src/hooks/useEagleTable/useEagleTable.d.ts +2 -2
  27. package/lib/src/hooks/useGlobalStore.d.ts +3 -0
  28. package/lib/src/index.d.ts +2 -0
  29. package/lib/src/main.d.ts +2 -0
  30. package/lib/src/model/pod-model.d.ts +2 -0
  31. package/lib/src/models/cronjob-model.d.ts +14 -0
  32. package/lib/src/models/event-model.d.ts +8 -0
  33. package/lib/src/models/index.d.ts +9 -0
  34. package/lib/src/models/job-model.d.ts +15 -0
  35. package/lib/src/models/pod-metrics-model.d.ts +9 -0
  36. package/lib/src/models/pod-model.d.ts +20 -0
  37. package/lib/src/models/resource-model.d.ts +21 -0
  38. package/lib/src/models/types/index.d.ts +1 -0
  39. package/lib/src/models/types/metric.d.ts +25 -0
  40. package/lib/src/models/workload-base-model.d.ts +13 -0
  41. package/lib/src/models/workload-model.d.ts +17 -0
  42. package/lib/src/pages/configmaps/index.d.ts +1 -1
  43. package/lib/src/pages/jobs/index.d.ts +1 -1
  44. package/lib/src/pages/secrets/index.d.ts +1 -1
  45. package/lib/src/pages/services/index.d.ts +1 -1
  46. package/lib/src/plugins/index.d.ts +2 -0
  47. package/lib/src/plugins/model-plugin.d.ts +12 -0
  48. package/lib/src/plugins/relation-plugin.d.ts +27 -0
  49. package/lib/src/plugins/type.d.ts +8 -0
  50. package/lib/src/providers/router-provider/index.d.ts +1 -1
  51. package/lib/src/types/resource.d.ts +4 -5
  52. package/lib/src/utils/error.d.ts +2 -2
  53. package/lib/src/utils/match-selector.d.ts +3 -0
  54. package/lib/src/utils/selector.d.ts +1 -1
  55. package/package.json +10 -4
@@ -13,12 +13,12 @@ import yaml from "js-yaml";
13
13
  import { isObject, get, merge } from "lodash-es";
14
14
  import { useForm } from "sunflower-antd";
15
15
  import i18n from "i18next";
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";
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 { GlobalStore, ProviderPlugins, dataProvider, liveProvider } from "k8s-api-provider";
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;
@@ -6769,6 +6769,10 @@ function generateYamlBySchema(defaultValue, schema) {
6769
6769
  const content = yaml.dump(merged);
6770
6770
  return content.replace(/(')(#.+?)(')/g, "$2").replace(/( +)(#)/g, "$2$1");
6771
6771
  }
6772
+ const GlobalStoreContext = createContext({});
6773
+ const useGlobalStore = () => {
6774
+ return useContext(GlobalStoreContext);
6775
+ };
6772
6776
  const useEagleForm = ({
6773
6777
  action,
6774
6778
  resource,
@@ -6807,6 +6811,7 @@ const useEagleForm = ({
6807
6811
  const [editorErrors, setEditorErrors] = useState([]);
6808
6812
  const [errorResponseBody, setErrorResponseBody] = useState(null);
6809
6813
  const useResourceResult = useResource();
6814
+ const { globalStore } = useGlobalStore();
6810
6815
  const kit = useUIKit();
6811
6816
  const {
6812
6817
  schema,
@@ -6911,7 +6916,7 @@ const useEagleForm = ({
6911
6916
  }
6912
6917
  }
6913
6918
  };
6914
- const initialValues = ((_c = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _c.data) ? queryResult.data.data.restore() : 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;
6915
6920
  if (initialValues) {
6916
6921
  pruneBeforeEdit(initialValues);
6917
6922
  }
@@ -7397,7 +7402,7 @@ const WorkloadReplicas = ({
7397
7402
  const currentReplicas = get(record, "spec.replicas", 0);
7398
7403
  const scale = (delta) => {
7399
7404
  const v = record.scale(currentReplicas + delta);
7400
- const id = v.id;
7405
+ const id = record.id;
7401
7406
  pruneBeforeEdit(v);
7402
7407
  mutate({
7403
7408
  id,
@@ -7782,7 +7787,7 @@ const DurationColumnRenderer = () => {
7782
7787
  };
7783
7788
  };
7784
7789
  const ServiceTypeColumnRenderer = () => {
7785
- const dataIndex = ["rawYaml", "spec", "type"];
7790
+ const dataIndex = ["spec", "type"];
7786
7791
  return {
7787
7792
  key: "type",
7788
7793
  title: i18n.t("dovetail.type"),
@@ -7833,8 +7838,9 @@ function useEdit() {
7833
7838
  return { edit: edit2 };
7834
7839
  }
7835
7840
  function K8sDropdown(props) {
7836
- const { data: data2 } = props;
7841
+ const { record } = props;
7837
7842
  const kit = useUIKit();
7843
+ const { globalStore } = useGlobalStore();
7838
7844
  const useResourceResult = useResource();
7839
7845
  const resource = useResourceResult.resource;
7840
7846
  const { edit: edit2 } = useEdit();
@@ -7852,8 +7858,8 @@ function K8sDropdown(props) {
7852
7858
  kit.menuItem,
7853
7859
  {
7854
7860
  onClick: () => {
7855
- if (data2.id) {
7856
- edit2(data2.id);
7861
+ if (record.id) {
7862
+ edit2(record.id);
7857
7863
  }
7858
7864
  },
7859
7865
  children: /* @__PURE__ */ jsxRuntime.exports.jsx(Icon, { src: EditPen16PrimaryIcon, children: t("dovetail.edit") })
@@ -7864,7 +7870,7 @@ function K8sDropdown(props) {
7864
7870
  {
7865
7871
  danger: true,
7866
7872
  onClick: () => {
7867
- openDeleteConfirmModal(data2.id);
7873
+ openDeleteConfirmModal(record.id);
7868
7874
  },
7869
7875
  children: /* @__PURE__ */ jsxRuntime.exports.jsx(Icon, { src: TrashBinDelete16Icon, children: t("dovetail.delete") })
7870
7876
  }
@@ -7874,10 +7880,10 @@ function K8sDropdown(props) {
7874
7880
  {
7875
7881
  onClick: () => {
7876
7882
  var _a;
7877
- if (data2.id) {
7883
+ if (record.id) {
7878
7884
  download2({
7879
- name: ((_a = data2.metadata) == null ? void 0 : _a.name) || data2.kind || "",
7880
- item: data2.restore()
7885
+ name: ((_a = record.metadata) == null ? void 0 : _a.name) || record.kind || "",
7886
+ item: (globalStore == null ? void 0 : globalStore.restoreItem(record)) || record
7881
7887
  });
7882
7888
  }
7883
7889
  },
@@ -8074,6 +8080,7 @@ const useEagleTable = (params) => {
8074
8080
  const { columns, tableProps, formatter, Dropdown = K8sDropdown } = params;
8075
8081
  const [selectedKeys, setSelectedKeys] = useState([]);
8076
8082
  const [currentPage, setCurrentPage] = useState((tableProps == null ? void 0 : tableProps.currentPage) || 1);
8083
+ const { resource } = useResource();
8077
8084
  const { value: nsFilter } = useNamespacesFilter();
8078
8085
  const useTableParams = useMemo(() => {
8079
8086
  const mergedParams = merge(params.useTableParams, {
@@ -8099,21 +8106,13 @@ const useEagleTable = (params) => {
8099
8106
  },
8100
8107
  [setCurrentPage]
8101
8108
  );
8102
- const actionColumn = {
8103
- key: "action",
8104
- display: true,
8105
- dataIndex: [],
8106
- title: () => /* @__PURE__ */ jsxRuntime.exports.jsx(Icon, { src: SettingsGear16GradientGrayIcon }),
8107
- render: (_, record) => {
8108
- return /* @__PURE__ */ jsxRuntime.exports.jsx(Dropdown, { data: record });
8109
- }
8110
- };
8111
8109
  const data2 = (_a = table.tableQueryResult.data) == null ? void 0 : _a.data;
8112
8110
  const finalDataSource = formatter ? data2 == null ? void 0 : data2.map(formatter) : data2;
8113
8111
  const finalProps = {
8112
+ tableKey: (resource == null ? void 0 : resource.name) || "table",
8114
8113
  loading: table.tableQueryResult.isLoading,
8115
- dataSource: finalDataSource || [],
8116
- columns: [...columns, actionColumn],
8114
+ data: finalDataSource || [],
8115
+ columns,
8117
8116
  refetch: () => null,
8118
8117
  error: false,
8119
8118
  rowKey: "id",
@@ -8122,7 +8121,8 @@ const useEagleTable = (params) => {
8122
8121
  onPageChange,
8123
8122
  onSelect: (keys) => {
8124
8123
  setSelectedKeys(keys);
8125
- }
8124
+ },
8125
+ RowMenu: Dropdown
8126
8126
  };
8127
8127
  return { tableProps: finalProps, selectedKeys, ...table };
8128
8128
  };
@@ -8491,23 +8491,23 @@ function styled(tag) {
8491
8491
  filteredProps.className = options.atomic ? cx_default(options.class, filteredProps.className || className) : cx_default(filteredProps.className || className, options.class);
8492
8492
  const { vars } = options;
8493
8493
  if (vars) {
8494
- const style2 = {};
8494
+ const style = {};
8495
8495
  for (const name2 in vars) {
8496
8496
  const variable = vars[name2];
8497
8497
  const result = variable[0];
8498
8498
  const unit = variable[1] || "";
8499
8499
  const value = typeof result === "function" ? result(props) : result;
8500
8500
  warnIfInvalid(value, options.name);
8501
- style2[`--${name2}`] = `${value}${unit}`;
8501
+ style[`--${name2}`] = `${value}${unit}`;
8502
8502
  }
8503
8503
  const ownStyle = filteredProps.style || {};
8504
8504
  const keys = Object.keys(ownStyle);
8505
8505
  if (keys.length > 0) {
8506
8506
  keys.forEach((key) => {
8507
- style2[key] = ownStyle[key];
8507
+ style[key] = ownStyle[key];
8508
8508
  });
8509
8509
  }
8510
- filteredProps.style = style2;
8510
+ filteredProps.style = style;
8511
8511
  }
8512
8512
  if (tag.__linaria && tag !== component) {
8513
8513
  filteredProps.as = component;
@@ -8548,12 +8548,13 @@ function Table(props) {
8548
8548
  const {
8549
8549
  loading,
8550
8550
  error,
8551
- dataSource,
8551
+ data: dataSource,
8552
8552
  rowKey,
8553
8553
  columns,
8554
8554
  scroll,
8555
8555
  currentPage,
8556
8556
  currentSize,
8557
+ RowMenu,
8557
8558
  refetch,
8558
8559
  onSelect,
8559
8560
  onPageChange,
@@ -8566,6 +8567,23 @@ function Table(props) {
8566
8567
  pageSize: currentSize,
8567
8568
  onChange: onPageChange
8568
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
+ });
8581
+ }
8582
+ };
8583
+ return [...columns, actionColumn];
8584
+ }
8585
+ return columns;
8586
+ }, [columns, RowMenu]);
8569
8587
  if (loading) {
8570
8588
  return /* @__PURE__ */ jsxRuntime.exports.jsx(kit.loading, {});
8571
8589
  } else if (error) {
@@ -8594,7 +8612,7 @@ function Table(props) {
8594
8612
  onSelect == null ? void 0 : onSelect(keys, rows);
8595
8613
  }
8596
8614
  } : void 0,
8597
- columns,
8615
+ columns: finalColumns,
8598
8616
  dataSource,
8599
8617
  pagination,
8600
8618
  error,
@@ -8735,8 +8753,9 @@ const CronjobJobsTable = ({
8735
8753
  selectedKeys,
8736
8754
  hideCreate: true
8737
8755
  }), /* @__PURE__ */ jsxRuntime.exports.jsx(Table, {
8756
+ tableKey: "cronjobs",
8738
8757
  loading: !dataSource,
8739
- dataSource: dataSource || [],
8758
+ data: dataSource || [],
8740
8759
  columns,
8741
8760
  onSelect: (keys) => setSelectedKeys(keys),
8742
8761
  rowKey: "id",
@@ -8780,7 +8799,7 @@ const KeyValue = ({ value }) => {
8780
8799
  }
8781
8800
  );
8782
8801
  };
8783
- function matchSelector(pod, selector) {
8802
+ function matchSelector$1(pod, selector) {
8784
8803
  var _a, _b, _c;
8785
8804
  let match = true;
8786
8805
  for (const key in selector.matchLabels) {
@@ -8808,7 +8827,7 @@ const WorkloadPodsTable = ({
8808
8827
  });
8809
8828
  const dataSource = useMemo(() => {
8810
8829
  return data2 == null ? void 0 : data2.data.filter((p) => {
8811
- return selector ? matchSelector(p, selector) : true;
8830
+ return selector ? matchSelector$1(p, selector) : true;
8812
8831
  });
8813
8832
  }, [data2 == null ? void 0 : data2.data, selector]);
8814
8833
  const columns = [PhaseColumnRenderer(), NameColumnRenderer("pods"), NodeNameColumnRenderer(), WorkloadImageColumnRenderer(), RestartCountColumnRenderer()];
@@ -8820,8 +8839,9 @@ const WorkloadPodsTable = ({
8820
8839
  selectedKeys,
8821
8840
  hideCreate: true
8822
8841
  }), /* @__PURE__ */ jsxRuntime.exports.jsx(Table, {
8842
+ tableKey: "pods",
8823
8843
  loading: !dataSource,
8824
- dataSource: dataSource || [],
8844
+ data: dataSource || [],
8825
8845
  columns,
8826
8846
  onSelect: (keys) => setSelectedKeys(keys),
8827
8847
  rowKey: "id",
@@ -8907,7 +8927,7 @@ const DataField = () => {
8907
8927
  return {
8908
8928
  key: "data",
8909
8929
  title: i18n.t("dovetail.data"),
8910
- path: ["rawYaml", "data"],
8930
+ path: ["data"],
8911
8931
  render: (val) => {
8912
8932
  return /* @__PURE__ */ jsxRuntime.exports.jsx(KeyValue, { value: val });
8913
8933
  }
@@ -8917,7 +8937,7 @@ const SecretDataField = () => {
8917
8937
  return {
8918
8938
  key: "data",
8919
8939
  title: i18n.t("dovetail.data"),
8920
- path: ["rawYaml", "data"],
8940
+ path: ["data"],
8921
8941
  render: (val) => {
8922
8942
  const decodeVal = {};
8923
8943
  for (const key in val) {
@@ -8941,21 +8961,21 @@ const ServiceTypeField = () => {
8941
8961
  return {
8942
8962
  key: "type",
8943
8963
  title: i18n.t("dovetail.type"),
8944
- path: ["rawYaml", "spec", "type"]
8964
+ path: ["spec", "type"]
8945
8965
  };
8946
8966
  };
8947
8967
  const ClusterIpField = () => {
8948
8968
  return {
8949
8969
  key: "clusterIp",
8950
8970
  title: i18n.t("dovetail.clusterIp"),
8951
- path: ["rawYaml", "spec", "clusterIP"]
8971
+ path: ["spec", "clusterIP"]
8952
8972
  };
8953
8973
  };
8954
8974
  const SessionAffinityField = () => {
8955
8975
  return {
8956
8976
  key: "clusterIp",
8957
8977
  title: i18n.t("dovetail.sessionAffinity"),
8958
- path: ["rawYaml", "spec", "sessionAffinity"]
8978
+ path: ["spec", "sessionAffinity"]
8959
8979
  };
8960
8980
  };
8961
8981
  const ServicePodsField = () => {
@@ -9151,51 +9171,51 @@ const EventsTable = ({}) => {
9151
9171
  {
9152
9172
  key: "type",
9153
9173
  display: true,
9154
- dataIndex: ["rawYaml", "type"],
9174
+ dataIndex: ["type"],
9155
9175
  title: i18n2.t("dovetail.type"),
9156
9176
  sortable: true,
9157
- sorter: CommonSorter(["rawYaml", "type"])
9177
+ sorter: CommonSorter(["type"])
9158
9178
  },
9159
9179
  {
9160
9180
  key: "reason",
9161
9181
  display: true,
9162
- dataIndex: ["rawYaml", "reason"],
9182
+ dataIndex: ["reason"],
9163
9183
  title: i18n2.t("dovetail.reason"),
9164
9184
  sortable: true,
9165
- sorter: CommonSorter(["rawYaml", "reason"])
9185
+ sorter: CommonSorter(["reason"])
9166
9186
  },
9167
9187
  {
9168
9188
  key: "object",
9169
9189
  display: true,
9170
- dataIndex: ["rawYaml", "regarding", "name"],
9190
+ dataIndex: ["regarding", "name"],
9171
9191
  title: i18n2.t("dovetail.object"),
9172
9192
  sortable: true,
9173
- sorter: CommonSorter(["rawYaml", "regarding", "name"])
9193
+ sorter: CommonSorter(["regarding", "name"])
9174
9194
  },
9175
9195
  {
9176
9196
  key: "note",
9177
9197
  display: true,
9178
- dataIndex: ["rawYaml", "note"],
9198
+ dataIndex: ["note"],
9179
9199
  title: i18n2.t("dovetail.note"),
9180
9200
  sortable: true,
9181
- sorter: CommonSorter(["rawYaml", "note"])
9201
+ sorter: CommonSorter(["note"])
9182
9202
  },
9183
9203
  AgeColumnRenderer()
9184
9204
  ],
9185
9205
  [i18n2]
9186
9206
  );
9187
- const dataSource = useMemo(
9188
- () => 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) => {
9189
9209
  const objectId = `${d.regarding.namespace}/${d.regarding.name}`;
9190
9210
  return objectId === parsed.id;
9191
- }),
9192
- [data2 == null ? void 0 : data2.data, parsed]
9193
- );
9211
+ });
9212
+ }, [data2 == null ? void 0 : data2.data, parsed]);
9194
9213
  return /* @__PURE__ */ jsxRuntime.exports.jsx(
9195
9214
  Table,
9196
9215
  {
9216
+ tableKey: "events",
9197
9217
  loading: isLoading,
9198
- dataSource: dataSource || [],
9218
+ data: dataSource || [],
9199
9219
  columns,
9200
9220
  rowKey: "id",
9201
9221
  error: false,
@@ -9239,6 +9259,9 @@ const ShowContent = (props) => {
9239
9259
  Dropdown = K8sDropdown
9240
9260
  } = props;
9241
9261
  const kit = useUIKit();
9262
+ const {
9263
+ globalStore
9264
+ } = useGlobalStore();
9242
9265
  const parsed = useParsed();
9243
9266
  const {
9244
9267
  resource
@@ -9346,7 +9369,7 @@ const ShowContent = (props) => {
9346
9369
  children: "YAML"
9347
9370
  })]
9348
9371
  }), /* @__PURE__ */ jsxRuntime.exports.jsx(Dropdown, {
9349
- data: record
9372
+ record
9350
9373
  })]
9351
9374
  })]
9352
9375
  });
@@ -9387,7 +9410,7 @@ const ShowContent = (props) => {
9387
9410
  }),
9388
9411
  ["yaml"]: /* @__PURE__ */ jsxRuntime.exports.jsx(MonacoYamlEditor$1, {
9389
9412
  className: EditorStyle$1,
9390
- defaultValue: yaml.dump(model.restore()),
9413
+ defaultValue: yaml.dump(globalStore == null ? void 0 : globalStore.restoreItem(model)),
9391
9414
  schema: {},
9392
9415
  onEditorCreate: (editor) => {
9393
9416
  fold(editor);
@@ -9525,16 +9548,16 @@ const PodContainersTable = ({
9525
9548
  );
9526
9549
  };
9527
9550
  function WorkloadDropdown(props) {
9528
- const { data: data2 } = props;
9551
+ const { record } = props;
9529
9552
  const kit = useUIKit();
9530
9553
  const { resource } = useResource();
9531
9554
  const { mutate } = useUpdate();
9532
9555
  const { t } = useTranslation();
9533
- 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(
9534
9557
  kit.menu.Item,
9535
9558
  {
9536
9559
  onClick: () => {
9537
- const v = data2.redeploy();
9560
+ const v = record.redeploy();
9538
9561
  const id = v.id;
9539
9562
  pruneBeforeEdit(v);
9540
9563
  mutate({
@@ -9547,6 +9570,7 @@ function WorkloadDropdown(props) {
9547
9570
  }
9548
9571
  ) });
9549
9572
  }
9573
+ const ComponentContext = createContext({});
9550
9574
  const index_3lw8k1 = "";
9551
9575
  const ListPageStyle = "laykzsq";
9552
9576
  const TableStyle = "t1ng0psc";
@@ -9556,12 +9580,16 @@ function ListPage(props) {
9556
9580
  selectedKeys,
9557
9581
  tableProps
9558
9582
  } = props;
9583
+ const {
9584
+ Table: TableComponent
9585
+ } = useContext(ComponentContext);
9586
+ const Table$1 = TableComponent || Table;
9559
9587
  return /* @__PURE__ */ jsxRuntime.exports.jsxs("div", {
9560
9588
  className: ListPageStyle,
9561
9589
  children: [/* @__PURE__ */ jsxRuntime.exports.jsx(TableToolBar, {
9562
9590
  title,
9563
9591
  selectedKeys
9564
- }), /* @__PURE__ */ jsxRuntime.exports.jsx(Table, {
9592
+ }), /* @__PURE__ */ jsxRuntime.exports.jsx(Table$1, {
9565
9593
  ...tableProps,
9566
9594
  className: TableStyle,
9567
9595
  scroll: {
@@ -9572,7 +9600,6 @@ function ListPage(props) {
9572
9600
  }
9573
9601
  function ResourceList(props) {
9574
9602
  const { formatter, name: name2, columns, Dropdown } = props;
9575
- useTranslation();
9576
9603
  const { tableProps, selectedKeys } = useEagleTable({
9577
9604
  useTableParams: {},
9578
9605
  columns: [
@@ -9648,7 +9675,7 @@ const Separator = () => {
9648
9675
  });
9649
9676
  };
9650
9677
  const MonacoYamlEditor = React.lazy(() => Promise.resolve().then(() => MonacoYamlEditor$2));
9651
- const MonacoYamlDiffEditor = React.lazy(() => import("./MonacoYamlDiffEditor.15656940.js"));
9678
+ const MonacoYamlDiffEditor = React.lazy(() => import("./MonacoYamlDiffEditor.4fe9fad1.js"));
9652
9679
  const YamlEditorComponent = forwardRef(
9653
9680
  function YamlEditorComponent2(props, ref) {
9654
9681
  const {
@@ -10136,7 +10163,8 @@ function YamlForm(props) {
10136
10163
  } = useEagleForm({
10137
10164
  editorOptions: {
10138
10165
  isSkipSchema: schemaStrategy === "None"
10139
- }
10166
+ },
10167
+ liveMode: "off"
10140
10168
  });
10141
10169
  const kit = useUIKit();
10142
10170
  const {
@@ -10144,6 +10172,9 @@ function YamlForm(props) {
10144
10172
  i18n: i18n2
10145
10173
  } = useTranslation();
10146
10174
  const responseErrors = errorResponseBody ? getCommonErrors(errorResponseBody, i18n2) : [];
10175
+ const schema = useMemo(() => {
10176
+ return editorProps.schema || {};
10177
+ }, [editorProps.schema]);
10147
10178
  return /* @__PURE__ */ jsxRuntime.exports.jsx(FormLayout, {
10148
10179
  children: /* @__PURE__ */ jsxRuntime.exports.jsx(kit.form, {
10149
10180
  ...formProps,
@@ -10162,7 +10193,7 @@ function YamlForm(props) {
10162
10193
  children: /* @__PURE__ */ jsxRuntime.exports.jsx(YamlEditorComponent, {
10163
10194
  ...editorProps,
10164
10195
  className: EditorStyle,
10165
- schema: editorProps.schema || {},
10196
+ schema,
10166
10197
  collapsable: false
10167
10198
  })
10168
10199
  }), /* @__PURE__ */ jsxRuntime.exports.jsxs(kit.form.Item, {
@@ -10209,7 +10240,6 @@ function ResourceForm(props) {
10209
10240
  }
10210
10241
  const ResourceCRUD = (props) => {
10211
10242
  const { configs, urlPrefix } = props;
10212
- const { i18n: i18n2 } = useTranslation();
10213
10243
  return /* @__PURE__ */ jsxRuntime.exports.jsx(jsxRuntime.exports.Fragment, { children: configs.map((config) => {
10214
10244
  var _a, _b;
10215
10245
  return /* @__PURE__ */ jsxRuntime.exports.jsxs(React.Fragment, { children: [
@@ -10218,7 +10248,7 @@ const ResourceCRUD = (props) => {
10218
10248
  {
10219
10249
  name: config.kind,
10220
10250
  formatter: config.formatter,
10221
- columns: ((_a = config.columns) == null ? void 0 : _a.call(config, i18n2)) || [],
10251
+ columns: ((_a = config.columns) == null ? void 0 : _a.call(config)) || [],
10222
10252
  Dropdown: config.Dropdown
10223
10253
  }
10224
10254
  ) }),
@@ -10226,7 +10256,7 @@ const ResourceCRUD = (props) => {
10226
10256
  ResourceShow,
10227
10257
  {
10228
10258
  formatter: config.formatter,
10229
- filedGroups: ((_b = config.showFields) == null ? void 0 : _b.call(config, i18n2)) || [],
10259
+ filedGroups: ((_b = config.showFields) == null ? void 0 : _b.call(config)) || [],
10230
10260
  Dropdown: config.Dropdown
10231
10261
  }
10232
10262
  ) }),
@@ -10236,19 +10266,19 @@ const ResourceCRUD = (props) => {
10236
10266
  }) });
10237
10267
  };
10238
10268
  function CronJobDropdown(props) {
10239
- const { data: data2 } = props;
10240
- const { spec } = data2;
10269
+ const { record } = props;
10270
+ const { spec } = record;
10241
10271
  const kit = useUIKit();
10242
10272
  const { resource } = useResource();
10243
10273
  const { mutate } = useUpdate();
10244
10274
  const { t } = useTranslation();
10245
10275
  const suspended = Boolean(spec == null ? void 0 : spec.suspend);
10246
- return /* @__PURE__ */ jsxRuntime.exports.jsx(K8sDropdown, { data: data2, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
10276
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(K8sDropdown, { record, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
10247
10277
  kit.menu.Item,
10248
10278
  {
10249
10279
  onClick: () => {
10250
- const v = suspended ? data2.resume() : data2.suspend();
10251
- const id = data2.id;
10280
+ const v = suspended ? record.resume() : record.suspend();
10281
+ const id = record.id;
10252
10282
  pruneBeforeEdit(v);
10253
10283
  mutate({
10254
10284
  id,
@@ -10262,6 +10292,41 @@ function CronJobDropdown(props) {
10262
10292
  }
10263
10293
  const UNITS = ["", "K", "M", "G", "T", "P"];
10264
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
+ }
10265
10330
  function parseSi(inValue, increment = null, allowFractional = true) {
10266
10331
  if (!inValue || typeof inValue !== "string" || !inValue.length) {
10267
10332
  return NaN;
@@ -14837,7 +14902,7 @@ const escapeTextForHtml = (inputString) => inputString.replace(/[&<>"']/gm, (str
14837
14902
  return "&#x27;";
14838
14903
  }
14839
14904
  });
14840
- const LogViewerRow = memo(({ index, style: style2, data: data2, ansiUp }) => {
14905
+ const LogViewerRow = memo(({ index, style, data: data2, ansiUp }) => {
14841
14906
  const { parsedData, searchedWordIndexes, rowInFocus } = data2;
14842
14907
  const context = useContext(LogViewerContext);
14843
14908
  const getData = (index2) => parsedData ? parsedData[index2] : null;
@@ -14881,7 +14946,7 @@ const LogViewerRow = memo(({ index, style: style2, data: data2, ansiUp }) => {
14881
14946
  };
14882
14947
  return React.createElement(
14883
14948
  "div",
14884
- { style: style2, className: css(styles$1.logViewerListItem) },
14949
+ { style, className: css(styles$1.logViewerListItem) },
14885
14950
  React.createElement("span", { className: css(styles$1.logViewerIndex) }, getRowIndex(index)),
14886
14951
  React.createElement("span", { className: css(styles$1.logViewerText), style: { width: "fit-content" }, dangerouslySetInnerHTML: { __html: ansiUp.ansi_to_html(getFormattedData()) } })
14887
14952
  );
@@ -15009,19 +15074,19 @@ function createListComponent({ getItemOffset, getEstimatedTotalSize: getEstimate
15009
15074
  this._getItemStyle = (index) => {
15010
15075
  const { itemSize } = this.props;
15011
15076
  const itemStyleCache = this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && itemSize);
15012
- let style2;
15077
+ let style;
15013
15078
  if (itemStyleCache.hasOwnProperty(index)) {
15014
- style2 = itemStyleCache[index];
15079
+ style = itemStyleCache[index];
15015
15080
  } else {
15016
15081
  const offset = getItemOffset(this.props, index, this._instanceProps);
15017
15082
  const size = getItemSize(this.props, index, this._instanceProps);
15018
- itemStyleCache[index] = style2 = {
15083
+ itemStyleCache[index] = style = {
15019
15084
  position: "absolute",
15020
15085
  top: offset,
15021
15086
  height: size
15022
15087
  };
15023
15088
  }
15024
- return style2;
15089
+ return style;
15025
15090
  };
15026
15091
  this._getItemStyleCache = memoizeOne(() => ({}));
15027
15092
  this._onScrollVertical = (event2) => {
@@ -15138,7 +15203,7 @@ function createListComponent({ getItemOffset, getEstimatedTotalSize: getEstimate
15138
15203
  });
15139
15204
  }
15140
15205
  render() {
15141
- 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;
15142
15207
  const { isScrolling } = this.state;
15143
15208
  const onScroll = this._onScrollVertical;
15144
15209
  const [startIndex, stopIndex] = this._getRangeToRender();
@@ -15161,7 +15226,7 @@ function createListComponent({ getItemOffset, getEstimatedTotalSize: getEstimate
15161
15226
  onScroll,
15162
15227
  ref: this._outerRefSetter,
15163
15228
  tabIndex: 0,
15164
- 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)
15165
15230
  }, createElement(innerElementType || innerTagName || "div", {
15166
15231
  className: innerClassName,
15167
15232
  ref: innerRef,
@@ -16131,17 +16196,447 @@ const PodLog = ({
16131
16196
  })]
16132
16197
  });
16133
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
16623
+ });
16624
+ return item;
16625
+ }
16626
+ appendRelation(item, relation) {
16627
+ const metadata = item.metadata;
16628
+ if (!metadata.relations) {
16629
+ metadata.relations = [];
16630
+ }
16631
+ metadata.relations.push(relation);
16632
+ return item;
16633
+ }
16634
+ }
16635
+ const relationPlugin = new RelationPlugin();
16636
+ const ProviderPlugins = [relationPlugin, modelPlugin];
16134
16637
  const styles = "";
16135
- const antd = "";
16136
- const style = "";
16137
16638
  const Dovetail = (props) => {
16138
- const {
16139
- resourcesConfig,
16140
- urlPrefix = "",
16141
- Layout: Layout2,
16142
- history,
16143
- globalStoreParams
16144
- } = props;
16639
+ const { resourcesConfig, urlPrefix = "", Layout: Layout2, history, globalStoreParams } = props;
16145
16640
  const globalStore = useMemo(() => {
16146
16641
  return new GlobalStore(globalStoreParams, ProviderPlugins);
16147
16642
  }, [globalStoreParams]);
@@ -16158,7 +16653,7 @@ const Dovetail = (props) => {
16158
16653
  }
16159
16654
  return _content;
16160
16655
  }, [Layout2, notCustomResources, props.children, urlPrefix]);
16161
- 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(
16162
16657
  Refine,
16163
16658
  {
16164
16659
  dataProvider: {
@@ -16187,7 +16682,7 @@ const Dovetail = (props) => {
16187
16682
  }),
16188
16683
  children: content
16189
16684
  }
16190
- ) });
16685
+ ) }) });
16191
16686
  };
16192
16687
  var RESOURCE_GROUP = /* @__PURE__ */ ((RESOURCE_GROUP2) => {
16193
16688
  RESOURCE_GROUP2["WORKLOAD"] = "WORKLOAD";
@@ -16197,68 +16692,78 @@ var RESOURCE_GROUP = /* @__PURE__ */ ((RESOURCE_GROUP2) => {
16197
16692
  return RESOURCE_GROUP2;
16198
16693
  })(RESOURCE_GROUP || {});
16199
16694
  export {
16200
- PodsField as $,
16695
+ ConditionsField as $,
16201
16696
  AgeColumnRenderer as A,
16202
16697
  Breadcrumb as B,
16203
16698
  CommonSorter as C,
16204
16699
  DurationColumnRenderer as D,
16205
- ResourceForm as E,
16206
- ResourceCRUD as F,
16207
- WorkloadPodsTable as G,
16208
- CronJobDropdown as H,
16700
+ ResourceShow as E,
16701
+ ResourceForm as F,
16702
+ ResourceCRUD as G,
16703
+ WorkloadPodsTable as H,
16209
16704
  ImageNames as I,
16210
- ResourceUsageBar as J,
16705
+ CronJobDropdown as J,
16211
16706
  KeyValueListWidget as K,
16212
- WorkloadReplicas as L,
16707
+ ResourceUsageBar as L,
16213
16708
  MetadataForm as M,
16214
16709
  NameColumnRenderer as N,
16215
- CronjobJobsTable as O,
16710
+ WorkloadReplicas as O,
16216
16711
  PhaseColumnRenderer as P,
16217
- KeyValue as Q,
16712
+ CronjobJobsTable as Q,
16218
16713
  ReplicasColumnRenderer as R,
16219
16714
  ServiceTypeColumnRenderer as S,
16220
- Separator as T,
16221
- DeleteButton as U,
16222
- Layout as V,
16715
+ KeyValue as T,
16716
+ Separator as U,
16717
+ DeleteButton as V,
16223
16718
  WorkloadImageColumnRenderer as W,
16224
- ImageField as X,
16719
+ Layout as X,
16225
16720
  YamlEditorComponent as Y,
16226
- ReplicaField as Z,
16227
- ConditionsField as _,
16721
+ ImageField as Z,
16722
+ ReplicaField as _,
16228
16723
  useDeleteModal as a,
16229
- JobsField as a0,
16230
- DataField as a1,
16231
- SecretDataField as a2,
16232
- StartTimeField as a3,
16233
- ServiceTypeField as a4,
16234
- ClusterIpField as a5,
16235
- SessionAffinityField as a6,
16236
- ServicePodsField as a7,
16237
- ShowContent as a8,
16238
- SchemaStrategy as a9,
16239
- DeleteManyButton as aa,
16240
- ListPage as ab,
16241
- StateTag as ac,
16242
- DrawerShow as ad,
16243
- Menu as ae,
16244
- EditButton as af,
16245
- NS_STORE_KEY as ag,
16246
- ALL_NS as ah,
16247
- useNamespacesFilter as ai,
16248
- NamespacesFilter as aj,
16249
- Tags as ak,
16250
- PodLog as al,
16251
- BASE_INIT_VALUE as am,
16252
- DEPLOYMENT_INIT_VALUE as an,
16253
- CRONJOB_INIT_VALUE as ao,
16254
- DAEMONSET_INIT_VALUE as ap,
16255
- JOB_INIT_VALUE as aq,
16256
- STATEFULSET_INIT_VALUE as ar,
16257
- POD_INIT_VALUE as as,
16258
- SERVICE_INIT_VALUE as at,
16259
- TIMESTAMP_LABEL as au,
16260
- Dovetail as av,
16261
- RESOURCE_GROUP as aw,
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,
16262
16767
  NameSpaceColumnRenderer as b,
16263
16768
  WorkloadRestartsColumnRenderer as c,
16264
16769
  NodeNameColumnRenderer as d,
@@ -16269,19 +16774,19 @@ export {
16269
16774
  useDownloadYAML as i,
16270
16775
  jsxRuntime as j,
16271
16776
  useEdit as k,
16272
- NameInputWidget as l,
16273
- dnsSubDomainRules as m,
16274
- rfc1123LabelRules as n,
16275
- rfc1035LabelRules as o,
16276
- NamespaceSelectWidget as p,
16277
- namespaceRules as q,
16777
+ useGlobalStore as l,
16778
+ NameInputWidget as m,
16779
+ dnsSubDomainRules as n,
16780
+ rfc1123LabelRules as o,
16781
+ rfc1035LabelRules as p,
16782
+ NamespaceSelectWidget as q,
16278
16783
  routerProvider as r,
16279
- PageShow as s,
16280
- ConditionsTable as t,
16784
+ namespaceRules as s,
16785
+ PageShow as t,
16281
16786
  useSchema as u,
16282
- PodContainersTable as v,
16283
- WorkloadDropdown as w,
16284
- CreateButton as x,
16285
- ResourceList as y,
16286
- ResourceShow as z
16787
+ ConditionsTable as v,
16788
+ PodContainersTable as w,
16789
+ WorkloadDropdown as x,
16790
+ CreateButton as y,
16791
+ ResourceList as z
16287
16792
  };