@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.
@@ -5,8 +5,8 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  (function(global2, factory) {
8
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@refinedev/core"), require("qs"), require("react"), require("react-router-dom"), require("@cloudtower/eagle"), require("js-yaml"), require("lodash-es"), require("sunflower-antd"), require("i18next"), require("@cloudtower/icons-react"), require("monaco-editor"), require("monaco-yaml"), require("react-dom"), require("antd"), require("k8s-api-provider")) : typeof define === "function" && define.amd ? define(["exports", "@refinedev/core", "qs", "react", "react-router-dom", "@cloudtower/eagle", "js-yaml", "lodash-es", "sunflower-antd", "i18next", "@cloudtower/icons-react", "monaco-editor", "monaco-yaml", "react-dom", "antd", "k8s-api-provider"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.dovetail = {}, global2.core, global2.qs, global2.React, global2.reactRouterDom, global2.eagle, global2.yaml, global2.lodashEs, global2.sunflowerAntd, global2.i18n, global2.iconsReact, global2.monaco, global2.monacoYaml, global2.ReactDOM, global2.antd$1, global2.k8sApiProvider));
9
- })(this, function(exports2, core, qs, React, reactRouterDom, eagle, yaml, lodashEs, sunflowerAntd, i18n, iconsReact, monaco, monacoYaml, ReactDOM, antd$1, k8sApiProvider) {
8
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@refinedev/core"), require("qs"), require("react"), require("react-router-dom"), require("@cloudtower/eagle"), require("js-yaml"), require("lodash-es"), require("sunflower-antd"), require("i18next"), require("@cloudtower/icons-react"), require("monaco-editor"), require("monaco-yaml"), require("react-dom"), require("antd"), require("k8s-api-provider")) : typeof define === "function" && define.amd ? define(["exports", "@refinedev/core", "qs", "react", "react-router-dom", "@cloudtower/eagle", "js-yaml", "lodash-es", "sunflower-antd", "i18next", "@cloudtower/icons-react", "monaco-editor", "monaco-yaml", "react-dom", "antd", "k8s-api-provider"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.dovetail = {}, global2.core, global2.qs, global2.React, global2.reactRouterDom, global2.eagle, global2.yaml, global2.lodashEs, global2.sunflowerAntd, global2.i18n, global2.iconsReact, global2.monaco, global2.monacoYaml, global2.ReactDOM, global2.antd, global2.k8sApiProvider));
9
+ })(this, function(exports2, core, qs, React, reactRouterDom, eagle, yaml, lodashEs, sunflowerAntd, i18n, iconsReact, monaco, monacoYaml, ReactDOM, antd, k8sApiProvider) {
10
10
  "use strict";
11
11
  const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
12
12
  function _interopNamespace(e) {
@@ -6870,14 +6870,18 @@ var __publicField = (obj, key, value) => {
6870
6870
  const warnWhenUnsavedChanges = warnWhenUnsavedChangesProp != null ? warnWhenUnsavedChangesProp : warnWhenUnsavedChangesRefine;
6871
6871
  React__default.default.useEffect(() => {
6872
6872
  var _a2;
6873
+ form.resetFields();
6873
6874
  if (editor.current) {
6875
+ const editorValue = yaml__default.default.dump(form.getFieldsValue(true));
6874
6876
  const editorInstance = editor.current.getEditorInstance();
6877
+ editor.current.setEditorValue(editorValue);
6878
+ editor.current.setValue(editorValue);
6875
6879
  if (((_a2 = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a2.data) && editorInstance && !isFoldRef.current) {
6876
6880
  fold(editorInstance);
6877
6881
  isFoldRef.current = true;
6878
6882
  }
6879
6883
  }
6880
- }, [(_a = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a.data, id, fold]);
6884
+ }, [(_a = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a.data, id, form, fold]);
6881
6885
  React__default.default.useEffect(() => {
6882
6886
  var _a2, _b2;
6883
6887
  const response = (_a2 = useFormCoreResult.mutationResult.error) == null ? void 0 : _a2.response;
@@ -7411,7 +7415,7 @@ var __publicField = (obj, key, value) => {
7411
7415
  const currentReplicas = lodashEs.get(record, "spec.replicas", 0);
7412
7416
  const scale = (delta) => {
7413
7417
  const v = record.scale(currentReplicas + delta);
7414
- const id = v.id;
7418
+ const id = record.id;
7415
7419
  pruneBeforeEdit(v);
7416
7420
  mutate({
7417
7421
  id,
@@ -8500,23 +8504,23 @@ var __publicField = (obj, key, value) => {
8500
8504
  filteredProps.className = options.atomic ? cx_default(options.class, filteredProps.className || className) : cx_default(filteredProps.className || className, options.class);
8501
8505
  const { vars } = options;
8502
8506
  if (vars) {
8503
- const style2 = {};
8507
+ const style = {};
8504
8508
  for (const name2 in vars) {
8505
8509
  const variable = vars[name2];
8506
8510
  const result = variable[0];
8507
8511
  const unit = variable[1] || "";
8508
8512
  const value = typeof result === "function" ? result(props) : result;
8509
8513
  warnIfInvalid(value, options.name);
8510
- style2[`--${name2}`] = `${value}${unit}`;
8514
+ style[`--${name2}`] = `${value}${unit}`;
8511
8515
  }
8512
8516
  const ownStyle = filteredProps.style || {};
8513
8517
  const keys = Object.keys(ownStyle);
8514
8518
  if (keys.length > 0) {
8515
8519
  keys.forEach((key) => {
8516
- style2[key] = ownStyle[key];
8520
+ style[key] = ownStyle[key];
8517
8521
  });
8518
8522
  }
8519
- filteredProps.style = style2;
8523
+ filteredProps.style = style;
8520
8524
  }
8521
8525
  if (tag.__linaria && tag !== component) {
8522
8526
  filteredProps.as = component;
@@ -9213,13 +9217,12 @@ var __publicField = (obj, key, value) => {
9213
9217
  ],
9214
9218
  [i18n2]
9215
9219
  );
9216
- const dataSource = React.useMemo(
9217
- () => addId((data2 == null ? void 0 : data2.data) || [], "metadata.uid").filter((d) => {
9220
+ const dataSource = React.useMemo(() => {
9221
+ return data2 == null ? void 0 : data2.data.filter((d) => {
9218
9222
  const objectId = `${d.regarding.namespace}/${d.regarding.name}`;
9219
9223
  return objectId === parsed.id;
9220
- }),
9221
- [data2 == null ? void 0 : data2.data, parsed]
9222
- );
9224
+ });
9225
+ }, [data2 == null ? void 0 : data2.data, parsed]);
9223
9226
  return /* @__PURE__ */ jsxRuntime.exports.jsx(
9224
9227
  Table,
9225
9228
  {
@@ -10173,7 +10176,8 @@ var __publicField = (obj, key, value) => {
10173
10176
  } = useEagleForm({
10174
10177
  editorOptions: {
10175
10178
  isSkipSchema: schemaStrategy === "None"
10176
- }
10179
+ },
10180
+ liveMode: "off"
10177
10181
  });
10178
10182
  const kit = eagle.useUIKit();
10179
10183
  const {
@@ -10521,7 +10525,7 @@ var __publicField = (obj, key, value) => {
10521
10525
  const { queryResult } = core.useShow({ id: (_a = parsed == null ? void 0 : parsed.params) == null ? void 0 : _a.id });
10522
10526
  const { isLoading } = queryResult;
10523
10527
  return /* @__PURE__ */ jsxRuntime.exports.jsx(
10524
- antd$1.Drawer,
10528
+ antd.Drawer,
10525
10529
  {
10526
10530
  title: "Show Drawer",
10527
10531
  placement: "right",
@@ -14911,7 +14915,7 @@ var __publicField = (obj, key, value) => {
14911
14915
  return "'";
14912
14916
  }
14913
14917
  });
14914
- const LogViewerRow = React.memo(({ index, style: style2, data: data2, ansiUp }) => {
14918
+ const LogViewerRow = React.memo(({ index, style, data: data2, ansiUp }) => {
14915
14919
  const { parsedData, searchedWordIndexes, rowInFocus } = data2;
14916
14920
  const context = React.useContext(LogViewerContext);
14917
14921
  const getData = (index2) => parsedData ? parsedData[index2] : null;
@@ -14955,7 +14959,7 @@ var __publicField = (obj, key, value) => {
14955
14959
  };
14956
14960
  return React__default.default.createElement(
14957
14961
  "div",
14958
- { style: style2, className: css(styles$1.logViewerListItem) },
14962
+ { style, className: css(styles$1.logViewerListItem) },
14959
14963
  React__default.default.createElement("span", { className: css(styles$1.logViewerIndex) }, getRowIndex(index)),
14960
14964
  React__default.default.createElement("span", { className: css(styles$1.logViewerText), style: { width: "fit-content" }, dangerouslySetInnerHTML: { __html: ansiUp.ansi_to_html(getFormattedData()) } })
14961
14965
  );
@@ -15083,19 +15087,19 @@ var __publicField = (obj, key, value) => {
15083
15087
  this._getItemStyle = (index) => {
15084
15088
  const { itemSize } = this.props;
15085
15089
  const itemStyleCache = this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && itemSize);
15086
- let style2;
15090
+ let style;
15087
15091
  if (itemStyleCache.hasOwnProperty(index)) {
15088
- style2 = itemStyleCache[index];
15092
+ style = itemStyleCache[index];
15089
15093
  } else {
15090
15094
  const offset = getItemOffset(this.props, index, this._instanceProps);
15091
15095
  const size = getItemSize(this.props, index, this._instanceProps);
15092
- itemStyleCache[index] = style2 = {
15096
+ itemStyleCache[index] = style = {
15093
15097
  position: "absolute",
15094
15098
  top: offset,
15095
15099
  height: size
15096
15100
  };
15097
15101
  }
15098
- return style2;
15102
+ return style;
15099
15103
  };
15100
15104
  this._getItemStyleCache = memoizeOne(() => ({}));
15101
15105
  this._onScrollVertical = (event2) => {
@@ -15212,7 +15216,7 @@ var __publicField = (obj, key, value) => {
15212
15216
  });
15213
15217
  }
15214
15218
  render() {
15215
- const { children, outerClassName, innerClassName, height, innerRef, innerElementType, innerTagName, itemCount, itemData, itemKey = defaultItemKey, outerElementType, outerTagName, style: style2, useIsScrolling, width, isTextWrapped, hasLineNumbers, indexWidth, ansiUp } = this.props;
15219
+ const { children, outerClassName, innerClassName, height, innerRef, innerElementType, innerTagName, itemCount, itemData, itemKey = defaultItemKey, outerElementType, outerTagName, style, useIsScrolling, width, isTextWrapped, hasLineNumbers, indexWidth, ansiUp } = this.props;
15216
15220
  const { isScrolling } = this.state;
15217
15221
  const onScroll = this._onScrollVertical;
15218
15222
  const [startIndex, stopIndex] = this._getRangeToRender();
@@ -15235,7 +15239,7 @@ var __publicField = (obj, key, value) => {
15235
15239
  onScroll,
15236
15240
  ref: this._outerRefSetter,
15237
15241
  tabIndex: 0,
15238
- style: Object.assign({ height, paddingTop: 0, paddingBottom: 0, WebkitOverflowScrolling: "touch", overflowX: isTextWrapped ? "hidden" : "auto" }, style2)
15242
+ style: Object.assign({ height, paddingTop: 0, paddingBottom: 0, WebkitOverflowScrolling: "touch", overflowX: isTextWrapped ? "hidden" : "auto" }, style)
15239
15243
  }, React.createElement(innerElementType || innerTagName || "div", {
15240
15244
  className: innerClassName,
15241
15245
  ref: innerRef,
@@ -16205,6 +16209,60 @@ var __publicField = (obj, key, value) => {
16205
16209
  })]
16206
16210
  });
16207
16211
  };
16212
+ const styles = "";
16213
+ const Dovetail = (props) => {
16214
+ const { resourcesConfig, urlPrefix = "", Layout: Layout2, history, globalStore } = props;
16215
+ const notCustomResources = React.useMemo(() => {
16216
+ return resourcesConfig.filter((c) => !c.isCustom);
16217
+ }, [resourcesConfig]);
16218
+ const content = React.useMemo(() => {
16219
+ const _content = /* @__PURE__ */ jsxRuntime.exports.jsxs(jsxRuntime.exports.Fragment, { children: [
16220
+ /* @__PURE__ */ jsxRuntime.exports.jsx(ResourceCRUD, { configs: notCustomResources, urlPrefix }),
16221
+ props.children
16222
+ ] });
16223
+ if (Layout2) {
16224
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(Layout2, { children: _content });
16225
+ }
16226
+ return _content;
16227
+ }, [Layout2, notCustomResources, props.children, urlPrefix]);
16228
+ return /* @__PURE__ */ jsxRuntime.exports.jsx(reactRouterDom.Router, { history, children: /* @__PURE__ */ jsxRuntime.exports.jsx(GlobalStoreContext.Provider, { value: { globalStore }, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
16229
+ core.Refine,
16230
+ {
16231
+ dataProvider: {
16232
+ default: k8sApiProvider.dataProvider(globalStore)
16233
+ },
16234
+ routerProvider,
16235
+ liveProvider: k8sApiProvider.liveProvider(globalStore),
16236
+ options: {
16237
+ warnWhenUnsavedChanges: true,
16238
+ liveMode: "auto"
16239
+ },
16240
+ resources: resourcesConfig.map((c) => {
16241
+ return {
16242
+ name: c.name,
16243
+ meta: {
16244
+ resourceBasePath: c.basePath,
16245
+ kind: c.kind,
16246
+ parent: c.parent,
16247
+ label: `${c.kind}s`
16248
+ },
16249
+ list: `${urlPrefix}/${c.name}`,
16250
+ show: `${urlPrefix}/${c.name}/show`,
16251
+ create: `${urlPrefix}/${c.name}/create`,
16252
+ edit: `${urlPrefix}/${c.name}/edit`
16253
+ };
16254
+ }),
16255
+ children: content
16256
+ }
16257
+ ) }) });
16258
+ };
16259
+ var RESOURCE_GROUP = /* @__PURE__ */ ((RESOURCE_GROUP2) => {
16260
+ RESOURCE_GROUP2["WORKLOAD"] = "WORKLOAD";
16261
+ RESOURCE_GROUP2["STORAGE"] = "STORAGE";
16262
+ RESOURCE_GROUP2["NETWORK"] = "NETWORK";
16263
+ RESOURCE_GROUP2["CLUSTER"] = "CLUSTER";
16264
+ return RESOURCE_GROUP2;
16265
+ })(RESOURCE_GROUP || {});
16208
16266
  function getSecondsDiff(startDate, endDate) {
16209
16267
  return Math.round(Math.abs(Date.parse(endDate) - Date.parse(startDate)) / 1e3);
16210
16268
  }
@@ -16362,7 +16420,8 @@ var __publicField = (obj, key, value) => {
16362
16420
  this.restarts = result;
16363
16421
  }
16364
16422
  redeploy() {
16365
- const newOne = lodash.exports.cloneDeep(this._rawYaml);
16423
+ const rawYaml = this._globalStore.restoreItem(this);
16424
+ const newOne = lodash.exports.cloneDeep(rawYaml);
16366
16425
  const path = "spec.template.metadata.annotations";
16367
16426
  const annotations = lodash.exports.get(newOne, path, {});
16368
16427
  lodash.exports.set(newOne, path, {
@@ -16372,7 +16431,8 @@ var __publicField = (obj, key, value) => {
16372
16431
  return newOne;
16373
16432
  }
16374
16433
  scale(value) {
16375
- const newOne = lodash.exports.cloneDeep(this._rawYaml);
16434
+ const rawYaml = this._globalStore.restoreItem(this);
16435
+ const newOne = lodash.exports.cloneDeep(rawYaml);
16376
16436
  if (newOne.kind === "Deployment" || newOne.kind === "StatefulSet") {
16377
16437
  lodash.exports.set(newOne, "spec.replicas", value);
16378
16438
  }
@@ -16503,13 +16563,22 @@ var __publicField = (obj, key, value) => {
16503
16563
  return newOne;
16504
16564
  }
16505
16565
  }
16566
+ class EventModel extends ResourceModel {
16567
+ constructor(_rawYaml, _globalStore) {
16568
+ super(_rawYaml, _globalStore);
16569
+ this._rawYaml = _rawYaml;
16570
+ this._globalStore = _globalStore;
16571
+ this.id = _rawYaml.metadata.uid || _rawYaml.id;
16572
+ }
16573
+ }
16506
16574
  const ModelMap = {
16507
16575
  Deployment: WorkloadModel,
16508
16576
  DaemonSet: WorkloadModel,
16509
16577
  StatefulSet: WorkloadModel,
16510
16578
  CronJob: CronJobModel,
16511
16579
  Job: JobModel,
16512
- Pod: PodModel
16580
+ Pod: PodModel,
16581
+ Event: EventModel
16513
16582
  };
16514
16583
  class ModelPlugin {
16515
16584
  constructor() {
@@ -16632,65 +16701,6 @@ var __publicField = (obj, key, value) => {
16632
16701
  }
16633
16702
  const relationPlugin = new RelationPlugin();
16634
16703
  const ProviderPlugins = [relationPlugin, modelPlugin];
16635
- const styles = "";
16636
- const antd = "";
16637
- const style = "";
16638
- const Dovetail = (props) => {
16639
- const { resourcesConfig, urlPrefix = "", Layout: Layout2, history, globalStoreParams } = props;
16640
- const globalStore = React.useMemo(() => {
16641
- return new k8sApiProvider.GlobalStore(globalStoreParams, ProviderPlugins);
16642
- }, [globalStoreParams]);
16643
- const notCustomResources = React.useMemo(() => {
16644
- return resourcesConfig.filter((c) => !c.isCustom);
16645
- }, [resourcesConfig]);
16646
- const content = React.useMemo(() => {
16647
- const _content = /* @__PURE__ */ jsxRuntime.exports.jsxs(jsxRuntime.exports.Fragment, { children: [
16648
- /* @__PURE__ */ jsxRuntime.exports.jsx(ResourceCRUD, { configs: notCustomResources, urlPrefix }),
16649
- props.children
16650
- ] });
16651
- if (Layout2) {
16652
- return /* @__PURE__ */ jsxRuntime.exports.jsx(Layout2, { children: _content });
16653
- }
16654
- return _content;
16655
- }, [Layout2, notCustomResources, props.children, urlPrefix]);
16656
- return /* @__PURE__ */ jsxRuntime.exports.jsx(reactRouterDom.Router, { history, children: /* @__PURE__ */ jsxRuntime.exports.jsx(GlobalStoreContext.Provider, { value: { globalStore }, children: /* @__PURE__ */ jsxRuntime.exports.jsx(
16657
- core.Refine,
16658
- {
16659
- dataProvider: {
16660
- default: k8sApiProvider.dataProvider(globalStore)
16661
- },
16662
- routerProvider,
16663
- liveProvider: k8sApiProvider.liveProvider(globalStore),
16664
- options: {
16665
- warnWhenUnsavedChanges: true,
16666
- liveMode: "auto"
16667
- },
16668
- resources: resourcesConfig.map((c) => {
16669
- return {
16670
- name: c.name,
16671
- meta: {
16672
- resourceBasePath: c.basePath,
16673
- kind: c.kind,
16674
- parent: c.parent,
16675
- label: `${c.kind}s`
16676
- },
16677
- list: `${urlPrefix}/${c.name}`,
16678
- show: `${urlPrefix}/${c.name}/show`,
16679
- create: `${urlPrefix}/${c.name}/create`,
16680
- edit: `${urlPrefix}/${c.name}/edit`
16681
- };
16682
- }),
16683
- children: content
16684
- }
16685
- ) }) });
16686
- };
16687
- var RESOURCE_GROUP = /* @__PURE__ */ ((RESOURCE_GROUP2) => {
16688
- RESOURCE_GROUP2["WORKLOAD"] = "WORKLOAD";
16689
- RESOURCE_GROUP2["STORAGE"] = "STORAGE";
16690
- RESOURCE_GROUP2["NETWORK"] = "NETWORK";
16691
- RESOURCE_GROUP2["CLUSTER"] = "CLUSTER";
16692
- return RESOURCE_GROUP2;
16693
- })(RESOURCE_GROUP || {});
16694
16704
  const MonacoYamlDiffEditor = (props) => {
16695
16705
  const ref = React.useRef(null);
16696
16706
  const { origin, modified, id, height } = props;
@@ -16756,6 +16766,8 @@ var __publicField = (obj, key, value) => {
16756
16766
  exports2.DrawerShow = DrawerShow;
16757
16767
  exports2.DurationColumnRenderer = DurationColumnRenderer;
16758
16768
  exports2.EditButton = EditButton;
16769
+ exports2.EventModel = EventModel;
16770
+ exports2.GlobalStoreContext = GlobalStoreContext;
16759
16771
  exports2.ImageField = ImageField;
16760
16772
  exports2.ImageNames = ImageNames;
16761
16773
  exports2.JOB_INIT_VALUE = JOB_INIT_VALUE;
@@ -16782,6 +16794,7 @@ var __publicField = (obj, key, value) => {
16782
16794
  exports2.PodMetricsModel = PodMetricsModel;
16783
16795
  exports2.PodModel = PodModel;
16784
16796
  exports2.PodsField = PodsField;
16797
+ exports2.ProviderPlugins = ProviderPlugins;
16785
16798
  exports2.RESOURCE_GROUP = RESOURCE_GROUP;
16786
16799
  exports2.ReplicaField = ReplicaField;
16787
16800
  exports2.ReplicasColumnRenderer = ReplicasColumnRenderer;