@dovetail-v2/refine 0.0.14-beta.1 → 0.0.14-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { j as jsxRuntime } from "./index.e31fb37e.js";
1
+ import { j as jsxRuntime } from "./index.6a36859b.js";
2
2
  import * as monaco from "monaco-editor";
3
3
  import { useRef, useEffect } from "react";
4
4
  import "@refinedev/core";
@@ -18,7 +18,7 @@ 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, dataProvider, liveProvider } from "k8s-api-provider";
21
+ import { 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;
@@ -6857,14 +6857,18 @@ const useEagleForm = ({
6857
6857
  const warnWhenUnsavedChanges = warnWhenUnsavedChangesProp != null ? warnWhenUnsavedChangesProp : warnWhenUnsavedChangesRefine;
6858
6858
  React.useEffect(() => {
6859
6859
  var _a2;
6860
+ form.resetFields();
6860
6861
  if (editor.current) {
6862
+ const editorValue = yaml.dump(form.getFieldsValue(true));
6861
6863
  const editorInstance = editor.current.getEditorInstance();
6864
+ editor.current.setEditorValue(editorValue);
6865
+ editor.current.setValue(editorValue);
6862
6866
  if (((_a2 = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a2.data) && editorInstance && !isFoldRef.current) {
6863
6867
  fold(editorInstance);
6864
6868
  isFoldRef.current = true;
6865
6869
  }
6866
6870
  }
6867
- }, [(_a = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a.data, id, fold]);
6871
+ }, [(_a = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a.data, id, form, fold]);
6868
6872
  React.useEffect(() => {
6869
6873
  var _a2, _b2;
6870
6874
  const response = (_a2 = useFormCoreResult.mutationResult.error) == null ? void 0 : _a2.response;
@@ -7398,7 +7402,7 @@ const WorkloadReplicas = ({
7398
7402
  const currentReplicas = get(record, "spec.replicas", 0);
7399
7403
  const scale = (delta) => {
7400
7404
  const v = record.scale(currentReplicas + delta);
7401
- const id = v.id;
7405
+ const id = record.id;
7402
7406
  pruneBeforeEdit(v);
7403
7407
  mutate({
7404
7408
  id,
@@ -8487,23 +8491,23 @@ function styled(tag) {
8487
8491
  filteredProps.className = options.atomic ? cx_default(options.class, filteredProps.className || className) : cx_default(filteredProps.className || className, options.class);
8488
8492
  const { vars } = options;
8489
8493
  if (vars) {
8490
- const style2 = {};
8494
+ const style = {};
8491
8495
  for (const name2 in vars) {
8492
8496
  const variable = vars[name2];
8493
8497
  const result = variable[0];
8494
8498
  const unit = variable[1] || "";
8495
8499
  const value = typeof result === "function" ? result(props) : result;
8496
8500
  warnIfInvalid(value, options.name);
8497
- style2[`--${name2}`] = `${value}${unit}`;
8501
+ style[`--${name2}`] = `${value}${unit}`;
8498
8502
  }
8499
8503
  const ownStyle = filteredProps.style || {};
8500
8504
  const keys = Object.keys(ownStyle);
8501
8505
  if (keys.length > 0) {
8502
8506
  keys.forEach((key) => {
8503
- style2[key] = ownStyle[key];
8507
+ style[key] = ownStyle[key];
8504
8508
  });
8505
8509
  }
8506
- filteredProps.style = style2;
8510
+ filteredProps.style = style;
8507
8511
  }
8508
8512
  if (tag.__linaria && tag !== component) {
8509
8513
  filteredProps.as = component;
@@ -9200,13 +9204,12 @@ const EventsTable = ({}) => {
9200
9204
  ],
9201
9205
  [i18n2]
9202
9206
  );
9203
- const dataSource = useMemo(
9204
- () => 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) => {
9205
9209
  const objectId = `${d.regarding.namespace}/${d.regarding.name}`;
9206
9210
  return objectId === parsed.id;
9207
- }),
9208
- [data2 == null ? void 0 : data2.data, parsed]
9209
- );
9211
+ });
9212
+ }, [data2 == null ? void 0 : data2.data, parsed]);
9210
9213
  return /* @__PURE__ */ jsxRuntime.exports.jsx(
9211
9214
  Table,
9212
9215
  {
@@ -9672,7 +9675,7 @@ const Separator = () => {
9672
9675
  });
9673
9676
  };
9674
9677
  const MonacoYamlEditor = React.lazy(() => Promise.resolve().then(() => MonacoYamlEditor$2));
9675
- const MonacoYamlDiffEditor = React.lazy(() => import("./MonacoYamlDiffEditor.e0df5a1b.js"));
9678
+ const MonacoYamlDiffEditor = React.lazy(() => import("./MonacoYamlDiffEditor.8f3588cd.js"));
9676
9679
  const YamlEditorComponent = forwardRef(
9677
9680
  function YamlEditorComponent2(props, ref) {
9678
9681
  const {
@@ -10160,7 +10163,8 @@ function YamlForm(props) {
10160
10163
  } = useEagleForm({
10161
10164
  editorOptions: {
10162
10165
  isSkipSchema: schemaStrategy === "None"
10163
- }
10166
+ },
10167
+ liveMode: "off"
10164
10168
  });
10165
10169
  const kit = useUIKit();
10166
10170
  const {
@@ -14898,7 +14902,7 @@ const escapeTextForHtml = (inputString) => inputString.replace(/[&<>"']/gm, (str
14898
14902
  return "&#x27;";
14899
14903
  }
14900
14904
  });
14901
- const LogViewerRow = memo(({ index, style: style2, data: data2, ansiUp }) => {
14905
+ const LogViewerRow = memo(({ index, style, data: data2, ansiUp }) => {
14902
14906
  const { parsedData, searchedWordIndexes, rowInFocus } = data2;
14903
14907
  const context = useContext(LogViewerContext);
14904
14908
  const getData = (index2) => parsedData ? parsedData[index2] : null;
@@ -14942,7 +14946,7 @@ const LogViewerRow = memo(({ index, style: style2, data: data2, ansiUp }) => {
14942
14946
  };
14943
14947
  return React.createElement(
14944
14948
  "div",
14945
- { style: style2, className: css(styles$1.logViewerListItem) },
14949
+ { style, className: css(styles$1.logViewerListItem) },
14946
14950
  React.createElement("span", { className: css(styles$1.logViewerIndex) }, getRowIndex(index)),
14947
14951
  React.createElement("span", { className: css(styles$1.logViewerText), style: { width: "fit-content" }, dangerouslySetInnerHTML: { __html: ansiUp.ansi_to_html(getFormattedData()) } })
14948
14952
  );
@@ -15070,19 +15074,19 @@ function createListComponent({ getItemOffset, getEstimatedTotalSize: getEstimate
15070
15074
  this._getItemStyle = (index) => {
15071
15075
  const { itemSize } = this.props;
15072
15076
  const itemStyleCache = this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && itemSize);
15073
- let style2;
15077
+ let style;
15074
15078
  if (itemStyleCache.hasOwnProperty(index)) {
15075
- style2 = itemStyleCache[index];
15079
+ style = itemStyleCache[index];
15076
15080
  } else {
15077
15081
  const offset = getItemOffset(this.props, index, this._instanceProps);
15078
15082
  const size = getItemSize(this.props, index, this._instanceProps);
15079
- itemStyleCache[index] = style2 = {
15083
+ itemStyleCache[index] = style = {
15080
15084
  position: "absolute",
15081
15085
  top: offset,
15082
15086
  height: size
15083
15087
  };
15084
15088
  }
15085
- return style2;
15089
+ return style;
15086
15090
  };
15087
15091
  this._getItemStyleCache = memoizeOne(() => ({}));
15088
15092
  this._onScrollVertical = (event2) => {
@@ -15199,7 +15203,7 @@ function createListComponent({ getItemOffset, getEstimatedTotalSize: getEstimate
15199
15203
  });
15200
15204
  }
15201
15205
  render() {
15202
- 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;
15203
15207
  const { isScrolling } = this.state;
15204
15208
  const onScroll = this._onScrollVertical;
15205
15209
  const [startIndex, stopIndex] = this._getRangeToRender();
@@ -15222,7 +15226,7 @@ function createListComponent({ getItemOffset, getEstimatedTotalSize: getEstimate
15222
15226
  onScroll,
15223
15227
  ref: this._outerRefSetter,
15224
15228
  tabIndex: 0,
15225
- 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)
15226
15230
  }, createElement(innerElementType || innerTagName || "div", {
15227
15231
  className: innerClassName,
15228
15232
  ref: innerRef,
@@ -16192,6 +16196,60 @@ const PodLog = ({
16192
16196
  })]
16193
16197
  });
16194
16198
  };
16199
+ const styles = "";
16200
+ const Dovetail = (props) => {
16201
+ const { resourcesConfig, urlPrefix = "", Layout: Layout2, history, globalStore } = props;
16202
+ const notCustomResources = useMemo(() => {
16203
+ return resourcesConfig.filter((c) => !c.isCustom);
16204
+ }, [resourcesConfig]);
16205
+ const content = useMemo(() => {
16206
+ const _content = /* @__PURE__ */ jsxRuntime.exports.jsxs(jsxRuntime.exports.Fragment, { children: [
16207
+ /* @__PURE__ */ jsxRuntime.exports.jsx(ResourceCRUD, { configs: notCustomResources, urlPrefix }),
16208
+ props.children
16209
+ ] });
16210
+ if (Layout2) {
16211
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(Layout2, { children: _content });
16212
+ }
16213
+ return _content;
16214
+ }, [Layout2, notCustomResources, props.children, urlPrefix]);
16215
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(Router, { history, children: /* @__PURE__ */ jsxRuntime.exports.jsx(GlobalStoreContext.Provider, { value: { globalStore }, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
16216
+ Refine,
16217
+ {
16218
+ dataProvider: {
16219
+ default: dataProvider(globalStore)
16220
+ },
16221
+ routerProvider,
16222
+ liveProvider: liveProvider(globalStore),
16223
+ options: {
16224
+ warnWhenUnsavedChanges: true,
16225
+ liveMode: "auto"
16226
+ },
16227
+ resources: resourcesConfig.map((c) => {
16228
+ return {
16229
+ name: c.name,
16230
+ meta: {
16231
+ resourceBasePath: c.basePath,
16232
+ kind: c.kind,
16233
+ parent: c.parent,
16234
+ label: `${c.kind}s`
16235
+ },
16236
+ list: `${urlPrefix}/${c.name}`,
16237
+ show: `${urlPrefix}/${c.name}/show`,
16238
+ create: `${urlPrefix}/${c.name}/create`,
16239
+ edit: `${urlPrefix}/${c.name}/edit`
16240
+ };
16241
+ }),
16242
+ children: content
16243
+ }
16244
+ ) }) });
16245
+ };
16246
+ var RESOURCE_GROUP = /* @__PURE__ */ ((RESOURCE_GROUP2) => {
16247
+ RESOURCE_GROUP2["WORKLOAD"] = "WORKLOAD";
16248
+ RESOURCE_GROUP2["STORAGE"] = "STORAGE";
16249
+ RESOURCE_GROUP2["NETWORK"] = "NETWORK";
16250
+ RESOURCE_GROUP2["CLUSTER"] = "CLUSTER";
16251
+ return RESOURCE_GROUP2;
16252
+ })(RESOURCE_GROUP || {});
16195
16253
  function getSecondsDiff(startDate, endDate) {
16196
16254
  return Math.round(Math.abs(Date.parse(endDate) - Date.parse(startDate)) / 1e3);
16197
16255
  }
@@ -16349,7 +16407,8 @@ class WorkloadModel extends WorkloadBaseModel {
16349
16407
  this.restarts = result;
16350
16408
  }
16351
16409
  redeploy() {
16352
- const newOne = lodash.exports.cloneDeep(this._rawYaml);
16410
+ const rawYaml = this._globalStore.restoreItem(this);
16411
+ const newOne = lodash.exports.cloneDeep(rawYaml);
16353
16412
  const path = "spec.template.metadata.annotations";
16354
16413
  const annotations = lodash.exports.get(newOne, path, {});
16355
16414
  lodash.exports.set(newOne, path, {
@@ -16359,7 +16418,8 @@ class WorkloadModel extends WorkloadBaseModel {
16359
16418
  return newOne;
16360
16419
  }
16361
16420
  scale(value) {
16362
- const newOne = lodash.exports.cloneDeep(this._rawYaml);
16421
+ const rawYaml = this._globalStore.restoreItem(this);
16422
+ const newOne = lodash.exports.cloneDeep(rawYaml);
16363
16423
  if (newOne.kind === "Deployment" || newOne.kind === "StatefulSet") {
16364
16424
  lodash.exports.set(newOne, "spec.replicas", value);
16365
16425
  }
@@ -16490,13 +16550,22 @@ class CronJobModel extends WorkloadBaseModel {
16490
16550
  return newOne;
16491
16551
  }
16492
16552
  }
16553
+ class EventModel extends ResourceModel {
16554
+ constructor(_rawYaml, _globalStore) {
16555
+ super(_rawYaml, _globalStore);
16556
+ this._rawYaml = _rawYaml;
16557
+ this._globalStore = _globalStore;
16558
+ this.id = _rawYaml.metadata.uid || _rawYaml.id;
16559
+ }
16560
+ }
16493
16561
  const ModelMap = {
16494
16562
  Deployment: WorkloadModel,
16495
16563
  DaemonSet: WorkloadModel,
16496
16564
  StatefulSet: WorkloadModel,
16497
16565
  CronJob: CronJobModel,
16498
16566
  Job: JobModel,
16499
- Pod: PodModel
16567
+ Pod: PodModel,
16568
+ Event: EventModel
16500
16569
  };
16501
16570
  class ModelPlugin {
16502
16571
  constructor() {
@@ -16619,65 +16688,6 @@ class RelationPlugin {
16619
16688
  }
16620
16689
  const relationPlugin = new RelationPlugin();
16621
16690
  const ProviderPlugins = [relationPlugin, modelPlugin];
16622
- const styles = "";
16623
- const antd = "";
16624
- const style = "";
16625
- const Dovetail = (props) => {
16626
- const { resourcesConfig, urlPrefix = "", Layout: Layout2, history, globalStoreParams } = props;
16627
- const globalStore = useMemo(() => {
16628
- return new GlobalStore(globalStoreParams, ProviderPlugins);
16629
- }, [globalStoreParams]);
16630
- const notCustomResources = useMemo(() => {
16631
- return resourcesConfig.filter((c) => !c.isCustom);
16632
- }, [resourcesConfig]);
16633
- const content = useMemo(() => {
16634
- const _content = /* @__PURE__ */ jsxRuntime.exports.jsxs(jsxRuntime.exports.Fragment, { children: [
16635
- /* @__PURE__ */ jsxRuntime.exports.jsx(ResourceCRUD, { configs: notCustomResources, urlPrefix }),
16636
- props.children
16637
- ] });
16638
- if (Layout2) {
16639
- return /* @__PURE__ */ jsxRuntime.exports.jsx(Layout2, { children: _content });
16640
- }
16641
- return _content;
16642
- }, [Layout2, notCustomResources, props.children, urlPrefix]);
16643
- return /* @__PURE__ */ jsxRuntime.exports.jsx(Router, { history, children: /* @__PURE__ */ jsxRuntime.exports.jsx(GlobalStoreContext.Provider, { value: { globalStore }, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
16644
- Refine,
16645
- {
16646
- dataProvider: {
16647
- default: dataProvider(globalStore)
16648
- },
16649
- routerProvider,
16650
- liveProvider: liveProvider(globalStore),
16651
- options: {
16652
- warnWhenUnsavedChanges: true,
16653
- liveMode: "auto"
16654
- },
16655
- resources: resourcesConfig.map((c) => {
16656
- return {
16657
- name: c.name,
16658
- meta: {
16659
- resourceBasePath: c.basePath,
16660
- kind: c.kind,
16661
- parent: c.parent,
16662
- label: `${c.kind}s`
16663
- },
16664
- list: `${urlPrefix}/${c.name}`,
16665
- show: `${urlPrefix}/${c.name}/show`,
16666
- create: `${urlPrefix}/${c.name}/create`,
16667
- edit: `${urlPrefix}/${c.name}/edit`
16668
- };
16669
- }),
16670
- children: content
16671
- }
16672
- ) }) });
16673
- };
16674
- var RESOURCE_GROUP = /* @__PURE__ */ ((RESOURCE_GROUP2) => {
16675
- RESOURCE_GROUP2["WORKLOAD"] = "WORKLOAD";
16676
- RESOURCE_GROUP2["STORAGE"] = "STORAGE";
16677
- RESOURCE_GROUP2["NETWORK"] = "NETWORK";
16678
- RESOURCE_GROUP2["CLUSTER"] = "CLUSTER";
16679
- return RESOURCE_GROUP2;
16680
- })(RESOURCE_GROUP || {});
16681
16691
  export {
16682
16692
  ConditionsField as $,
16683
16693
  AgeColumnRenderer as A,
@@ -16718,12 +16728,15 @@ export {
16718
16728
  SessionAffinityField as a7,
16719
16729
  ServicePodsField as a8,
16720
16730
  ShowContent as a9,
16721
- WorkloadModel as aA,
16722
- WorkloadBaseModel as aB,
16723
- PodModel as aC,
16724
- PodMetricsModel as aD,
16725
- ResourceModel as aE,
16726
- CronJobModel as aF,
16731
+ JobModel as aA,
16732
+ WorkloadModel as aB,
16733
+ WorkloadBaseModel as aC,
16734
+ PodModel as aD,
16735
+ PodMetricsModel as aE,
16736
+ ResourceModel as aF,
16737
+ CronJobModel as aG,
16738
+ EventModel as aH,
16739
+ ProviderPlugins as aI,
16727
16740
  SchemaStrategy as aa,
16728
16741
  DeleteManyButton as ab,
16729
16742
  ListPage as ac,
@@ -16749,7 +16762,7 @@ export {
16749
16762
  Dovetail as aw,
16750
16763
  RESOURCE_GROUP as ax,
16751
16764
  ComponentContext as ay,
16752
- JobModel as az,
16765
+ GlobalStoreContext as az,
16753
16766
  NameSpaceColumnRenderer as b,
16754
16767
  WorkloadRestartsColumnRenderer as c,
16755
16768
  NodeNameColumnRenderer as d,
package/dist/refine.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ai, A, an, B, ap, a6, g, C, f, ay, $, v, y, J, aF, Q, aq, ao, a2, V, ab, aw, ae, D, ag, Z, I, ar, az, a1, T, K, X, ac, af, M, ah, N, m, b, q, ak, d, at, t, P, w, am, aD, aC, a0, ax, _, R, G, F, z, aE, E, L, e, au, as, aa, a3, U, a8, S, a5, a7, a9, a4, ad, av, al, aB, x, W, aA, H, O, c, Y, n, s, p, o, r, a, i, h, k, l, aj, u } from "./index.e31fb37e.js";
1
+ import { ai, A, an, B, ap, a6, g, C, f, ay, $, v, y, J, aG, Q, aq, ao, a2, V, ab, aw, ae, D, ag, aH, az, Z, I, ar, aA, a1, T, K, X, ac, af, M, ah, N, m, b, q, ak, d, at, t, P, w, am, aE, aD, a0, aI, ax, _, R, G, F, z, aF, E, L, e, au, as, aa, a3, U, a8, S, a5, a7, a9, a4, ad, av, al, aC, x, W, aB, H, O, c, Y, n, s, p, o, r, a, i, h, k, l, aj, u } from "./index.6a36859b.js";
2
2
  import "@cloudtower/eagle";
3
3
  import "@refinedev/core";
4
4
  import "js-yaml";
@@ -29,7 +29,7 @@ export {
29
29
  v as ConditionsTable,
30
30
  y as CreateButton,
31
31
  J as CronJobDropdown,
32
- aF as CronJobModel,
32
+ aG as CronJobModel,
33
33
  Q as CronjobJobsTable,
34
34
  aq as DAEMONSET_INIT_VALUE,
35
35
  ao as DEPLOYMENT_INIT_VALUE,
@@ -40,10 +40,12 @@ export {
40
40
  ae as DrawerShow,
41
41
  D as DurationColumnRenderer,
42
42
  ag as EditButton,
43
+ aH as EventModel,
44
+ az as GlobalStoreContext,
43
45
  Z as ImageField,
44
46
  I as ImageNames,
45
47
  ar as JOB_INIT_VALUE,
46
- az as JobModel,
48
+ aA as JobModel,
47
49
  a1 as JobsField,
48
50
  T as KeyValue,
49
51
  K as KeyValueListWidget,
@@ -63,16 +65,17 @@ export {
63
65
  P as PhaseColumnRenderer,
64
66
  w as PodContainersTable,
65
67
  am as PodLog,
66
- aD as PodMetricsModel,
67
- aC as PodModel,
68
+ aE as PodMetricsModel,
69
+ aD as PodModel,
68
70
  a0 as PodsField,
71
+ aI as ProviderPlugins,
69
72
  ax as RESOURCE_GROUP,
70
73
  _ as ReplicaField,
71
74
  R as ReplicasColumnRenderer,
72
75
  G as ResourceCRUD,
73
76
  F as ResourceForm,
74
77
  z as ResourceList,
75
- aE as ResourceModel,
78
+ aF as ResourceModel,
76
79
  E as ResourceShow,
77
80
  L as ResourceUsageBar,
78
81
  e as RestartCountColumnRenderer,
@@ -90,10 +93,10 @@ export {
90
93
  ad as StateTag,
91
94
  av as TIMESTAMP_LABEL,
92
95
  al as Tags,
93
- aB as WorkloadBaseModel,
96
+ aC as WorkloadBaseModel,
94
97
  x as WorkloadDropdown,
95
98
  W as WorkloadImageColumnRenderer,
96
- aA as WorkloadModel,
99
+ aB as WorkloadModel,
97
100
  H as WorkloadPodsTable,
98
101
  O as WorkloadReplicas,
99
102
  c as WorkloadRestartsColumnRenderer,