@dovetail-v2/refine 0.1.31 → 0.2.0-alpha.0

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.
@@ -11,7 +11,7 @@ import { ResourceContext, matchResourceFromRoute, useResource, useDelete, useNav
11
11
  import { parse, stringify } from "qs";
12
12
  import { useLocation, useHistory, useParams, matchPath, Link, Route, NavLink, Router } from "react-router-dom";
13
13
  import { Typo, Tag, Input, Select, AntdOption, Button, Form, Space, TextArea, kitContext, Loading, Table as Table$2, Pagination, Alert, usePopModal, Modal, usePushModal, Fields, Units, Link as Link$1, OverflowTooltip, Tooltip, Dropdown, Menu as Menu$1, Icon as Icon$1, Divider, StatusCapsule, Tabs as Tabs$1, TabsTabPane, Row, Col, Popover, AntdTable, TableForm, getOptions, DonutChart, SegmentControl, Checkbox, useMessage, DropdownMenu, SearchInput, Token, AntdSelectOptGroup, MenuItemGroup, Layout as Layout$1, Time as Time$1, ModalStack, KitStoreProvider, ConfigProvider } from "@cloudtower/eagle";
14
- import { first, get as get$3, cloneDeep, set as set$1, omit as omit$1, merge, debounce, last, isObject as isObject$4, uniq, keyBy } from "lodash-es";
14
+ import { first, get as get$3, cloneDeep, set as set$1, omit as omit$1, merge, debounce, last, setWith, clone, isObject as isObject$4, uniq, keyBy } from "lodash-es";
15
15
  import { EditPen16PrimaryIcon, Download16GradientBlueIcon, TrashBinDelete16Icon, MoreEllipsis324BoldSecondaryIcon, MoreEllipsis324BoldBlueIcon, MoreEllipsis316BoldBlueIcon, PlusAddCreateNew16BoldOntintIcon, ArrowChevronLeft16BoldTertiaryIcon, ArrowChevronLeftSmall16BoldBlueIcon, ViewEye16GradientGrayIcon, EntityFilterIgnoreGradient16GrayIcon, InfoICircleFill16GrayIcon, InfoICircleFill16Gray70Icon, RecoverContinue16GradientBlueIcon, SuspendedPause16GradientBlueIcon, Retry16GradientBlueIcon, FontSize16GrayIcon, FontSize16BlueIcon, LogCollection16GrayIcon, LogCollection16GradientBlueIcon, TrashBinDeletePermanently16GrayIcon, TrashBinDeletePermanently16BlueIcon, Loading24GradientBlueIcon, OpenTerminal16GradientBlueIcon, HierarchyTriangleRight16GrayIcon, HierarchyTriangleRight16BlueIcon, ClipboardCopy16GradientGrayIcon, ClipboardCopy16GradientBlueIcon, Retry16GradientGrayIcon, EditPen16GradientGrayIcon, EditPen16GradientBlueIcon, Showdiff16GradientGrayIcon, Showdiff16GradientBlueIcon, XmarkFailedSeriousWarningFill16RedIcon, ExclamationErrorCircleFill16RedIcon, Pause16GradientBlueIcon, EditPen16BlueIcon } from "@cloudtower/icons-react";
16
16
  import yaml$2 from "js-yaml";
17
17
  import { paginateData, sortData, dataProvider, liveProvider } from "k8s-api-provider";
@@ -621,9 +621,9 @@ function nodesToString(children, i18nOptions) {
621
621
  } else if (typeof child === "object") {
622
622
  const {
623
623
  format: format2,
624
- ...clone
624
+ ...clone2
625
625
  } = child;
626
- const keys = Object.keys(clone);
626
+ const keys = Object.keys(clone2);
627
627
  if (keys.length === 1) {
628
628
  const value2 = format2 ? `${keys[0]}, ${format2}` : keys[0];
629
629
  stringNode += `{{${value2}}}`;
@@ -1236,7 +1236,7 @@ const taint_effect_NoExecute_tooltip_2$1 = "Pods with tolerance but no duration
1236
1236
  const taint_effect_NoExecute_tooltip_3$1 = "Pods with tolerance and a duration set will run for the specified time and then be evicted.";
1237
1237
  const taint_effect_PreferNoSchedule_tooltip$1 = "The control plane will try to avoid scheduling pods without taint tolerance to the node, but full avoidance isn't guaranteed.";
1238
1238
  const cant_delete_resource$1 = "Unable to delete {{resource}}";
1239
- const cant_delete_resource_with_name$1 = "The {{resource}} <0>{name}</0> cannot be deleted.";
1239
+ const cant_delete_resource_with_name$1 = "The {{resource}} <0>{{name}}</0> cannot be deleted.";
1240
1240
  const close$1 = "Close";
1241
1241
  const dovetail$1 = {
1242
1242
  copy: copy$2,
@@ -6326,15 +6326,15 @@ lodash.exports;
6326
6326
  function wrapperPlant(value2) {
6327
6327
  var result2, parent2 = this;
6328
6328
  while (parent2 instanceof baseLodash) {
6329
- var clone2 = wrapperClone(parent2);
6330
- clone2.__index__ = 0;
6331
- clone2.__values__ = undefined$1;
6329
+ var clone3 = wrapperClone(parent2);
6330
+ clone3.__index__ = 0;
6331
+ clone3.__values__ = undefined$1;
6332
6332
  if (result2) {
6333
- previous.__wrapped__ = clone2;
6333
+ previous.__wrapped__ = clone3;
6334
6334
  } else {
6335
- result2 = clone2;
6335
+ result2 = clone3;
6336
6336
  }
6337
- var previous = clone2;
6337
+ var previous = clone3;
6338
6338
  parent2 = parent2.__wrapped__;
6339
6339
  }
6340
6340
  previous.__wrapped__ = value2;
@@ -6769,7 +6769,7 @@ lodash.exports;
6769
6769
  var value2 = arguments[0];
6770
6770
  return isArray2(value2) ? value2 : [value2];
6771
6771
  }
6772
- function clone(value2) {
6772
+ function clone2(value2) {
6773
6773
  return baseClone(value2, CLONE_SYMBOLS_FLAG);
6774
6774
  }
6775
6775
  function cloneWith(value2, customizer) {
@@ -7183,7 +7183,7 @@ lodash.exports;
7183
7183
  function set2(object2, path2, value2) {
7184
7184
  return object2 == null ? object2 : baseSet(object2, path2, value2);
7185
7185
  }
7186
- function setWith(object2, path2, value2, customizer) {
7186
+ function setWith2(object2, path2, value2, customizer) {
7187
7187
  customizer = typeof customizer == "function" ? customizer : undefined$1;
7188
7188
  return object2 == null ? object2 : baseSet(object2, path2, value2, customizer);
7189
7189
  }
@@ -7844,7 +7844,7 @@ lodash.exports;
7844
7844
  lodash2.reverse = reverse;
7845
7845
  lodash2.sampleSize = sampleSize;
7846
7846
  lodash2.set = set2;
7847
- lodash2.setWith = setWith;
7847
+ lodash2.setWith = setWith2;
7848
7848
  lodash2.shuffle = shuffle;
7849
7849
  lodash2.slice = slice;
7850
7850
  lodash2.sortBy = sortBy;
@@ -7901,7 +7901,7 @@ lodash.exports;
7901
7901
  lodash2.capitalize = capitalize;
7902
7902
  lodash2.ceil = ceil;
7903
7903
  lodash2.clamp = clamp;
7904
- lodash2.clone = clone;
7904
+ lodash2.clone = clone2;
7905
7905
  lodash2.cloneDeep = cloneDeep2;
7906
7906
  lodash2.cloneDeepWith = cloneDeepWith;
7907
7907
  lodash2.cloneWith = cloneWith;
@@ -11432,11 +11432,21 @@ var RESOURCE_GROUP = /* @__PURE__ */ ((RESOURCE_GROUP2) => {
11432
11432
  RESOURCE_GROUP2["PROJECT"] = "PROJECT";
11433
11433
  return RESOURCE_GROUP2;
11434
11434
  })(RESOURCE_GROUP || {});
11435
+ var FormContainerType = /* @__PURE__ */ ((FormContainerType2) => {
11436
+ FormContainerType2["PAGE"] = "PAGE";
11437
+ FormContainerType2["MODAL"] = "MODAL";
11438
+ return FormContainerType2;
11439
+ })(FormContainerType || {});
11435
11440
  var FormType = /* @__PURE__ */ ((FormType2) => {
11436
- FormType2["PAGE"] = "PAGE";
11437
- FormType2["MODAL"] = "MODAL";
11441
+ FormType2["YAML"] = "YAML";
11442
+ FormType2["FORM"] = "FORM";
11438
11443
  return FormType2;
11439
11444
  })(FormType || {});
11445
+ var FormMode = /* @__PURE__ */ ((FormMode2) => {
11446
+ FormMode2["FORM"] = "FORM";
11447
+ FormMode2["YAML"] = "YAML";
11448
+ return FormMode2;
11449
+ })(FormMode || {});
11440
11450
  function getInitialValues(config) {
11441
11451
  return config.initValue || {
11442
11452
  apiVersion: config.apiVersion,
@@ -11453,11 +11463,11 @@ function useOpenForm(options) {
11453
11463
  const pushModal = usePushModal();
11454
11464
  const go = useGo();
11455
11465
  return function openForm() {
11456
- var _a, _b, _c;
11466
+ var _a, _b;
11457
11467
  if (resource == null ? void 0 : resource.name) {
11458
11468
  const config = configs[resource.name];
11459
- const formType = (_a = config.formConfig) == null ? void 0 : _a.formType;
11460
- if (formType === void 0 || formType === FormType.MODAL) {
11469
+ const formType = (_a = config.formConfig) == null ? void 0 : _a.formContainerType;
11470
+ if (formType === void 0 || formType === FormContainerType.MODAL) {
11461
11471
  pushModal({
11462
11472
  component: ((_b = config.formConfig) == null ? void 0 : _b.CustomFormModal) || FormModal,
11463
11473
  props: {
@@ -11465,8 +11475,7 @@ function useOpenForm(options) {
11465
11475
  id: options == null ? void 0 : options.id,
11466
11476
  formProps: {
11467
11477
  initialValues: getInitialValues(config)
11468
- },
11469
- renderForm: (options == null ? void 0 : options.renderForm) || ((_c = config.formConfig) == null ? void 0 : _c.renderForm)
11478
+ }
11470
11479
  }
11471
11480
  });
11472
11481
  } else if (options == null ? void 0 : options.id) {
@@ -11514,12 +11523,13 @@ function K8sDropdown(props) {
11514
11523
  resource: resource == null ? void 0 : resource.name,
11515
11524
  action: AccessControlAuth.Delete
11516
11525
  });
11526
+ const formType = ((_a = config.formConfig) == null ? void 0 : _a.formType) || FormType.FORM;
11517
11527
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
11518
11528
  /* @__PURE__ */ jsxRuntimeExports.jsx(
11519
11529
  Dropdown,
11520
11530
  {
11521
11531
  overlay: /* @__PURE__ */ jsxRuntimeExports.jsxs(Menu$1, { children: [
11522
- isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false || config.hideEdit ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(Menu$1.Item, { onClick: openForm, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon$1, { src: EditPen16PrimaryIcon, children: ((_a = config.formConfig) == null ? void 0 : _a.fields) ? t2("dovetail.edit") : t2("dovetail.edit_yaml") }) }),
11532
+ isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false || config.hideEdit ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(Menu$1.Item, { onClick: openForm, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon$1, { src: EditPen16PrimaryIcon, children: formType === FormType.FORM ? t2("dovetail.edit") : t2("dovetail.edit_yaml") }) }),
11523
11533
  /* @__PURE__ */ jsxRuntimeExports.jsx(
11524
11534
  Menu$1.Item,
11525
11535
  {
@@ -12377,7 +12387,7 @@ const ShowContent = (props) => {
12377
12387
  marginRight: 8
12378
12388
  },
12379
12389
  onClick: openForm,
12380
- children: ((_e = config.formConfig) == null ? void 0 : _e.fields) ? t2("dovetail.edit") : t2("dovetail.edit_yaml")
12390
+ children: ((_e = config.formConfig) == null ? void 0 : _e.formType) === FormType.FORM ? t2("dovetail.edit") : t2("dovetail.edit_yaml")
12381
12391
  })
12382
12392
  }) : null, /* @__PURE__ */ jsxRuntimeExports.jsx(Dropdown2, {
12383
12393
  record,
@@ -19522,7 +19532,7 @@ const PodLogTab = (i18n2) => ({
19522
19532
  }
19523
19533
  ]
19524
19534
  });
19525
- const style_j3z7so = "";
19535
+ const style_10p48dp = "";
19526
19536
  const ToolBarStyle = "t1joof7s";
19527
19537
  const ToolBarHeaderStyle = "tti58uh";
19528
19538
  const ErrorIconStyle = "e15yt16p";
@@ -20588,7 +20598,7 @@ var tinycolor = { exports: {} };
20588
20598
  }
20589
20599
  return formattedString || this.toHexString();
20590
20600
  },
20591
- clone: function clone() {
20601
+ clone: function clone2() {
20592
20602
  return tinycolor2(this.toString());
20593
20603
  },
20594
20604
  _applyModification: function _applyModification(fn, args) {
@@ -36317,6 +36327,33 @@ function ResourceShow(props) {
36317
36327
  }
36318
36328
  );
36319
36329
  }
36330
+ function FormModeSegmentControl({
36331
+ formConfig,
36332
+ mode,
36333
+ onChangeMode
36334
+ }) {
36335
+ const { isDisabledChangeMode } = formConfig;
36336
+ return !isDisabledChangeMode ? /* @__PURE__ */ jsxRuntimeExports.jsx(
36337
+ SegmentControl,
36338
+ {
36339
+ style: { fontWeight: "normal" },
36340
+ value: mode,
36341
+ options: [
36342
+ {
36343
+ value: FormMode.FORM,
36344
+ label: i18n.t("dovetail.form")
36345
+ },
36346
+ {
36347
+ value: FormMode.YAML,
36348
+ label: i18n.t("dovetail.yaml")
36349
+ }
36350
+ ],
36351
+ onChange: (val) => {
36352
+ onChangeMode(val);
36353
+ }
36354
+ }
36355
+ ) : null;
36356
+ }
36320
36357
  var isCheckBoxInput = (element) => element.type === "checkbox";
36321
36358
  var isDateObject = (value2) => value2 instanceof Date;
36322
36359
  var isNullOrUndefined = (value2) => value2 == null;
@@ -37894,8 +37931,8 @@ function useForm$1(props = {}) {
37894
37931
  _formControl.current.formState = getProxyFormState(formState, control);
37895
37932
  return _formControl.current;
37896
37933
  }
37897
- function useFieldsConfig(config, resourceId) {
37898
- var _a, _b, _c, _d;
37934
+ function useFieldsConfig(config, formConfig, resourceId) {
37935
+ var _a, _b, _c;
37899
37936
  const action = resourceId ? "edit" : "create";
37900
37937
  const listQuery = useList({
37901
37938
  resource: config == null ? void 0 : config.name,
@@ -37909,40 +37946,91 @@ function useFieldsConfig(config, resourceId) {
37909
37946
  meta: { resourceBasePath: config == null ? void 0 : config.basePath, kind: config == null ? void 0 : config.kind },
37910
37947
  id: resourceId
37911
37948
  });
37912
- return (_d = (_a = config == null ? void 0 : config.formConfig) == null ? void 0 : _a.fields) == null ? void 0 : _d.call(_a, {
37913
- record: (_b = showQuery.queryResult.data) == null ? void 0 : _b.data,
37914
- records: ((_c = listQuery.data) == null ? void 0 : _c.data) || [],
37949
+ return (_c = formConfig == null ? void 0 : formConfig.fields) == null ? void 0 : _c.call(formConfig, {
37950
+ record: (_a = showQuery.queryResult.data) == null ? void 0 : _a.data,
37951
+ records: ((_b = listQuery.data) == null ? void 0 : _b.data) || [],
37952
+ action
37953
+ });
37954
+ }
37955
+ const RefineFormContent_ahna8x = "";
37956
+ function renderCommonFormFiled(props) {
37957
+ const {
37958
+ field,
37959
+ fieldConfig,
37915
37960
  action
37961
+ } = props;
37962
+ const {
37963
+ value: value2,
37964
+ onChange,
37965
+ onBlur,
37966
+ name: name2
37967
+ } = field;
37968
+ let ele = /* @__PURE__ */ jsxRuntimeExports.jsx(Fields.String, {
37969
+ placeholder: fieldConfig.placeholder,
37970
+ input: {
37971
+ value: value2,
37972
+ onChange,
37973
+ onBlur,
37974
+ name: name2,
37975
+ onFocus: () => null
37976
+ },
37977
+ meta: {}
37916
37978
  });
37979
+ switch (fieldConfig.type) {
37980
+ case "number":
37981
+ ele = /* @__PURE__ */ jsxRuntimeExports.jsx(Fields.Integer, {
37982
+ className: "c154n7ie",
37983
+ placeholder: fieldConfig.placeholder,
37984
+ input: {
37985
+ value: value2,
37986
+ onChange,
37987
+ onBlur,
37988
+ name: name2,
37989
+ onFocus: () => null
37990
+ },
37991
+ meta: {}
37992
+ });
37993
+ }
37994
+ if (action === "edit" && fieldConfig.disabledWhenEdit) {
37995
+ ele = /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
37996
+ children: value2
37997
+ });
37998
+ }
37999
+ return ele;
37917
38000
  }
37918
- const RefineFormContent_7gh3uw = "";
37919
38001
  const RefineFormContent = (props) => {
37920
38002
  const {
37921
38003
  config,
37922
38004
  formResult,
37923
38005
  resourceId,
37924
- errorMsgs
38006
+ errorMsgs,
38007
+ formConfig
37925
38008
  } = props;
37926
38009
  const {
37927
38010
  control,
37928
- getValues
38011
+ getValues,
38012
+ watch,
38013
+ trigger
37929
38014
  } = formResult;
37930
38015
  const action = resourceId ? "edit" : "create";
37931
- const formFieldsConfig = useFieldsConfig(config, resourceId);
37932
- const fields = formFieldsConfig == null ? void 0 : formFieldsConfig.map((c2) => {
37933
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Controller, {
38016
+ const formValues = watch();
38017
+ const formFieldsConfig = useFieldsConfig(config, formConfig, resourceId);
38018
+ const fields = formFieldsConfig == null ? void 0 : formFieldsConfig.map((fieldConfig) => {
38019
+ var _a;
38020
+ const isDisplay = ((_a = fieldConfig.condition) == null ? void 0 : _a.call(fieldConfig, formValues, get$3(formValues, fieldConfig.path.join(".")))) !== false;
38021
+ return isDisplay ? /* @__PURE__ */ jsxRuntimeExports.jsx(Controller, {
37934
38022
  control,
37935
- name: c2.path.join("."),
38023
+ name: fieldConfig.path.join("."),
37936
38024
  rules: {
37937
38025
  validate(value2) {
37938
38026
  const formValue = getValues();
37939
- if (!c2.validators || c2.validators.length === 0)
38027
+ if (!fieldConfig.validators || fieldConfig.validators.length === 0)
37940
38028
  return true;
37941
- for (const func of c2.validators) {
38029
+ for (const func of fieldConfig.validators) {
37942
38030
  const {
37943
38031
  isValid,
37944
38032
  errorMsg
37945
- } = func(value2, formValue);
38033
+ } = func(value2, formValue, FormType.FORM);
37946
38034
  if (!isValid)
37947
38035
  return errorMsg;
37948
38036
  }
@@ -37950,79 +38038,42 @@ const RefineFormContent = (props) => {
37950
38038
  }
37951
38039
  },
37952
38040
  render: ({
37953
- field: {
37954
- onChange,
37955
- onBlur,
37956
- value: value2,
37957
- name: name2
37958
- },
38041
+ field,
37959
38042
  fieldState
37960
38043
  }) => {
37961
- var _a, _b;
37962
- const formValue = getValues();
37963
- let ele = /* @__PURE__ */ jsxRuntimeExports.jsx(Fields.String, {
37964
- placeholder: c2.placeholder,
37965
- input: {
37966
- value: value2,
37967
- onChange,
37968
- onBlur,
37969
- name: name2,
37970
- onFocus: () => null
37971
- },
37972
- meta: {}
37973
- });
37974
- switch (c2.type) {
37975
- case "number":
37976
- ele = /* @__PURE__ */ jsxRuntimeExports.jsx(Fields.Integer, {
37977
- className: "c154n7ie",
37978
- placeholder: c2.placeholder,
37979
- input: {
37980
- value: value2,
37981
- onChange,
37982
- onBlur,
37983
- name: name2,
37984
- onFocus: () => null
37985
- },
37986
- meta: {}
37987
- });
37988
- }
37989
- if (action === "edit" && c2.disabledWhenEdit) {
37990
- ele = /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
37991
- children: value2
37992
- });
37993
- }
37994
- if (c2 == null ? void 0 : c2.render) {
37995
- ele = c2.render(value2, onChange, formValue, onBlur, action, control);
37996
- }
37997
- if (c2.helperText) {
37998
- ele = /* @__PURE__ */ jsxRuntimeExports.jsxs(Space, {
37999
- size: 4,
38000
- direction: "vertical",
38001
- className: "c1c9j4da",
38002
- children: [ele, /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
38003
- className: cx_default(Typo.Footnote.f2_regular, "cjxv8cf"),
38004
- children: c2.helperText
38005
- })]
38006
- });
38044
+ var _a2;
38045
+ const renderProps = {
38046
+ field,
38047
+ fieldConfig,
38048
+ action,
38049
+ control,
38050
+ trigger
38051
+ };
38052
+ let ele = null;
38053
+ if (fieldConfig == null ? void 0 : fieldConfig.render) {
38054
+ ele = fieldConfig.render(renderProps);
38055
+ } else {
38056
+ ele = renderCommonFormFiled(renderProps);
38007
38057
  }
38008
38058
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Item, {
38009
- label: c2.label,
38059
+ label: fieldConfig.label,
38010
38060
  colon: false,
38011
38061
  labelCol: {
38012
- flex: `0 0 ${((_a = config == null ? void 0 : config.formConfig) == null ? void 0 : _a.labelWidth) || "216px"}`
38062
+ flex: `0 0 ${(formConfig == null ? void 0 : formConfig.labelWidth) || "216px"}`
38013
38063
  },
38014
- help: (_b = fieldState.error) == null ? void 0 : _b.message,
38064
+ help: (_a2 = fieldState.error) == null ? void 0 : _a2.message,
38065
+ extra: fieldConfig.helperText,
38015
38066
  validateStatus: fieldState.invalid ? "error" : void 0,
38016
- "data-test-id": c2.key,
38067
+ "data-test-id": fieldConfig.key,
38017
38068
  children: ele
38018
- }, c2.key);
38069
+ }, fieldConfig.key);
38019
38070
  }
38020
- }, c2.key);
38071
+ }, fieldConfig.key) : null;
38021
38072
  });
38022
38073
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Space, {
38023
38074
  direction: "vertical",
38024
38075
  size: 16,
38025
- className: "c1xsnuvk",
38076
+ className: "c1c9j4da",
38026
38077
  children: [fields, /* @__PURE__ */ jsxRuntimeExports.jsx(FormErrorAlert, {
38027
38078
  errorMsgs: errorMsgs || [],
38028
38079
  style: {
@@ -38032,6 +38083,59 @@ const RefineFormContent = (props) => {
38032
38083
  })]
38033
38084
  });
38034
38085
  };
38086
+ function immutableSet(obj, path2, value2) {
38087
+ return setWith(clone(obj), path2, value2, clone);
38088
+ }
38089
+ function usePathMap(options) {
38090
+ const { pathMap, transformInitValues, transformApplyValues } = options;
38091
+ return {
38092
+ /**
38093
+ * Transforms initial values by mapping paths from source to target structure
38094
+ * @param values Initial values to transform
38095
+ * @returns Transformed values with updated paths
38096
+ */
38097
+ transformInitValues(values) {
38098
+ const initValues = values._rawYaml || values;
38099
+ let result = initValues;
38100
+ for (const { from, to } of pathMap || []) {
38101
+ result = immutableSet(initValues, to, get$3(initValues, from));
38102
+ const fromPath = [...from];
38103
+ const lastKey = fromPath.pop();
38104
+ if (lastKey) {
38105
+ const obj = get$3(result, fromPath.join("."));
38106
+ if (obj && typeof obj === "object") {
38107
+ delete obj[lastKey];
38108
+ }
38109
+ }
38110
+ }
38111
+ return (transformInitValues == null ? void 0 : transformInitValues(result)) || result;
38112
+ },
38113
+ /**
38114
+ * Transforms values back to original structure before applying/saving
38115
+ * @param values Values to transform back
38116
+ * @returns Transformed values in original structure
38117
+ */
38118
+ transformApplyValues(values) {
38119
+ let result = values;
38120
+ for (const { from, to } of pathMap || []) {
38121
+ result = immutableSet(
38122
+ values,
38123
+ from,
38124
+ get$3(result, to)
38125
+ );
38126
+ const toPath = [...to];
38127
+ const lastKey = toPath.pop();
38128
+ if (lastKey) {
38129
+ const obj = get$3(result, toPath.join("."));
38130
+ if (obj && typeof obj === "object") {
38131
+ delete obj[lastKey];
38132
+ }
38133
+ }
38134
+ }
38135
+ return (transformApplyValues == null ? void 0 : transformApplyValues(result)) || result;
38136
+ }
38137
+ };
38138
+ }
38035
38139
  var isArray$4 = Array.isArray;
38036
38140
  var isArray_1 = isArray$4;
38037
38141
  var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
@@ -38669,8 +38773,12 @@ const useForm = ({
38669
38773
  };
38670
38774
  };
38671
38775
  const useRefineForm = (props) => {
38672
- var _a, _b, _c;
38673
- const { config, id, refineProps } = props;
38776
+ const { formConfig, config, id, refineProps } = props;
38777
+ const { transformInitValues, transformApplyValues } = usePathMap({
38778
+ pathMap: formConfig == null ? void 0 : formConfig.pathMap,
38779
+ transformInitValues: formConfig == null ? void 0 : formConfig.transformInitValues,
38780
+ transformApplyValues: formConfig == null ? void 0 : formConfig.transformApplyValues
38781
+ });
38674
38782
  const [responseErrorMsgs, setResponseErrorMsgs] = useState([]);
38675
38783
  const { i18n: i18n2 } = useTranslation();
38676
38784
  const result = useForm({
@@ -38679,14 +38787,14 @@ const useRefineForm = (props) => {
38679
38787
  refineCoreProps: {
38680
38788
  errorNotification: false,
38681
38789
  successNotification: () => {
38682
- var _a2;
38790
+ var _a;
38683
38791
  const formValue = result.getValues();
38684
38792
  return {
38685
38793
  message: i18n2.t(
38686
38794
  id ? "dovetail.edit_resource_success" : "dovetail.create_success_toast",
38687
38795
  {
38688
38796
  kind: transformResourceKindInSentence(config.displayName || config.kind, i18n2.language),
38689
- name: (_a2 = formValue.metadata) == null ? void 0 : _a2.name,
38797
+ name: (_a = formValue.metadata) == null ? void 0 : _a.name,
38690
38798
  interpolation: { escapeValue: false }
38691
38799
  }
38692
38800
  ).trim(),
@@ -38701,20 +38809,20 @@ const useRefineForm = (props) => {
38701
38809
  ...refineProps
38702
38810
  },
38703
38811
  defaultValues: config == null ? void 0 : config.initValue,
38704
- transformApplyValues: (_a = config.formConfig) == null ? void 0 : _a.transformApplyValues,
38705
- transformInitValues: (_b = config.formConfig) == null ? void 0 : _b.transformInitValues,
38706
- ...(_c = config.formConfig) == null ? void 0 : _c.useFormProps
38812
+ transformApplyValues,
38813
+ transformInitValues,
38814
+ ...formConfig == null ? void 0 : formConfig.useFormProps
38707
38815
  });
38708
38816
  useEffect(() => {
38709
- var _a2, _b2;
38710
- const response = (_a2 = result.refineCore.mutationResult.error) == null ? void 0 : _a2.response;
38817
+ var _a, _b;
38818
+ const response = (_a = result.refineCore.mutationResult.error) == null ? void 0 : _a.response;
38711
38819
  if (response && !(response == null ? void 0 : response.bodyUsed)) {
38712
- (_b2 = response.json) == null ? void 0 : _b2.call(response).then((body) => {
38713
- var _a3, _b3;
38714
- setResponseErrorMsgs([].concat(((_b3 = (_a3 = config.formConfig) == null ? void 0 : _a3.formatError) == null ? void 0 : _b3.call(_a3, body)) || getCommonErrors(body, i18n2)));
38820
+ (_b = response.json) == null ? void 0 : _b.call(response).then((body) => {
38821
+ var _a2;
38822
+ setResponseErrorMsgs([].concat(((_a2 = formConfig == null ? void 0 : formConfig.formatError) == null ? void 0 : _a2.call(formConfig, body)) || getCommonErrors(body, i18n2)));
38715
38823
  });
38716
38824
  }
38717
- }, [config.formConfig, result, i18n2]);
38825
+ }, [formConfig, result, i18n2]);
38718
38826
  return { formResult: result, responseErrorMsgs };
38719
38827
  };
38720
38828
  const index_2ivb33 = "";
@@ -38725,7 +38833,7 @@ const Separator = () => {
38725
38833
  });
38726
38834
  };
38727
38835
  const MonacoYamlEditor = React__default.lazy(() => Promise.resolve().then(() => MonacoYamlEditor$2));
38728
- const MonacoYamlDiffEditor = React__default.lazy(() => import("./MonacoYamlDiffEditor-fec09973.js"));
38836
+ const MonacoYamlDiffEditor = React__default.lazy(() => import("./MonacoYamlDiffEditor-b8952aa0.js"));
38729
38837
  const YamlEditorComponent = forwardRef(
38730
38838
  function YamlEditorComponent2(props, ref) {
38731
38839
  const {
@@ -39192,7 +39300,7 @@ const useYamlForm = ({
39192
39300
  const { path: path2, validators } = rule2;
39193
39301
  const value2 = get$3(formValue, path2);
39194
39302
  for (const validator of validators || []) {
39195
- const { isValid, errorMsg } = validator(value2, formValue);
39303
+ const { isValid, errorMsg } = validator(value2, formValue, FormType.YAML);
39196
39304
  if (!isValid) {
39197
39305
  errorMap[path2.join(".")] = `${errorMsg}(${path2.join(".")})`;
39198
39306
  break;
@@ -39329,6 +39437,7 @@ function YamlForm(props) {
39329
39437
  schemaStrategy = "Optional",
39330
39438
  isShowLayout = true,
39331
39439
  useFormProps,
39440
+ config,
39332
39441
  transformInitValues,
39333
39442
  transformApplyValues,
39334
39443
  onSaveButtonPropsChange,
@@ -39340,8 +39449,6 @@ function YamlForm(props) {
39340
39449
  resource
39341
39450
  } = useResource();
39342
39451
  const action = actionFromProps || actionFromResource;
39343
- const configs = useContext(ConfigsContext);
39344
- const config = configs[(resource == null ? void 0 : resource.name) || ""];
39345
39452
  const {
39346
39453
  t: t2,
39347
39454
  i18n: i18n2
@@ -39457,6 +39564,159 @@ function YamlForm(props) {
39457
39564
  })
39458
39565
  });
39459
39566
  }
39567
+ function RefineFormContainer({
39568
+ id,
39569
+ config,
39570
+ customYamlFormProps,
39571
+ formConfig,
39572
+ isYamlMode,
39573
+ onSuccess,
39574
+ onError,
39575
+ onSaveButtonPropsChange
39576
+ }) {
39577
+ const action = id ? "edit" : "create";
39578
+ const fieldsConfig = useFieldsConfig(config, formConfig, id);
39579
+ const refineFormResult = useRefineForm({
39580
+ config,
39581
+ id,
39582
+ refineProps: {
39583
+ onMutationSuccess: () => {
39584
+ onSuccess == null ? void 0 : onSuccess();
39585
+ },
39586
+ onMutationError() {
39587
+ onError == null ? void 0 : onError();
39588
+ },
39589
+ redirect: false,
39590
+ ...formConfig == null ? void 0 : formConfig.refineCoreProps
39591
+ }
39592
+ });
39593
+ const yamlFormProps = useMemo(() => {
39594
+ const transformApplyValues = (formConfig == null ? void 0 : formConfig.transformApplyValues) || ((v) => v);
39595
+ return {
39596
+ ...customYamlFormProps,
39597
+ config,
39598
+ transformInitValues: void 0,
39599
+ transformApplyValues: void 0,
39600
+ initialValuesForCreate: transformApplyValues(
39601
+ refineFormResult.formResult.getValues()
39602
+ ),
39603
+ initialValuesForEdit: transformApplyValues(refineFormResult.formResult.getValues()),
39604
+ id,
39605
+ action,
39606
+ isShowLayout: false,
39607
+ useFormProps: {
39608
+ redirect: false
39609
+ },
39610
+ rules: fieldsConfig == null ? void 0 : fieldsConfig.map((config2) => ({
39611
+ path: config2.path,
39612
+ validators: config2.validators
39613
+ })),
39614
+ onSaveButtonPropsChange,
39615
+ onErrorsChange(errors) {
39616
+ if (errors.length) {
39617
+ onError == null ? void 0 : onError();
39618
+ }
39619
+ },
39620
+ onFinish: onSuccess
39621
+ };
39622
+ }, [
39623
+ action,
39624
+ customYamlFormProps,
39625
+ fieldsConfig,
39626
+ config,
39627
+ id,
39628
+ refineFormResult,
39629
+ formConfig,
39630
+ onSaveButtonPropsChange,
39631
+ onSuccess,
39632
+ onError
39633
+ ]);
39634
+ useEffect(() => {
39635
+ if (!isYamlMode) {
39636
+ onSaveButtonPropsChange == null ? void 0 : onSaveButtonPropsChange(refineFormResult.formResult.saveButtonProps);
39637
+ }
39638
+ }, [isYamlMode, onSaveButtonPropsChange]);
39639
+ if (isYamlMode) {
39640
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(YamlForm, { ...yamlFormProps });
39641
+ }
39642
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
39643
+ !(formConfig == null ? void 0 : formConfig.isDisabledChangeMode) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
39644
+ Alert,
39645
+ {
39646
+ type: "warning",
39647
+ message: i18n.t("dovetail.change_form_mode_alert"),
39648
+ style: { marginBottom: "16px" }
39649
+ }
39650
+ ) : void 0,
39651
+ (formConfig == null ? void 0 : formConfig.renderForm) ? formConfig == null ? void 0 : formConfig.renderForm() : /* @__PURE__ */ jsxRuntimeExports.jsx(
39652
+ RefineFormContent,
39653
+ {
39654
+ formResult: refineFormResult.formResult,
39655
+ config,
39656
+ formConfig,
39657
+ errorMsgs: refineFormResult.responseErrorMsgs,
39658
+ resourceId: id
39659
+ }
39660
+ )
39661
+ ] });
39662
+ }
39663
+ function YamlFormContainer({
39664
+ id,
39665
+ customYamlFormProps,
39666
+ config,
39667
+ formConfig,
39668
+ onSuccess,
39669
+ onError,
39670
+ onSaveButtonPropsChange
39671
+ }) {
39672
+ const action = id ? "edit" : "create";
39673
+ const {
39674
+ transformInitValues,
39675
+ transformApplyValues
39676
+ } = usePathMap({
39677
+ pathMap: formConfig == null ? void 0 : formConfig.pathMap,
39678
+ transformInitValues: formConfig == null ? void 0 : formConfig.transformInitValues,
39679
+ transformApplyValues: (formConfig == null ? void 0 : formConfig.transformApplyValues) || ((v) => v)
39680
+ });
39681
+ const yamlFormProps = useMemo(
39682
+ () => {
39683
+ return {
39684
+ ...customYamlFormProps,
39685
+ config,
39686
+ transformInitValues,
39687
+ transformApplyValues,
39688
+ initialValuesForCreate: (customYamlFormProps == null ? void 0 : customYamlFormProps.initialValuesForCreate) || config.initValue,
39689
+ initialValuesForEdit: void 0,
39690
+ id,
39691
+ action,
39692
+ isShowLayout: false,
39693
+ useFormProps: {
39694
+ redirect: false
39695
+ },
39696
+ rules: void 0,
39697
+ onSaveButtonPropsChange,
39698
+ onErrorsChange(errors) {
39699
+ if (errors.length) {
39700
+ onError == null ? void 0 : onError();
39701
+ }
39702
+ },
39703
+ onFinish: onSuccess
39704
+ };
39705
+ },
39706
+ [
39707
+ id,
39708
+ action,
39709
+ customYamlFormProps,
39710
+ config,
39711
+ transformInitValues,
39712
+ transformApplyValues,
39713
+ onSuccess,
39714
+ onError,
39715
+ onSaveButtonPropsChange
39716
+ ]
39717
+ );
39718
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(YamlForm, { ...yamlFormProps });
39719
+ }
39460
39720
  const FormModal_64brhp = "";
39461
39721
  const FormDescStyle = "f1nltbcu";
39462
39722
  const ErrorStyle = "e1qgcca6";
@@ -39490,11 +39750,11 @@ function ConfirmModal({
39490
39750
  });
39491
39751
  }
39492
39752
  function FormModal(props) {
39493
- var _a, _b, _c, _d, _e, _f;
39753
+ var _a, _b, _c;
39494
39754
  const {
39495
39755
  resource: resourceFromProps,
39496
39756
  id,
39497
- renderForm
39757
+ yamlFormProps: customYamlFormProps
39498
39758
  } = props;
39499
39759
  const {
39500
39760
  i18n: i18n2
@@ -39503,74 +39763,17 @@ function FormModal(props) {
39503
39763
  resource
39504
39764
  } = useResource();
39505
39765
  const configs = useContext(ConfigsContext);
39506
- const [yamlSaveButtonProps, setYamlSaveButtonProps] = useState({});
39766
+ const [saveButtonProps, setSaveButtonProps] = useState({});
39507
39767
  const [isError, setIsError] = useState(false);
39508
- const [mode, setMode] = useState(
39509
- "form"
39510
- /* Form */
39511
- );
39512
- const isYamlMode = mode === "yaml";
39768
+ const [mode, setMode] = useState(FormMode.FORM);
39769
+ const isYamlMode = mode === FormMode.YAML;
39513
39770
  const popModal = usePopModal();
39514
39771
  const pushModal = usePushModal();
39515
39772
  const config = configs[resourceFromProps || (resource == null ? void 0 : resource.name) || ""];
39516
- const isDisabledChangeMode = (_a = config.formConfig) == null ? void 0 : _a.isDisabledChangeMode;
39773
+ const isDisabledChangeMode = config.formConfig && "isDisabledChangeMode" in config.formConfig && config.formConfig.isDisabledChangeMode;
39517
39774
  const okText = i18n2.t(id ? "dovetail.save" : "dovetail.create");
39518
39775
  const action = id ? "edit" : "create";
39519
- const fieldsConfig = useFieldsConfig(config, id);
39520
- const refineFormResult = useRefineForm({
39521
- config,
39522
- id,
39523
- refineProps: {
39524
- onMutationSuccess: () => {
39525
- popModal();
39526
- },
39527
- redirect: false,
39528
- ...(_b = config.formConfig) == null ? void 0 : _b.refineCoreProps
39529
- }
39530
- });
39531
- const yamlFormProps = useMemo(() => {
39532
- var _a2, _b2, _c2;
39533
- const transformApplyValues = ((_a2 = config.formConfig) == null ? void 0 : _a2.transformApplyValues) || ((v) => v);
39534
- return {
39535
- ...props.formProps,
39536
- transformInitValues: isYamlMode ? void 0 : (_b2 = config.formConfig) == null ? void 0 : _b2.transformInitValues,
39537
- transformApplyValues: isYamlMode ? void 0 : transformApplyValues,
39538
- initialValuesForCreate: isYamlMode ? transformApplyValues(refineFormResult.formResult.getValues()) : ((_c2 = props.formProps) == null ? void 0 : _c2.initialValuesForCreate) || (config == null ? void 0 : config.initValue),
39539
- initialValuesForEdit: isYamlMode ? transformApplyValues(refineFormResult.formResult.getValues()) : void 0,
39540
- id,
39541
- action,
39542
- isShowLayout: false,
39543
- useFormProps: {
39544
- redirect: false
39545
- },
39546
- rules: isYamlMode ? fieldsConfig == null ? void 0 : fieldsConfig.map((config2) => ({
39547
- path: config2.path,
39548
- validators: config2.validators
39549
- })) : void 0,
39550
- onSaveButtonPropsChange: setYamlSaveButtonProps,
39551
- onErrorsChange(errors) {
39552
- setIsError(!!errors.length);
39553
- },
39554
- onFinish: popModal
39555
- };
39556
- }, [props.formProps, (_c = config.formConfig) == null ? void 0 : _c.transformInitValues, (_d = config.formConfig) == null ? void 0 : _d.transformApplyValues, config == null ? void 0 : config.initValue, id, action, refineFormResult.formResult, isYamlMode, fieldsConfig, popModal]);
39557
- const isYamlForm = !((_e = config.formConfig) == null ? void 0 : _e.fields);
39558
- const formEle = (() => {
39559
- if (renderForm) {
39560
- return renderForm(yamlFormProps);
39561
- }
39562
- if (isYamlForm || isYamlMode)
39563
- return /* @__PURE__ */ jsxRuntimeExports.jsx(YamlForm, {
39564
- ...yamlFormProps
39565
- });
39566
- return /* @__PURE__ */ jsxRuntimeExports.jsx(RefineFormContent, {
39567
- formResult: refineFormResult.formResult,
39568
- config,
39569
- errorMsgs: refineFormResult.responseErrorMsgs,
39570
- resourceId: id
39571
- });
39572
- })();
39573
- const saveButtonProps = isYamlForm || isYamlMode ? yamlSaveButtonProps : refineFormResult.formResult.saveButtonProps;
39776
+ const isYamlForm = ((_a = config.formConfig) == null ? void 0 : _a.formType) === FormType.YAML;
39574
39777
  const onCancel = useCallback(() => {
39575
39778
  popModal();
39576
39779
  }, [popModal]);
@@ -39580,15 +39783,12 @@ function FormModal(props) {
39580
39783
  (_a2 = saveButtonProps.onClick) == null ? void 0 : _a2.call(saveButtonProps, e2);
39581
39784
  }, [saveButtonProps]);
39582
39785
  const onChangeMode = useCallback((value2) => {
39583
- if (value2 === "form") {
39786
+ if (value2 === FormMode.FORM) {
39584
39787
  pushModal({
39585
39788
  component: ConfirmModal,
39586
39789
  props: {
39587
39790
  onOk: () => {
39588
- setMode(
39589
- "form"
39590
- /* Form */
39591
- );
39791
+ setMode(FormMode.FORM);
39592
39792
  }
39593
39793
  }
39594
39794
  });
@@ -39596,17 +39796,18 @@ function FormModal(props) {
39596
39796
  setMode(value2);
39597
39797
  }
39598
39798
  }, [pushModal]);
39599
- const errorText = (() => {
39600
- if (!!refineFormResult.responseErrorMsgs.length || isError) {
39799
+ const errorText = useMemo(() => {
39800
+ if (isError) {
39601
39801
  return i18n2.t(id ? "dovetail.save_failed" : "dovetail.create_failed");
39602
39802
  }
39603
- })();
39803
+ return "";
39804
+ }, [isError, id, i18n2]);
39604
39805
  const title = useMemo(() => {
39605
- var _a2, _b2, _c2, _d2;
39806
+ var _a2, _b2, _c2, _d;
39606
39807
  if (typeof ((_a2 = config.formConfig) == null ? void 0 : _a2.formTitle) === "string")
39607
39808
  return (_b2 = config.formConfig) == null ? void 0 : _b2.formTitle;
39608
39809
  if (typeof ((_c2 = config.formConfig) == null ? void 0 : _c2.formTitle) === "function") {
39609
- return (_d2 = config.formConfig) == null ? void 0 : _d2.formTitle(action);
39810
+ return (_d = config.formConfig) == null ? void 0 : _d.formTitle(action);
39610
39811
  }
39611
39812
  const label2 = config.displayName || (config == null ? void 0 : config.kind);
39612
39813
  return i18n2.t(id ? "dovetail.edit_resource" : "dovetail.create_resource", {
@@ -39614,14 +39815,41 @@ function FormModal(props) {
39614
39815
  });
39615
39816
  }, [action, config.formConfig, config.displayName, config == null ? void 0 : config.kind, i18n2, id]);
39616
39817
  const desc = useMemo(() => {
39617
- var _a2, _b2, _c2, _d2;
39818
+ var _a2, _b2, _c2, _d;
39618
39819
  if (typeof ((_a2 = config.formConfig) == null ? void 0 : _a2.formDesc) === "string")
39619
39820
  return (_b2 = config.formConfig) == null ? void 0 : _b2.formDesc;
39620
39821
  if (typeof ((_c2 = config.formConfig) == null ? void 0 : _c2.formDesc) === "function") {
39621
- return (_d2 = config.formConfig) == null ? void 0 : _d2.formDesc(action);
39822
+ return (_d = config.formConfig) == null ? void 0 : _d.formDesc(action);
39622
39823
  }
39623
39824
  return "";
39624
39825
  }, [action, config.formConfig]);
39826
+ const formEle = useMemo(() => {
39827
+ var _a2;
39828
+ const commonFormProps = {
39829
+ id,
39830
+ config,
39831
+ customYamlFormProps,
39832
+ onSaveButtonPropsChange: setSaveButtonProps,
39833
+ onError: () => {
39834
+ setIsError(true);
39835
+ },
39836
+ onSuccess: () => {
39837
+ setIsError(false);
39838
+ popModal();
39839
+ }
39840
+ };
39841
+ if (config.formConfig && (((_a2 = config.formConfig) == null ? void 0 : _a2.formType) === FormType.FORM || "fields" in config.formConfig)) {
39842
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(RefineFormContainer, {
39843
+ ...commonFormProps,
39844
+ isYamlMode,
39845
+ formConfig: config.formConfig
39846
+ });
39847
+ }
39848
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(YamlFormContainer, {
39849
+ ...commonFormProps,
39850
+ formConfig: config.formConfig
39851
+ });
39852
+ }, [id, customYamlFormProps, config, isYamlMode, popModal, setSaveButtonProps]);
39625
39853
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Modal, {
39626
39854
  className: cx_default(FullscreenModalStyle),
39627
39855
  style: {
@@ -39632,21 +39860,10 @@ function FormModal(props) {
39632
39860
  className: TitleWrapperStyle,
39633
39861
  children: [/* @__PURE__ */ jsxRuntimeExports.jsx("span", {
39634
39862
  children: title
39635
- }), !(isYamlForm || isDisabledChangeMode) ? /* @__PURE__ */ jsxRuntimeExports.jsx(SegmentControl, {
39636
- style: {
39637
- fontWeight: "normal"
39638
- },
39639
- value: mode,
39640
- options: [{
39641
- value: "form",
39642
- label: i18n2.t("dovetail.form")
39643
- }, {
39644
- value: "yaml",
39645
- label: i18n2.t("dovetail.yaml")
39646
- }],
39647
- onChange: (val) => {
39648
- onChangeMode(val);
39649
- }
39863
+ }), ((_b = config.formConfig) == null ? void 0 : _b.formType) === FormType.FORM ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormModeSegmentControl, {
39864
+ formConfig: config.formConfig,
39865
+ mode,
39866
+ onChangeMode
39650
39867
  }) : null]
39651
39868
  }),
39652
39869
  error: errorText ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
@@ -39655,7 +39872,7 @@ function FormModal(props) {
39655
39872
  }) : "",
39656
39873
  okButtonProps: {
39657
39874
  ...saveButtonProps,
39658
- children: (_f = config.formConfig) == null ? void 0 : _f.saveButtonText,
39875
+ children: (_c = config.formConfig) == null ? void 0 : _c.saveButtonText,
39659
39876
  onClick: onOk
39660
39877
  },
39661
39878
  closeIcon: /* @__PURE__ */ jsxRuntimeExports.jsx(CloseCircleFilled$1, {}),
@@ -39666,12 +39883,6 @@ function FormModal(props) {
39666
39883
  children: [desc ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
39667
39884
  className: FormDescStyle,
39668
39885
  children: desc
39669
- }) : void 0, !isYamlForm && mode === "form" && !isDisabledChangeMode ? /* @__PURE__ */ jsxRuntimeExports.jsx(Alert, {
39670
- type: "warning",
39671
- message: i18n2.t("dovetail.change_form_mode_alert"),
39672
- style: {
39673
- marginBottom: "16px"
39674
- }
39675
39886
  }) : void 0, formEle]
39676
39887
  });
39677
39888
  }
@@ -39726,10 +39937,11 @@ function ResourceForm(props) {
39726
39937
  return {
39727
39938
  initialValues: getInitialValues(config),
39728
39939
  transformInitValues: (_a2 = config.formConfig) == null ? void 0 : _a2.transformInitValues,
39729
- transformApplyValues: (_b = config.formConfig) == null ? void 0 : _b.transformApplyValues
39940
+ transformApplyValues: (_b = config.formConfig) == null ? void 0 : _b.transformApplyValues,
39941
+ config
39730
39942
  };
39731
39943
  }, [config]);
39732
- if ((_a = config.formConfig) == null ? void 0 : _a.fields) {
39944
+ if (((_a = config.formConfig) == null ? void 0 : _a.formType) === FormType.FORM) {
39733
39945
  return /* @__PURE__ */ jsxRuntimeExports.jsx(RefineFormPage, { config });
39734
39946
  }
39735
39947
  return /* @__PURE__ */ jsxRuntimeExports.jsx(YamlForm, { ...formProps });
@@ -39742,7 +39954,7 @@ function ResourceCRUD(props) {
39742
39954
  /* @__PURE__ */ jsxRuntimeExports.jsx(Route, { path: `${urlPrefix}/${config.name}`, exact: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResourceList, { config }) }),
39743
39955
  !config.noShow ? /* @__PURE__ */ jsxRuntimeExports.jsx(Route, { path: `${urlPrefix}/${config.name}/show`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResourceShow, { config }) }) : null,
39744
39956
  // the modals would render in ModalStack
39745
- ((_a = config.formConfig) == null ? void 0 : _a.formType) === FormType.PAGE ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
39957
+ ((_a = config.formConfig) == null ? void 0 : _a.formContainerType) === FormContainerType.PAGE ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
39746
39958
  /* @__PURE__ */ jsxRuntimeExports.jsx(Route, { path: `${urlPrefix}/${config.name}/create`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResourceForm, { config }) }),
39747
39959
  /* @__PURE__ */ jsxRuntimeExports.jsx(Route, { path: `${urlPrefix}/${config.name}/edit`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResourceForm, { config }) })
39748
39960
  ] }) : null
@@ -41319,7 +41531,7 @@ export {
41319
41531
  CronjobJobsTable as ay,
41320
41532
  KeyValue as az,
41321
41533
  useSchema as b,
41322
- PodLog as b$,
41534
+ TextTags as b$,
41323
41535
  PodSelectorField as b0,
41324
41536
  PortsTableField as b1,
41325
41537
  DurationField as b2,
@@ -41348,15 +41560,15 @@ export {
41348
41560
  useNamespacesFilter as bP,
41349
41561
  NamespacesFilter as bQ,
41350
41562
  FormModal as bR,
41351
- RefineFormContent as bS,
41352
- RefineFormPage as bT,
41353
- SchemaStrategy as bU,
41354
- YamlForm as bV,
41355
- useRefineForm as bW,
41356
- ServiceInClusterAccessComponent as bX,
41357
- ServiceOutClusterAccessComponent as bY,
41358
- Tags as bZ,
41359
- TextTags as b_,
41563
+ renderCommonFormFiled as bS,
41564
+ RefineFormContent as bT,
41565
+ RefineFormPage as bU,
41566
+ SchemaStrategy as bV,
41567
+ YamlForm as bW,
41568
+ useRefineForm as bX,
41569
+ ServiceInClusterAccessComponent as bY,
41570
+ ServiceOutClusterAccessComponent as bZ,
41571
+ Tags as b_,
41360
41572
  PVVolumeModeField as ba,
41361
41573
  PVAccessModeField as bb,
41362
41574
  PVCPodsField as bc,
@@ -41384,83 +41596,86 @@ export {
41384
41596
  NetworkPolicyIngressRulesGroup as by,
41385
41597
  NetworkPolicyEgressRulesGroup as bz,
41386
41598
  useDeleteModal as c,
41387
- StorageClassModel as c$,
41388
- NetworkPolicyRulesViewer as c0,
41389
- PVVolumeModeDisplay as c1,
41390
- Tabs as c2,
41391
- ResourceSelect as c3,
41392
- SocketStatus as c4,
41393
- Shell as c5,
41394
- PodShellModal as c6,
41395
- PodShell as c7,
41396
- ResourceTable as c8,
41397
- ErrorWrapper as c9,
41398
- PV_INIT_VALUE as cA,
41399
- PVC_INIT_VALUE as cB,
41400
- ResourceState as cC,
41401
- AccessControlAuth as cD,
41402
- Dovetail as cE,
41403
- RESOURCE_GROUP as cF,
41404
- FormType as cG,
41405
- ComponentContext as cH,
41406
- GlobalStoreContext as cI,
41407
- ConfigsContext as cJ,
41408
- IngressModel as cK,
41409
- NetworkPolicyModel as cL,
41410
- JobModel as cM,
41411
- WorkloadModel as cN,
41412
- WorkloadBaseModel as cO,
41413
- PodModel as cP,
41414
- PodMetricsModel as cQ,
41415
- ResourceModel as cR,
41416
- CronJobModel as cS,
41417
- EventModel as cT,
41418
- DeploymentModel as cU,
41419
- DaemonSetModel as cV,
41420
- StatefulSetModel as cW,
41421
- ServiceTypeEnum as cX,
41422
- ServiceModel as cY,
41423
- NodeRole as cZ,
41424
- NodeModel as c_,
41425
- ErrorContentType as ca,
41426
- BASE_INIT_VALUE as cb,
41427
- DEPLOYMENT_INIT_VALUE as cc,
41428
- CRONJOB_INIT_VALUE as cd,
41429
- DAEMONSET_INIT_VALUE as ce,
41430
- JOB_INIT_VALUE as cf,
41431
- STATEFULSET_INIT_VALUE as cg,
41432
- POD_INIT_VALUE as ch,
41433
- SERVICE_CLUSTER_IP_INIT_VALUE as ci,
41434
- SERVICE_NODE_PORT_INIT_VALUE as cj,
41435
- SERVICE_LOAD_BALANCER_INIT_VALUE as ck,
41436
- SERVICE_EXTERNAL_NAME_INIT_VALUE as cl,
41437
- SERVICE_HEADLESS_INIT_VALUE as cm,
41438
- INGRESS_INIT_VALUE as cn,
41439
- NETWORK_POLICY_INIT_VALUE as co,
41440
- CONFIG_MAP_INIT_VALUE as cp,
41441
- SERVER_INSTANCE_INIT_VALUE as cq,
41442
- REDEPLOY_TIMESTAMP_KEY as cr,
41443
- SECRET_OPAQUE_INIT_VALUE as cs,
41444
- SECRET_IMAGE_REPO_INIT_VALUE as ct,
41445
- SECRET_BASIC_AUTH_INIT_VALUE as cu,
41446
- SECRET_SSH_AUTH_INIT_VALUE as cv,
41447
- SECRET_TLS_INIT_VALUE as cw,
41448
- SECRET_CUSTOM_INIT_VALUE as cx,
41449
- NODE_INIT_VALUE as cy,
41450
- STORAGE_CLASS_INIT_VALUE as cz,
41599
+ ServiceModel as c$,
41600
+ PodLog as c0,
41601
+ NetworkPolicyRulesViewer as c1,
41602
+ PVVolumeModeDisplay as c2,
41603
+ Tabs as c3,
41604
+ ResourceSelect as c4,
41605
+ SocketStatus as c5,
41606
+ Shell as c6,
41607
+ PodShellModal as c7,
41608
+ PodShell as c8,
41609
+ ResourceTable as c9,
41610
+ STORAGE_CLASS_INIT_VALUE as cA,
41611
+ PV_INIT_VALUE as cB,
41612
+ PVC_INIT_VALUE as cC,
41613
+ ResourceState as cD,
41614
+ AccessControlAuth as cE,
41615
+ Dovetail as cF,
41616
+ RESOURCE_GROUP as cG,
41617
+ FormContainerType as cH,
41618
+ FormType as cI,
41619
+ FormMode as cJ,
41620
+ ComponentContext as cK,
41621
+ GlobalStoreContext as cL,
41622
+ ConfigsContext as cM,
41623
+ IngressModel as cN,
41624
+ NetworkPolicyModel as cO,
41625
+ JobModel as cP,
41626
+ WorkloadModel as cQ,
41627
+ WorkloadBaseModel as cR,
41628
+ PodModel as cS,
41629
+ PodMetricsModel as cT,
41630
+ ResourceModel as cU,
41631
+ CronJobModel as cV,
41632
+ EventModel as cW,
41633
+ DeploymentModel as cX,
41634
+ DaemonSetModel as cY,
41635
+ StatefulSetModel as cZ,
41636
+ ServiceTypeEnum as c_,
41637
+ ErrorWrapper as ca,
41638
+ ErrorContentType as cb,
41639
+ BASE_INIT_VALUE as cc,
41640
+ DEPLOYMENT_INIT_VALUE as cd,
41641
+ CRONJOB_INIT_VALUE as ce,
41642
+ DAEMONSET_INIT_VALUE as cf,
41643
+ JOB_INIT_VALUE as cg,
41644
+ STATEFULSET_INIT_VALUE as ch,
41645
+ POD_INIT_VALUE as ci,
41646
+ SERVICE_CLUSTER_IP_INIT_VALUE as cj,
41647
+ SERVICE_NODE_PORT_INIT_VALUE as ck,
41648
+ SERVICE_LOAD_BALANCER_INIT_VALUE as cl,
41649
+ SERVICE_EXTERNAL_NAME_INIT_VALUE as cm,
41650
+ SERVICE_HEADLESS_INIT_VALUE as cn,
41651
+ INGRESS_INIT_VALUE as co,
41652
+ NETWORK_POLICY_INIT_VALUE as cp,
41653
+ CONFIG_MAP_INIT_VALUE as cq,
41654
+ SERVER_INSTANCE_INIT_VALUE as cr,
41655
+ REDEPLOY_TIMESTAMP_KEY as cs,
41656
+ SECRET_OPAQUE_INIT_VALUE as ct,
41657
+ SECRET_IMAGE_REPO_INIT_VALUE as cu,
41658
+ SECRET_BASIC_AUTH_INIT_VALUE as cv,
41659
+ SECRET_SSH_AUTH_INIT_VALUE as cw,
41660
+ SECRET_TLS_INIT_VALUE as cx,
41661
+ SECRET_CUSTOM_INIT_VALUE as cy,
41662
+ NODE_INIT_VALUE as cz,
41451
41663
  dovetailRefineI18n as d,
41452
- PersistentVolumeModel as d0,
41453
- PersistentVolumeClaimModel as d1,
41454
- ProviderPlugins as d2,
41455
- ModelPlugin as d3,
41456
- modelPlugin as d4,
41457
- RelationPlugin as d5,
41458
- relationPlugin as d6,
41459
- generateValueFromSchema as d7,
41460
- generateSchemaTypeValue as d8,
41461
- resolveRef as d9,
41462
- getApiVersion as da,
41463
- pruneBeforeEdit as db,
41664
+ NodeRole as d0,
41665
+ NodeModel as d1,
41666
+ StorageClassModel as d2,
41667
+ PersistentVolumeModel as d3,
41668
+ PersistentVolumeClaimModel as d4,
41669
+ ProviderPlugins as d5,
41670
+ ModelPlugin as d6,
41671
+ modelPlugin as d7,
41672
+ RelationPlugin as d8,
41673
+ relationPlugin as d9,
41674
+ generateValueFromSchema as da,
41675
+ generateSchemaTypeValue as db,
41676
+ resolveRef as dc,
41677
+ getApiVersion as dd,
41678
+ pruneBeforeEdit as de,
41464
41679
  useFailedModal as e,
41465
41680
  NameSpaceColumnRenderer as f,
41466
41681
  WorkloadRestartsColumnRenderer as g,