@dovetail-v2/refine 0.1.16 → 0.1.17-alpha.1

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 jsxRuntimeExports } from "./index-c5295550.js";
1
+ import { j as jsxRuntimeExports } from "./index-66b29f4e.js";
2
2
  import * as monaco from "monaco-editor";
3
3
  import { useRef, useEffect } from "react";
4
4
  import "i18next";
@@ -9650,11 +9650,17 @@ class ResourceModel {
9650
9650
  }
9651
9651
  updateLabel(labels) {
9652
9652
  const newYaml = this._globalStore.restoreItem(this);
9653
+ if (!newYaml.metadata) {
9654
+ newYaml.metadata = {};
9655
+ }
9653
9656
  newYaml.metadata.labels = labels;
9654
9657
  return newYaml;
9655
9658
  }
9656
9659
  updateAnnotation(annotations) {
9657
9660
  const newYaml = this._globalStore.restoreItem(this);
9661
+ if (!newYaml.metadata) {
9662
+ newYaml.metadata = {};
9663
+ }
9658
9664
  newYaml.metadata.annotations = annotations;
9659
9665
  return newYaml;
9660
9666
  }
@@ -10703,15 +10709,16 @@ class NodeModel extends ResourceModel {
10703
10709
  this._rawYaml = _rawYaml;
10704
10710
  }
10705
10711
  get role() {
10706
- return "node-role.kubernetes.io/control-plane" in (this.metadata.labels || {}) ? "Control Plane" : "Worker";
10712
+ var _a;
10713
+ return "node-role.kubernetes.io/control-plane" in (((_a = this.metadata) == null ? void 0 : _a.labels) || {}) ? "Control Plane" : "Worker";
10707
10714
  }
10708
10715
  get ip() {
10709
10716
  var _a, _b;
10710
10717
  return (_b = (_a = this._rawYaml.status.addresses) == null ? void 0 : _a.find((add) => add.type === "InternalIP")) == null ? void 0 : _b.address;
10711
10718
  }
10712
10719
  get nodeGroupName() {
10713
- var _a;
10714
- return (_a = this.metadata.labels) == null ? void 0 : _a["cape.infrastructure.cluster.x-k8s.io/node-group"];
10720
+ var _a, _b;
10721
+ return (_b = (_a = this.metadata) == null ? void 0 : _a.labels) == null ? void 0 : _b["cape.infrastructure.cluster.x-k8s.io/node-group"];
10715
10722
  }
10716
10723
  get isControlPlane() {
10717
10724
  var _a;
@@ -10732,7 +10739,10 @@ class StorageClassModel extends ResourceModel {
10732
10739
  kind: "PersistentVolume"
10733
10740
  });
10734
10741
  this.pvs = pvs.items.filter(
10735
- (pv2) => this.filterPV(pv2, this.metadata.name)
10742
+ (pv2) => {
10743
+ var _a;
10744
+ return this.filterPV(pv2, (_a = this.metadata) == null ? void 0 : _a.name);
10745
+ }
10736
10746
  );
10737
10747
  }
10738
10748
  filterPV(pv2, scName) {
@@ -11177,6 +11187,7 @@ var RESOURCE_GROUP = /* @__PURE__ */ ((RESOURCE_GROUP2) => {
11177
11187
  RESOURCE_GROUP2["SERVICE_AND_NETWORK"] = "SERVICE_AND_NETWORK";
11178
11188
  RESOURCE_GROUP2["CONFIG"] = "CONFIG";
11179
11189
  RESOURCE_GROUP2["NODE_MANAGEMENT"] = "NODE_MANAGEMENT";
11190
+ RESOURCE_GROUP2["PROJECT"] = "PROJECT";
11180
11191
  return RESOURCE_GROUP2;
11181
11192
  })(RESOURCE_GROUP || {});
11182
11193
  var FormType = /* @__PURE__ */ ((FormType2) => {
@@ -11200,20 +11211,20 @@ function useOpenForm(options) {
11200
11211
  const pushModal = usePushModal();
11201
11212
  const go = useGo();
11202
11213
  return function openForm() {
11203
- var _a, _b;
11214
+ var _a, _b, _c;
11204
11215
  if (resource == null ? void 0 : resource.name) {
11205
11216
  const config = configs[resource.name];
11206
11217
  const formType = (_a = config.formConfig) == null ? void 0 : _a.formType;
11207
11218
  if (formType === void 0 || formType === FormType.MODAL) {
11208
11219
  pushModal({
11209
- component: FormModal,
11220
+ component: ((_b = config.formConfig) == null ? void 0 : _b.CustomFormModal) || FormModal,
11210
11221
  props: {
11211
11222
  resource: resource.name,
11212
11223
  id: options == null ? void 0 : options.id,
11213
11224
  formProps: {
11214
11225
  initialValues: getInitialValues(config)
11215
11226
  },
11216
- renderForm: (options == null ? void 0 : options.renderForm) || ((_b = config.formConfig) == null ? void 0 : _b.renderForm)
11227
+ renderForm: (options == null ? void 0 : options.renderForm) || ((_c = config.formConfig) == null ? void 0 : _c.renderForm)
11217
11228
  }
11218
11229
  });
11219
11230
  } else if (options == null ? void 0 : options.id) {
@@ -11908,7 +11919,12 @@ function Tabs(props) {
11908
11919
  }) });
11909
11920
  }
11910
11921
  const StateTag = (props) => {
11911
- const { state: state2 = ResourceState.UPDATING, hideBackground, className, resourceKind } = props;
11922
+ const {
11923
+ state: state2 = ResourceState.UPDATING,
11924
+ hideBackground,
11925
+ className,
11926
+ customResourceStateMap
11927
+ } = props;
11912
11928
  const { t: t2 } = useTranslation();
11913
11929
  const defaultStateMap = {
11914
11930
  [ResourceState.UPDATING]: "loading",
@@ -11929,19 +11945,19 @@ const StateTag = (props) => {
11929
11945
  [ResourceState.RELEASED]: "gray",
11930
11946
  [ResourceState.LOST]: "red"
11931
11947
  };
11932
- const resourceStateMap = {};
11933
- const finalStateMap = resourceStateMap[resourceKind || ""] || defaultStateMap;
11948
+ const finalColorMap = (customResourceStateMap == null ? void 0 : customResourceStateMap.color) || defaultStateMap;
11949
+ const finalTextMap = customResourceStateMap == null ? void 0 : customResourceStateMap.text;
11934
11950
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
11935
11951
  StatusCapsule,
11936
11952
  {
11937
11953
  className: cx_default(className, StateTagStyle, hideBackground && "no-background"),
11938
- color: finalStateMap[state2] !== "loading" ? finalStateMap[state2] : void 0,
11939
- loading: finalStateMap[state2] === "loading",
11940
- children: t2(`dovetail.${state2 || "updating"}_state`)
11954
+ color: finalColorMap[state2] !== "loading" ? finalColorMap[state2] : void 0,
11955
+ loading: finalColorMap[state2] === "loading",
11956
+ children: finalTextMap ? finalTextMap[state2] : t2(`dovetail.${state2 || "updating"}_state`)
11941
11957
  }
11942
11958
  );
11943
11959
  };
11944
- const ShowContent_ua3los = "";
11960
+ const ShowContent_1g0ejph = "";
11945
11961
  const ShowContentWrapperStyle = "s9agep2";
11946
11962
  const BackButton = "bo89gfi";
11947
11963
  const ToolBarWrapper = "t1ohe42f";
@@ -11973,7 +11989,7 @@ function ShowGroupComponent(props) {
11973
11989
  });
11974
11990
  }
11975
11991
  const ShowContent = (props) => {
11976
- var _a, _b, _c, _d, _e, _f;
11992
+ var _a, _b, _c, _d, _e;
11977
11993
  const {
11978
11994
  showConfig,
11979
11995
  formatter,
@@ -12089,10 +12105,10 @@ const ShowContent = (props) => {
12089
12105
  children: (_c = record == null ? void 0 : record.metadata) == null ? void 0 : _c.name
12090
12106
  }), stateDisplay ? /* @__PURE__ */ jsxRuntimeExports.jsx(StateTag, {
12091
12107
  state: stateDisplay,
12092
- resourceKind: (_d = resource == null ? void 0 : resource.meta) == null ? void 0 : _d.kind
12108
+ customResourceStateMap: showConfig.resourceStateMap
12093
12109
  }) : void 0]
12094
12110
  }), /* @__PURE__ */ jsxRuntimeExports.jsxs(Space, {
12095
- children: [(_e = showConfig.renderExtraButton) == null ? void 0 : _e.call(showConfig, record), !config.hideEdit ? /* @__PURE__ */ jsxRuntimeExports.jsx(CanAccess, {
12111
+ children: [(_d = showConfig.renderExtraButton) == null ? void 0 : _d.call(showConfig, record), !config.hideEdit ? /* @__PURE__ */ jsxRuntimeExports.jsx(CanAccess, {
12096
12112
  resource: resource == null ? void 0 : resource.name,
12097
12113
  action: AccessControlAuth.Edit,
12098
12114
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, {
@@ -12100,7 +12116,7 @@ const ShowContent = (props) => {
12100
12116
  marginRight: 8
12101
12117
  },
12102
12118
  onClick: openForm,
12103
- children: ((_f = config.formConfig) == null ? void 0 : _f.fields) ? t2("dovetail.edit") : t2("dovetail.edit_yaml")
12119
+ children: ((_e = config.formConfig) == null ? void 0 : _e.fields) ? t2("dovetail.edit") : t2("dovetail.edit_yaml")
12104
12120
  })
12105
12121
  }) : null, /* @__PURE__ */ jsxRuntimeExports.jsx(Dropdown2, {
12106
12122
  record,
@@ -12441,10 +12457,11 @@ const EditNodeTaintForm = React__default.forwardRef(function EditNodeTaintForm2(
12441
12457
  kind: nodeModel.kind
12442
12458
  },
12443
12459
  successNotification() {
12460
+ var _a;
12444
12461
  return {
12445
12462
  message: t2("dovetail.edit_node_taint_success_toast", {
12446
12463
  kind: nodeModel.kind,
12447
- name: nodeModel.metadata.name,
12464
+ name: (_a = nodeModel.metadata) == null ? void 0 : _a.name,
12448
12465
  interpolation: {
12449
12466
  escapeValue: false
12450
12467
  }
@@ -13097,14 +13114,14 @@ const ServicePodsField = () => {
13097
13114
  key: "pods",
13098
13115
  path: [],
13099
13116
  renderContent: (_, record) => {
13100
- var _a, _b;
13117
+ var _a, _b, _c;
13101
13118
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
13102
13119
  WorkloadPodsTable,
13103
13120
  {
13104
13121
  selector: (_b = (_a = record.metadata.relations) == null ? void 0 : _a.find((r2) => {
13105
13122
  return r2.kind === "Pod" && r2.type === "selects";
13106
13123
  })) == null ? void 0 : _b.selector,
13107
- namespace: record.metadata.namespace,
13124
+ namespace: (_c = record.metadata) == null ? void 0 : _c.namespace,
13108
13125
  hideToolbar: true
13109
13126
  }
13110
13127
  );
@@ -13125,7 +13142,8 @@ const EventsTableTabField = () => {
13125
13142
  key: "event",
13126
13143
  path: [],
13127
13144
  renderContent: (_, record) => {
13128
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { padding: "0 24px", height: "100%" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(EventsTable, { uid: record.metadata.uid }) });
13145
+ var _a;
13146
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { padding: "0 24px", height: "100%" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(EventsTable, { uid: (_a = record.metadata) == null ? void 0 : _a.uid }) });
13129
13147
  }
13130
13148
  };
13131
13149
  };
@@ -13226,7 +13244,8 @@ const StorageClassPvField = () => {
13226
13244
  field: "",
13227
13245
  value: "",
13228
13246
  fn(pv2) {
13229
- return sc.filterPV(pv2, sc.metadata.name);
13247
+ var _a;
13248
+ return sc.filterPV(pv2, (_a = sc.metadata) == null ? void 0 : _a.name);
13230
13249
  }
13231
13250
  }
13232
13251
  ]
@@ -13280,14 +13299,7 @@ const PVStorageClassField = (i18n2) => {
13280
13299
  path: ["spec", "storageClassName"],
13281
13300
  title: i18n2.t("dovetail.storage_class"),
13282
13301
  renderContent(value2) {
13283
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
13284
- ResourceLink,
13285
- {
13286
- resourceKind: "storageclasses",
13287
- namespace: "",
13288
- name: value2
13289
- }
13290
- );
13302
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(ResourceLink, { resourceKind: "storageclasses", namespace: "", name: value2 });
13291
13303
  }
13292
13304
  };
13293
13305
  };
@@ -13297,7 +13309,7 @@ const PVPhaseField = (i18n2) => {
13297
13309
  path: ["stateDisplay"],
13298
13310
  title: i18n2.t("dovetail.state"),
13299
13311
  renderContent(value2) {
13300
- return /* @__PURE__ */ jsxRuntimeExports.jsx(StateTag, { state: value2, resourceKind: "PersistentVolume", hideBackground: true });
13312
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(StateTag, { state: value2, hideBackground: true });
13301
13313
  }
13302
13314
  };
13303
13315
  };
@@ -13326,17 +13338,20 @@ const PVCPodsField = () => {
13326
13338
  key: "pods",
13327
13339
  path: [],
13328
13340
  renderContent: (_, record) => {
13341
+ var _a;
13329
13342
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
13330
13343
  WorkloadPodsTable,
13331
13344
  {
13332
13345
  filter: (item) => {
13333
- var _a, _b;
13334
- return !!((_b = (_a = item.spec) == null ? void 0 : _a.volumes) == null ? void 0 : _b.some((v) => {
13335
- var _a2;
13336
- return ((_a2 = v.persistentVolumeClaim) == null ? void 0 : _a2.claimName) === record.metadata.name;
13337
- }));
13346
+ var _a2, _b;
13347
+ return !!((_b = (_a2 = item.spec) == null ? void 0 : _a2.volumes) == null ? void 0 : _b.some(
13348
+ (v) => {
13349
+ var _a3, _b2;
13350
+ return ((_a3 = v.persistentVolumeClaim) == null ? void 0 : _a3.claimName) === ((_b2 = record.metadata) == null ? void 0 : _b2.name);
13351
+ }
13352
+ ));
13338
13353
  },
13339
- namespace: record.metadata.namespace,
13354
+ namespace: (_a = record.metadata) == null ? void 0 : _a.namespace,
13340
13355
  hideToolbar: true
13341
13356
  }
13342
13357
  );
@@ -38364,13 +38379,14 @@ const useRefineForm = (props) => {
38364
38379
  refineCoreProps: {
38365
38380
  errorNotification: false,
38366
38381
  successNotification: () => {
38382
+ var _a2;
38367
38383
  const formValue = result.getValues();
38368
38384
  return {
38369
38385
  message: i18n2.t(
38370
38386
  id ? "dovetail.edit_resource_success" : "dovetail.create_success_toast",
38371
38387
  {
38372
38388
  kind: addSpaceBeforeLetter(config.displayName || config.kind),
38373
- name: formValue.metadata.name,
38389
+ name: (_a2 = formValue.metadata) == null ? void 0 : _a2.name,
38374
38390
  interpolation: { escapeValue: false }
38375
38391
  }
38376
38392
  ).trim(),
@@ -38409,7 +38425,7 @@ const Separator = () => {
38409
38425
  });
38410
38426
  };
38411
38427
  const MonacoYamlEditor = React__default.lazy(() => Promise.resolve().then(() => MonacoYamlEditor$2));
38412
- const MonacoYamlDiffEditor = React__default.lazy(() => import("./MonacoYamlDiffEditor-4fb3ff3b.js"));
38428
+ const MonacoYamlDiffEditor = React__default.lazy(() => import("./MonacoYamlDiffEditor-b8cc439d.js"));
38413
38429
  const YamlEditorComponent = forwardRef(
38414
38430
  function YamlEditorComponent2(props, ref) {
38415
38431
  const {
@@ -39511,10 +39527,11 @@ const EditLabelForm = React__default.forwardRef(
39511
39527
  kind: resourceModel.kind
39512
39528
  },
39513
39529
  successNotification() {
39530
+ var _a2;
39514
39531
  return {
39515
39532
  message: t2("dovetail.edit_label_success_toast", {
39516
39533
  kind: resourceModel.kind,
39517
- name: resourceModel.metadata.name,
39534
+ name: (_a2 = resourceModel.metadata) == null ? void 0 : _a2.name,
39518
39535
  interpolation: {
39519
39536
  escapeValue: false
39520
39537
  }
@@ -39596,10 +39613,11 @@ const EditAnnotationForm = React__default.forwardRef(function EditAnnotationForm
39596
39613
  kind: resourceModel.kind
39597
39614
  },
39598
39615
  successNotification() {
39616
+ var _a2;
39599
39617
  return {
39600
39618
  message: t2("dovetail.edit_annotation_success_toast", {
39601
39619
  kind: resourceModel.kind,
39602
- name: resourceModel.metadata.name,
39620
+ name: (_a2 = resourceModel.metadata) == null ? void 0 : _a2.name,
39603
39621
  interpolation: {
39604
39622
  escapeValue: false
39605
39623
  }
@@ -40544,7 +40562,6 @@ const PVPhaseColumnRenderer = (i18n2) => {
40544
40562
  render(value2) {
40545
40563
  return /* @__PURE__ */ jsxRuntimeExports.jsx(StateTag, {
40546
40564
  state: value2,
40547
- resourceKind: "PersistentVolume",
40548
40565
  hideBackground: true
40549
40566
  });
40550
40567
  }
@@ -40664,6 +40681,8 @@ const Dovetail = (props) => {
40664
40681
  globalStore,
40665
40682
  accessControlProvider,
40666
40683
  routerProvider: customRouterProvider,
40684
+ dataProvider: customDataProvider,
40685
+ liveProvider: customLiveProvider,
40667
40686
  antdGetPopupContainer
40668
40687
  } = props;
40669
40688
  const msg = useMessage();
@@ -40714,10 +40733,10 @@ const Dovetail = (props) => {
40714
40733
  Refine,
40715
40734
  {
40716
40735
  dataProvider: {
40717
- default: dataProvider(globalStore)
40736
+ default: customDataProvider || dataProvider(globalStore)
40718
40737
  },
40719
40738
  routerProvider: customRouterProvider || routerProvider,
40720
- liveProvider: liveProvider(globalStore),
40739
+ liveProvider: customLiveProvider || liveProvider(globalStore),
40721
40740
  notificationProvider,
40722
40741
  options: {
40723
40742
  warnWhenUnsavedChanges: true,
package/dist/refine.js CHANGED
@@ -1,4 +1,4 @@
1
- import { bN, cC, A, aW, aY, aF, ca, bk, a1, co, cc, aQ, T, C, i, cG, aI, bp, ac, cI, ai, ap, cR, ax, cd, cb, cU, aM, bw, w, aD, bD, cT, cD, bG, D, b1, as, bJ, ar, at, a0, c9, c8, cS, bi, aU, ad, bQ, cF, cH, cm, aG, aj, s, q, cJ, I, bt, aT, t, M, be, bg, ce, cL, aL, bs, aq, ay, az, a8, aA, aX, aE, bE, bH, a9, d2, cn, cx, bM, N, a2, e, aV, a6, bP, by, bx, cK, b$, cZ, g, cY, aJ, bq, cg, L, ba, bb, bo, H, bc, J, bd, B, b5, cA, z, b4, G, b8, E, b6, F, b7, K, c0, b9, cz, aa, d0, c$, P, bm, v, ae, ah, b_, bj, cP, cO, a$, bu, c6, c5, p, aK, bl, x, bv, b0, d1, y, cq, cE, bK, bR, bS, d4, aH, R, ag, an, am, bL, ak, cQ, c2, al, cB, c7, bh, bA, au, h, Q, O, bf, ct, cw, cs, cr, cu, cv, cp, ch, ck, cl, cj, ci, cf, cy, bT, aN, br, aB, m, bW, l, aZ, cX, o, bX, a_, n, aS, bn, k, cW, aP, aR, c4, bC, bB, c3, aO, S, bF, cV, c_, b2, b3, bz, bI, c1, bY, bZ, ab, $, cN, af, W, cM, ao, aw, av, f, aC, bU, U, a3, d, d7, d6, d9, d3, a7, da, d5, d8, a5, a4, r, a, c, X, V, Y, Z, u, bO, _, bV, b } from "./index-c5295550.js";
1
+ import { bN, cC, A, aW, aY, aF, ca, bk, a1, co, cc, aQ, T, C, i, cG, aI, bp, ac, cI, ai, ap, cR, ax, cd, cb, cU, aM, bw, w, aD, bD, cT, cD, bG, D, b1, as, bJ, ar, at, a0, c9, c8, cS, bi, aU, ad, bQ, cF, cH, cm, aG, aj, s, q, cJ, I, bt, aT, t, M, be, bg, ce, cL, aL, bs, aq, ay, az, a8, aA, aX, aE, bE, bH, a9, d2, cn, cx, bM, N, a2, e, aV, a6, bP, by, bx, cK, b$, cZ, g, cY, aJ, bq, cg, L, ba, bb, bo, H, bc, J, bd, B, b5, cA, z, b4, G, b8, E, b6, F, b7, K, c0, b9, cz, aa, d0, c$, P, bm, v, ae, ah, b_, bj, cP, cO, a$, bu, c6, c5, p, aK, bl, x, bv, b0, d1, y, cq, cE, bK, bR, bS, d4, aH, R, ag, an, am, bL, ak, cQ, c2, al, cB, c7, bh, bA, au, h, Q, O, bf, ct, cw, cs, cr, cu, cv, cp, ch, ck, cl, cj, ci, cf, cy, bT, aN, br, aB, m, bW, l, aZ, cX, o, bX, a_, n, aS, bn, k, cW, aP, aR, c4, bC, bB, c3, aO, S, bF, cV, c_, b2, b3, bz, bI, c1, bY, bZ, ab, $, cN, af, W, cM, ao, aw, av, f, aC, bU, U, a3, d, d7, d6, d9, d3, a7, da, d5, d8, a5, a4, r, a, c, X, V, Y, Z, u, bO, _, bV, b } from "./index-66b29f4e.js";
2
2
  import "@cloudtower/eagle";
3
3
  import "@refinedev/core";
4
4
  import "react";
@@ -9656,11 +9656,17 @@ var __publicField = (obj, key, value) => {
9656
9656
  }
9657
9657
  updateLabel(labels) {
9658
9658
  const newYaml = this._globalStore.restoreItem(this);
9659
+ if (!newYaml.metadata) {
9660
+ newYaml.metadata = {};
9661
+ }
9659
9662
  newYaml.metadata.labels = labels;
9660
9663
  return newYaml;
9661
9664
  }
9662
9665
  updateAnnotation(annotations) {
9663
9666
  const newYaml = this._globalStore.restoreItem(this);
9667
+ if (!newYaml.metadata) {
9668
+ newYaml.metadata = {};
9669
+ }
9664
9670
  newYaml.metadata.annotations = annotations;
9665
9671
  return newYaml;
9666
9672
  }
@@ -10709,15 +10715,16 @@ var __publicField = (obj, key, value) => {
10709
10715
  this._rawYaml = _rawYaml;
10710
10716
  }
10711
10717
  get role() {
10712
- return "node-role.kubernetes.io/control-plane" in (this.metadata.labels || {}) ? "Control Plane" : "Worker";
10718
+ var _a;
10719
+ return "node-role.kubernetes.io/control-plane" in (((_a = this.metadata) == null ? void 0 : _a.labels) || {}) ? "Control Plane" : "Worker";
10713
10720
  }
10714
10721
  get ip() {
10715
10722
  var _a, _b;
10716
10723
  return (_b = (_a = this._rawYaml.status.addresses) == null ? void 0 : _a.find((add) => add.type === "InternalIP")) == null ? void 0 : _b.address;
10717
10724
  }
10718
10725
  get nodeGroupName() {
10719
- var _a;
10720
- return (_a = this.metadata.labels) == null ? void 0 : _a["cape.infrastructure.cluster.x-k8s.io/node-group"];
10726
+ var _a, _b;
10727
+ return (_b = (_a = this.metadata) == null ? void 0 : _a.labels) == null ? void 0 : _b["cape.infrastructure.cluster.x-k8s.io/node-group"];
10721
10728
  }
10722
10729
  get isControlPlane() {
10723
10730
  var _a;
@@ -10738,7 +10745,10 @@ var __publicField = (obj, key, value) => {
10738
10745
  kind: "PersistentVolume"
10739
10746
  });
10740
10747
  this.pvs = pvs.items.filter(
10741
- (pv2) => this.filterPV(pv2, this.metadata.name)
10748
+ (pv2) => {
10749
+ var _a;
10750
+ return this.filterPV(pv2, (_a = this.metadata) == null ? void 0 : _a.name);
10751
+ }
10742
10752
  );
10743
10753
  }
10744
10754
  filterPV(pv2, scName) {
@@ -11183,6 +11193,7 @@ var __publicField = (obj, key, value) => {
11183
11193
  RESOURCE_GROUP2["SERVICE_AND_NETWORK"] = "SERVICE_AND_NETWORK";
11184
11194
  RESOURCE_GROUP2["CONFIG"] = "CONFIG";
11185
11195
  RESOURCE_GROUP2["NODE_MANAGEMENT"] = "NODE_MANAGEMENT";
11196
+ RESOURCE_GROUP2["PROJECT"] = "PROJECT";
11186
11197
  return RESOURCE_GROUP2;
11187
11198
  })(RESOURCE_GROUP || {});
11188
11199
  var FormType = /* @__PURE__ */ ((FormType2) => {
@@ -11206,20 +11217,20 @@ var __publicField = (obj, key, value) => {
11206
11217
  const pushModal = eagle.usePushModal();
11207
11218
  const go = core.useGo();
11208
11219
  return function openForm() {
11209
- var _a, _b;
11220
+ var _a, _b, _c;
11210
11221
  if (resource == null ? void 0 : resource.name) {
11211
11222
  const config = configs[resource.name];
11212
11223
  const formType = (_a = config.formConfig) == null ? void 0 : _a.formType;
11213
11224
  if (formType === void 0 || formType === FormType.MODAL) {
11214
11225
  pushModal({
11215
- component: FormModal,
11226
+ component: ((_b = config.formConfig) == null ? void 0 : _b.CustomFormModal) || FormModal,
11216
11227
  props: {
11217
11228
  resource: resource.name,
11218
11229
  id: options == null ? void 0 : options.id,
11219
11230
  formProps: {
11220
11231
  initialValues: getInitialValues(config)
11221
11232
  },
11222
- renderForm: (options == null ? void 0 : options.renderForm) || ((_b = config.formConfig) == null ? void 0 : _b.renderForm)
11233
+ renderForm: (options == null ? void 0 : options.renderForm) || ((_c = config.formConfig) == null ? void 0 : _c.renderForm)
11223
11234
  }
11224
11235
  });
11225
11236
  } else if (options == null ? void 0 : options.id) {
@@ -11914,7 +11925,12 @@ var __publicField = (obj, key, value) => {
11914
11925
  }) });
11915
11926
  }
11916
11927
  const StateTag = (props) => {
11917
- const { state: state2 = ResourceState.UPDATING, hideBackground, className, resourceKind } = props;
11928
+ const {
11929
+ state: state2 = ResourceState.UPDATING,
11930
+ hideBackground,
11931
+ className,
11932
+ customResourceStateMap
11933
+ } = props;
11918
11934
  const { t: t2 } = useTranslation();
11919
11935
  const defaultStateMap = {
11920
11936
  [ResourceState.UPDATING]: "loading",
@@ -11935,19 +11951,19 @@ var __publicField = (obj, key, value) => {
11935
11951
  [ResourceState.RELEASED]: "gray",
11936
11952
  [ResourceState.LOST]: "red"
11937
11953
  };
11938
- const resourceStateMap = {};
11939
- const finalStateMap = resourceStateMap[resourceKind || ""] || defaultStateMap;
11954
+ const finalColorMap = (customResourceStateMap == null ? void 0 : customResourceStateMap.color) || defaultStateMap;
11955
+ const finalTextMap = customResourceStateMap == null ? void 0 : customResourceStateMap.text;
11940
11956
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
11941
11957
  eagle.StatusCapsule,
11942
11958
  {
11943
11959
  className: cx_default(className, StateTagStyle, hideBackground && "no-background"),
11944
- color: finalStateMap[state2] !== "loading" ? finalStateMap[state2] : void 0,
11945
- loading: finalStateMap[state2] === "loading",
11946
- children: t2(`dovetail.${state2 || "updating"}_state`)
11960
+ color: finalColorMap[state2] !== "loading" ? finalColorMap[state2] : void 0,
11961
+ loading: finalColorMap[state2] === "loading",
11962
+ children: finalTextMap ? finalTextMap[state2] : t2(`dovetail.${state2 || "updating"}_state`)
11947
11963
  }
11948
11964
  );
11949
11965
  };
11950
- const ShowContent_ua3los = "";
11966
+ const ShowContent_1g0ejph = "";
11951
11967
  const ShowContentWrapperStyle = "s9agep2";
11952
11968
  const BackButton = "bo89gfi";
11953
11969
  const ToolBarWrapper = "t1ohe42f";
@@ -11979,7 +11995,7 @@ var __publicField = (obj, key, value) => {
11979
11995
  });
11980
11996
  }
11981
11997
  const ShowContent = (props) => {
11982
- var _a, _b, _c, _d, _e, _f;
11998
+ var _a, _b, _c, _d, _e;
11983
11999
  const {
11984
12000
  showConfig,
11985
12001
  formatter,
@@ -12095,10 +12111,10 @@ var __publicField = (obj, key, value) => {
12095
12111
  children: (_c = record == null ? void 0 : record.metadata) == null ? void 0 : _c.name
12096
12112
  }), stateDisplay ? /* @__PURE__ */ jsxRuntimeExports.jsx(StateTag, {
12097
12113
  state: stateDisplay,
12098
- resourceKind: (_d = resource == null ? void 0 : resource.meta) == null ? void 0 : _d.kind
12114
+ customResourceStateMap: showConfig.resourceStateMap
12099
12115
  }) : void 0]
12100
12116
  }), /* @__PURE__ */ jsxRuntimeExports.jsxs(eagle.Space, {
12101
- children: [(_e = showConfig.renderExtraButton) == null ? void 0 : _e.call(showConfig, record), !config.hideEdit ? /* @__PURE__ */ jsxRuntimeExports.jsx(core.CanAccess, {
12117
+ children: [(_d = showConfig.renderExtraButton) == null ? void 0 : _d.call(showConfig, record), !config.hideEdit ? /* @__PURE__ */ jsxRuntimeExports.jsx(core.CanAccess, {
12102
12118
  resource: resource == null ? void 0 : resource.name,
12103
12119
  action: AccessControlAuth.Edit,
12104
12120
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(eagle.Button, {
@@ -12106,7 +12122,7 @@ var __publicField = (obj, key, value) => {
12106
12122
  marginRight: 8
12107
12123
  },
12108
12124
  onClick: openForm,
12109
- children: ((_f = config.formConfig) == null ? void 0 : _f.fields) ? t2("dovetail.edit") : t2("dovetail.edit_yaml")
12125
+ children: ((_e = config.formConfig) == null ? void 0 : _e.fields) ? t2("dovetail.edit") : t2("dovetail.edit_yaml")
12110
12126
  })
12111
12127
  }) : null, /* @__PURE__ */ jsxRuntimeExports.jsx(Dropdown, {
12112
12128
  record,
@@ -12447,10 +12463,11 @@ var __publicField = (obj, key, value) => {
12447
12463
  kind: nodeModel.kind
12448
12464
  },
12449
12465
  successNotification() {
12466
+ var _a;
12450
12467
  return {
12451
12468
  message: t2("dovetail.edit_node_taint_success_toast", {
12452
12469
  kind: nodeModel.kind,
12453
- name: nodeModel.metadata.name,
12470
+ name: (_a = nodeModel.metadata) == null ? void 0 : _a.name,
12454
12471
  interpolation: {
12455
12472
  escapeValue: false
12456
12473
  }
@@ -13103,14 +13120,14 @@ var __publicField = (obj, key, value) => {
13103
13120
  key: "pods",
13104
13121
  path: [],
13105
13122
  renderContent: (_, record) => {
13106
- var _a, _b;
13123
+ var _a, _b, _c;
13107
13124
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
13108
13125
  WorkloadPodsTable,
13109
13126
  {
13110
13127
  selector: (_b = (_a = record.metadata.relations) == null ? void 0 : _a.find((r2) => {
13111
13128
  return r2.kind === "Pod" && r2.type === "selects";
13112
13129
  })) == null ? void 0 : _b.selector,
13113
- namespace: record.metadata.namespace,
13130
+ namespace: (_c = record.metadata) == null ? void 0 : _c.namespace,
13114
13131
  hideToolbar: true
13115
13132
  }
13116
13133
  );
@@ -13131,7 +13148,8 @@ var __publicField = (obj, key, value) => {
13131
13148
  key: "event",
13132
13149
  path: [],
13133
13150
  renderContent: (_, record) => {
13134
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { padding: "0 24px", height: "100%" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(EventsTable, { uid: record.metadata.uid }) });
13151
+ var _a;
13152
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { padding: "0 24px", height: "100%" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(EventsTable, { uid: (_a = record.metadata) == null ? void 0 : _a.uid }) });
13135
13153
  }
13136
13154
  };
13137
13155
  };
@@ -13232,7 +13250,8 @@ var __publicField = (obj, key, value) => {
13232
13250
  field: "",
13233
13251
  value: "",
13234
13252
  fn(pv2) {
13235
- return sc.filterPV(pv2, sc.metadata.name);
13253
+ var _a;
13254
+ return sc.filterPV(pv2, (_a = sc.metadata) == null ? void 0 : _a.name);
13236
13255
  }
13237
13256
  }
13238
13257
  ]
@@ -13286,14 +13305,7 @@ var __publicField = (obj, key, value) => {
13286
13305
  path: ["spec", "storageClassName"],
13287
13306
  title: i18n2.t("dovetail.storage_class"),
13288
13307
  renderContent(value2) {
13289
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
13290
- ResourceLink,
13291
- {
13292
- resourceKind: "storageclasses",
13293
- namespace: "",
13294
- name: value2
13295
- }
13296
- );
13308
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(ResourceLink, { resourceKind: "storageclasses", namespace: "", name: value2 });
13297
13309
  }
13298
13310
  };
13299
13311
  };
@@ -13303,7 +13315,7 @@ var __publicField = (obj, key, value) => {
13303
13315
  path: ["stateDisplay"],
13304
13316
  title: i18n2.t("dovetail.state"),
13305
13317
  renderContent(value2) {
13306
- return /* @__PURE__ */ jsxRuntimeExports.jsx(StateTag, { state: value2, resourceKind: "PersistentVolume", hideBackground: true });
13318
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(StateTag, { state: value2, hideBackground: true });
13307
13319
  }
13308
13320
  };
13309
13321
  };
@@ -13332,17 +13344,20 @@ var __publicField = (obj, key, value) => {
13332
13344
  key: "pods",
13333
13345
  path: [],
13334
13346
  renderContent: (_, record) => {
13347
+ var _a;
13335
13348
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
13336
13349
  WorkloadPodsTable,
13337
13350
  {
13338
13351
  filter: (item) => {
13339
- var _a, _b;
13340
- return !!((_b = (_a = item.spec) == null ? void 0 : _a.volumes) == null ? void 0 : _b.some((v) => {
13341
- var _a2;
13342
- return ((_a2 = v.persistentVolumeClaim) == null ? void 0 : _a2.claimName) === record.metadata.name;
13343
- }));
13352
+ var _a2, _b;
13353
+ return !!((_b = (_a2 = item.spec) == null ? void 0 : _a2.volumes) == null ? void 0 : _b.some(
13354
+ (v) => {
13355
+ var _a3, _b2;
13356
+ return ((_a3 = v.persistentVolumeClaim) == null ? void 0 : _a3.claimName) === ((_b2 = record.metadata) == null ? void 0 : _b2.name);
13357
+ }
13358
+ ));
13344
13359
  },
13345
- namespace: record.metadata.namespace,
13360
+ namespace: (_a = record.metadata) == null ? void 0 : _a.namespace,
13346
13361
  hideToolbar: true
13347
13362
  }
13348
13363
  );
@@ -38370,13 +38385,14 @@ WARNING: This link could potentially be dangerous`)) {
38370
38385
  refineCoreProps: {
38371
38386
  errorNotification: false,
38372
38387
  successNotification: () => {
38388
+ var _a2;
38373
38389
  const formValue = result.getValues();
38374
38390
  return {
38375
38391
  message: i18n2.t(
38376
38392
  id ? "dovetail.edit_resource_success" : "dovetail.create_success_toast",
38377
38393
  {
38378
38394
  kind: addSpaceBeforeLetter(config.displayName || config.kind),
38379
- name: formValue.metadata.name,
38395
+ name: (_a2 = formValue.metadata) == null ? void 0 : _a2.name,
38380
38396
  interpolation: { escapeValue: false }
38381
38397
  }
38382
38398
  ).trim(),
@@ -39517,10 +39533,11 @@ WARNING: This link could potentially be dangerous`)) {
39517
39533
  kind: resourceModel.kind
39518
39534
  },
39519
39535
  successNotification() {
39536
+ var _a2;
39520
39537
  return {
39521
39538
  message: t2("dovetail.edit_label_success_toast", {
39522
39539
  kind: resourceModel.kind,
39523
- name: resourceModel.metadata.name,
39540
+ name: (_a2 = resourceModel.metadata) == null ? void 0 : _a2.name,
39524
39541
  interpolation: {
39525
39542
  escapeValue: false
39526
39543
  }
@@ -39602,10 +39619,11 @@ WARNING: This link could potentially be dangerous`)) {
39602
39619
  kind: resourceModel.kind
39603
39620
  },
39604
39621
  successNotification() {
39622
+ var _a2;
39605
39623
  return {
39606
39624
  message: t2("dovetail.edit_annotation_success_toast", {
39607
39625
  kind: resourceModel.kind,
39608
- name: resourceModel.metadata.name,
39626
+ name: (_a2 = resourceModel.metadata) == null ? void 0 : _a2.name,
39609
39627
  interpolation: {
39610
39628
  escapeValue: false
39611
39629
  }
@@ -40550,7 +40568,6 @@ WARNING: This link could potentially be dangerous`)) {
40550
40568
  render(value2) {
40551
40569
  return /* @__PURE__ */ jsxRuntimeExports.jsx(StateTag, {
40552
40570
  state: value2,
40553
- resourceKind: "PersistentVolume",
40554
40571
  hideBackground: true
40555
40572
  });
40556
40573
  }
@@ -40670,6 +40687,8 @@ WARNING: This link could potentially be dangerous`)) {
40670
40687
  globalStore,
40671
40688
  accessControlProvider,
40672
40689
  routerProvider: customRouterProvider,
40690
+ dataProvider: customDataProvider,
40691
+ liveProvider: customLiveProvider,
40673
40692
  antdGetPopupContainer
40674
40693
  } = props;
40675
40694
  const msg = eagle.useMessage();
@@ -40720,10 +40739,10 @@ WARNING: This link could potentially be dangerous`)) {
40720
40739
  core.Refine,
40721
40740
  {
40722
40741
  dataProvider: {
40723
- default: k8sApiProvider.dataProvider(globalStore)
40742
+ default: customDataProvider || k8sApiProvider.dataProvider(globalStore)
40724
40743
  },
40725
40744
  routerProvider: customRouterProvider || routerProvider,
40726
- liveProvider: k8sApiProvider.liveProvider(globalStore),
40745
+ liveProvider: customLiveProvider || k8sApiProvider.liveProvider(globalStore),
40727
40746
  notificationProvider,
40728
40747
  options: {
40729
40748
  warnWhenUnsavedChanges: true,
package/lib/Dovetail.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AccessControlProvider } from '@refinedev/core';
1
+ import { AccessControlProvider, DataProvider, LiveProvider } from '@refinedev/core';
2
2
  import { History } from 'history';
3
3
  import { GlobalStore } from 'k8s-api-provider';
4
4
  import React from 'react';
@@ -14,6 +14,8 @@ type Props = {
14
14
  globalStore: GlobalStore;
15
15
  accessControlProvider?: AccessControlProvider;
16
16
  routerProvider?: any;
17
+ dataProvider?: DataProvider;
18
+ liveProvider?: LiveProvider;
17
19
  antdGetPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
18
20
  };
19
21
  export declare const Dovetail: React.FC<Props>;
@@ -1,3 +1,4 @@
1
+ import { StatusCapsuleColor } from '@cloudtower/eagle';
1
2
  import { useTable } from '@refinedev/core';
2
3
  import { i18n as I18nType } from 'i18next';
3
4
  import { Unstructured } from 'k8s-api-provider';
@@ -34,6 +35,10 @@ export type ShowTab<Model extends ResourceModel> = {
34
35
  export interface ShowConfig<Model extends ResourceModel = ResourceModel> {
35
36
  tabs?: ShowTab<Model>[];
36
37
  renderExtraButton?: (record: Model) => React.ReactNode;
38
+ resourceStateMap?: {
39
+ color: Record<string, StatusCapsuleColor | 'loading'>;
40
+ text: Record<string, string>;
41
+ };
37
42
  }
38
43
  export declare const ImageField: <Model extends WorkloadBaseModel>(i18n: I18nType) => ShowField<Model>;
39
44
  export declare const ReplicaField: <Model extends JobModel | WorkloadModel>() => ShowField<Model>;
@@ -1,10 +1,14 @@
1
+ import { StatusCapsuleColor } from '@cloudtower/eagle';
1
2
  import React from 'react';
2
3
  import { ResourceState } from '../../constants';
3
4
  type Props = {
4
5
  state?: ResourceState;
5
- resourceKind?: string;
6
6
  className?: string;
7
7
  hideBackground?: boolean;
8
+ customResourceStateMap?: {
9
+ color: Record<string, StatusCapsuleColor | 'loading'>;
10
+ text: Record<string, string>;
11
+ };
8
12
  };
9
13
  export declare const StateTag: React.FC<Props>;
10
14
  export {};
@@ -38,6 +38,7 @@ export declare const StorageClassConfig: (i18n: I18n) => {
38
38
  refineCoreProps?: import("@refinedev/core").UseFormProps<import("@refinedev/core").BaseRecord, import("@refinedev/core").HttpError, import("react-hook-form").FieldValues, import("@refinedev/core").BaseRecord, import("@refinedev/core").BaseRecord, import("@refinedev/core").HttpError> | undefined;
39
39
  useFormProps?: import("@refinedev/react-hook-form").UseFormProps | undefined;
40
40
  isDisabledChangeMode?: boolean | undefined;
41
+ CustomFormModal?: import("react").FC<import("../../components").FormModalProps> | undefined;
41
42
  } | undefined;
42
43
  columns: () => (import("../../components").Column<import("../..").ResourceModel<import("k8s-api-provider").Unstructured>> | import("../../components").Column<import("../..").StorageClassModel>)[];
43
44
  showConfig: () => {
@@ -0,0 +1,18 @@
1
+ import { MetaQuery } from '@refinedev/core';
2
+ import { IProviderPlugin, WatchEvent, GlobalStoreInitParams, Unstructured, UnstructuredList, CancelQueriesParams } from 'k8s-api-provider';
3
+ export interface IGlobalStore {
4
+ plugins: IProviderPlugin[];
5
+ prefix?: string;
6
+ fieldManager?: string;
7
+ apiUrl: string;
8
+ kubeApiTimeout: number | false | undefined;
9
+ get<T = UnstructuredList>(resource: string, meta?: MetaQuery): Promise<T>;
10
+ subscribe(resource: string, onEvent: (data: WatchEvent) => void): () => void;
11
+ publish(resource: string, data: WatchEvent): void;
12
+ init(params: GlobalStoreInitParams): void;
13
+ loadPlugins(plugins?: IProviderPlugin[]): void;
14
+ restoreItem(item: Unstructured): Unstructured;
15
+ restoreData(list: UnstructuredList): UnstructuredList;
16
+ destroy(): void;
17
+ cancelQueries(params?: CancelQueriesParams): void;
18
+ }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { UseFormProps } from '@refinedev/react-hook-form';
3
3
  import { YamlFormProps } from '../components';
4
- import { RefineFormField } from '../components/Form';
4
+ import { FormModalProps, RefineFormField } from '../components/Form';
5
5
  import { Column, InternalTableProps } from '../components/InternalBaseTable';
6
6
  import { ShowConfig } from '../components/ShowContent';
7
7
  import { ResourceModel } from '../models';
@@ -13,7 +13,8 @@ export declare enum RESOURCE_GROUP {
13
13
  SERVICE = "SERVICE",
14
14
  SERVICE_AND_NETWORK = "SERVICE_AND_NETWORK",
15
15
  CONFIG = "CONFIG",
16
- NODE_MANAGEMENT = "NODE_MANAGEMENT"
16
+ NODE_MANAGEMENT = "NODE_MANAGEMENT",
17
+ PROJECT = "PROJECT"
17
18
  }
18
19
  export declare enum FormType {
19
20
  PAGE = "PAGE",
@@ -33,7 +34,7 @@ export type ResourceConfig<Model extends ResourceModel = ResourceModel> = {
33
34
  hideEdit?: boolean;
34
35
  hideCreate?: boolean;
35
36
  description?: string;
36
- parent?: RESOURCE_GROUP;
37
+ parent?: string;
37
38
  formatter?: (v: Model) => Model;
38
39
  initValue?: Record<string, unknown>;
39
40
  columns?: () => Column<Model>[];
@@ -61,5 +62,6 @@ export type ResourceConfig<Model extends ResourceModel = ResourceModel> = {
61
62
  refineCoreProps?: UseFormProps['refineCoreProps'];
62
63
  useFormProps?: UseFormProps;
63
64
  isDisabledChangeMode?: boolean;
65
+ CustomFormModal?: React.FC<FormModalProps>;
64
66
  };
65
67
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dovetail-v2/refine",
3
- "version": "0.1.16",
3
+ "version": "0.1.17-alpha.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -30,7 +30,7 @@
30
30
  "dayjs": "^1.11.10",
31
31
  "i18next": "^23.2.3",
32
32
  "js-yaml": "^4.1.0",
33
- "k8s-api-provider": "0.0.23",
33
+ "k8s-api-provider": "^0.0.25",
34
34
  "ky": "^0.33.3",
35
35
  "lodash-es": "^4.17.21",
36
36
  "mitt": "^3.0.1",