@dovetail-v2/refine 0.3.33 → 0.3.35

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.
package/dist/refine.js CHANGED
@@ -7,13 +7,13 @@ var __publicField = (obj, key2, value2) => {
7
7
  import dayjs from "dayjs";
8
8
  import i18n from "i18next";
9
9
  import { w as warnOnce, g as getDefaults, a as warn, b as getI18n, s as setDefaults, d as setI18n, I as I18nContext, j as jsxRuntimeExports, u as useTranslation, c as cx_default, S as SocketStatus } from "./common-241b21f8.js";
10
- import { ResourceContext, matchResourceFromRoute, useResource, useDelete, useNavigation, useBreadcrumb, useList, CanAccess, useUpdate, useForm as useForm$2, pickNotDeprecated, useWarnAboutChange, useOne, useParsed, useGo, useCan, useTable, useDeleteMany, useShow, useRefineContext, useTranslate, flattenObjectKeys, useMenu, Refine } from "@refinedev/core";
10
+ import { ResourceContext, matchResourceFromRoute, useResource, useDelete, useNavigation, useBreadcrumb, useList, CanAccess, useUpdate, useForm as useForm$2, pickNotDeprecated, useWarnAboutChange, useParsed, useGo, useCan, useTable, useDeleteMany, useShow, useRefineContext, useTranslate, flattenObjectKeys, useMenu, Refine } from "@refinedev/core";
11
11
  import { parse, stringify } from "qs";
12
12
  import React, { createElement, isValidElement, cloneElement, Children, useContext, useCallback, createContext, useState, useEffect, useMemo, useRef, useImperativeHandle, forwardRef, Suspense, lazy, memo } from "react";
13
13
  import { useLocation, useHistory, useParams, matchPath, Link, Route, NavLink, Router } from "react-router-dom";
14
14
  import { usePushModal, usePopModal, DeleteDialog, Tag, RejectDialog, RejectDialogType, OverflowTooltip, Typo, Input, Select, AntdOption, Button, Form, Space, TextArea, kitContext, Loading, Table as Table$2, Pagination, Alert, ImmersiveDialog, SmallDialog, Fields, Units, Link as Link$1, Tooltip, Divider, Icon, Dropdown, Menu as Menu$1, LegacyModal, StatusCapsule, Popover, AntdTable, Upload, TableForm, ValidateTriggerType, AutoComplete, getOptions, DonutChart, SegmentControl, Checkbox, Tabs as Tabs$1, TabsTabPane, Col, Row, useMessage, SearchInput, Token, AntdSelectOptGroup, WizardDialog, MenuItemGroup, Layout as Layout$1, InputGroup, InputInteger, Time as Time$1, ModalStack, KitStoreProvider, ConfigProvider } from "@cloudtower/eagle";
15
15
  import { HierarchyTriangleRight16GrayIcon, HierarchyTriangleRight16BlueIcon, ClipboardCopy16GradientGrayIcon, ClipboardCopy16GradientBlueIcon, Retry16GradientGrayIcon, Retry16GradientBlueIcon, EditPen16GradientGrayIcon, EditPen16GradientBlueIcon, Showdiff16GradientGrayIcon, Showdiff16GradientBlueIcon, XmarkFailedSeriousWarningFill16RedIcon, EditPen16PrimaryIcon, Download16GradientBlueIcon, TrashBinDelete16Icon, MoreEllipsis324BoldSecondaryIcon, MoreEllipsis324BoldBlueIcon, MoreEllipsis316BoldBlueIcon, PlusAddCreateNew16BoldOntintIcon, ViewEye16GradientGrayIcon, EntityFilterIgnoreGradient16GrayIcon, InfoICircleFill16GrayIcon, InfoICircleFill16Gray70Icon, RecoverContinue16GradientBlueIcon, SuspendedPause16GradientBlueIcon, ArrowChevronLeft16BoldTertiaryIcon, ArrowChevronLeftSmall16BoldBlueIcon, OpenTerminal16GradientBlueIcon, ArrowChevronDown16BlueIcon, ArrowChevronUp16BlueIcon, Pause16GradientBlueIcon, EditPen16BlueIcon } from "@cloudtower/icons-react";
16
- import { first, get as get$2, cloneDeep, set, setWith, clone, debounce, isEqual as isEqual$1, isObject as isObject$4, uniq, omit as omit$1, merge, last, keyBy } from "lodash-es";
16
+ import { first, get as get$2, cloneDeep, set, setWith, clone, debounce, isEqual as isEqual$1, omit as omit$1, isObject as isObject$4, uniq, merge, last, keyBy } from "lodash-es";
17
17
  import yaml$2 from "js-yaml";
18
18
  import { useForm as useForm$1 } from "sunflower-antd";
19
19
  import { useLocalStorage } from "usehooks-ts";
@@ -622,6 +622,7 @@ const edit_form$1 = "Edit form";
622
622
  const data_expired$1 = "Data expired";
623
623
  const data_expired_body$1 = "The data in this form is no longer the latest version. To avoid saving errors, please discard this edit and reopen the form to edit again.";
624
624
  const data_expired_note$1 = "Your current entries will not be saved.";
625
+ const resource_version_conflict$1 = "The data in this form is no longer the latest version. Please discard this edit and reopen the form to edit again.";
625
626
  const abandon_edit$1 = "Discard edit";
626
627
  const exit_yaml_tip$1 = "If you go back to the form, any changes made to the YAML file will be lost.";
627
628
  const value_optional$1 = "Value (optional)";
@@ -903,6 +904,7 @@ const dovetail$1 = {
903
904
  data_expired: data_expired$1,
904
905
  data_expired_body: data_expired_body$1,
905
906
  data_expired_note: data_expired_note$1,
907
+ resource_version_conflict: resource_version_conflict$1,
906
908
  abandon_edit: abandon_edit$1,
907
909
  exit_yaml_tip: exit_yaml_tip$1,
908
910
  value_optional: value_optional$1,
@@ -1186,6 +1188,7 @@ const edit_form = "编辑表单";
1186
1188
  const data_expired = "数据已过期";
1187
1189
  const data_expired_body = "当前表单中的数据已不是最新版。为避免保存失败,请放弃本次编辑,并重新打开表单进行编辑。";
1188
1190
  const data_expired_note = "当前已填写内容将不会保留。";
1191
+ const resource_version_conflict = "当前表单中的数据已不是最新版,请放弃本次编辑,并重新打开表单进行编辑。";
1189
1192
  const abandon_edit = "放弃编辑";
1190
1193
  const exit_yaml_tip = "返回编辑表单,不会保留对 YAML 文件做出的所有更改。";
1191
1194
  const form = "表单";
@@ -1466,6 +1469,7 @@ const dovetail = {
1466
1469
  data_expired,
1467
1470
  data_expired_body,
1468
1471
  data_expired_note,
1472
+ resource_version_conflict,
1469
1473
  abandon_edit,
1470
1474
  exit_yaml_tip,
1471
1475
  form,
@@ -10689,26 +10693,6 @@ function usePathMap(options) {
10689
10693
  transformApplyValues
10690
10694
  };
10691
10695
  }
10692
- const useResourceVersionCheck = ({
10693
- queryResult
10694
- }) => {
10695
- var _a, _b, _c;
10696
- const initialResourceVersionRef = useRef();
10697
- const [isExpired, setIsExpired] = useState(false);
10698
- const currentResourceVersion = (_c = (_b = (_a = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a.data) == null ? void 0 : _b.metadata) == null ? void 0 : _c.resourceVersion;
10699
- useEffect(() => {
10700
- if (!currentResourceVersion)
10701
- return;
10702
- if (!initialResourceVersionRef.current) {
10703
- initialResourceVersionRef.current = currentResourceVersion;
10704
- return;
10705
- }
10706
- if (currentResourceVersion !== initialResourceVersionRef.current) {
10707
- setIsExpired(true);
10708
- }
10709
- }, [currentResourceVersion]);
10710
- return isExpired;
10711
- };
10712
10696
  function getInitialValues(resourceConfig) {
10713
10697
  return resourceConfig.initValue || {
10714
10698
  apiVersion: resourceConfig.apiVersion,
@@ -10717,42 +10701,6 @@ function getInitialValues(resourceConfig) {
10717
10701
  spec: {}
10718
10702
  };
10719
10703
  }
10720
- const button_1v659kh = "";
10721
- const WarningButtonStyle = "wwyz7ti";
10722
- const DataExpiredModal_eazxh6 = "";
10723
- const NoteStyle = "n609wlp";
10724
- function DataExpiredModal({
10725
- onAbandon
10726
- }) {
10727
- const {
10728
- t: t2
10729
- } = useTranslation();
10730
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(SmallDialog, {
10731
- title: t2("dovetail.data_expired"),
10732
- closable: false,
10733
- maskClosable: false,
10734
- cancelButtonProps: {
10735
- style: {
10736
- display: "none"
10737
- }
10738
- },
10739
- okText: t2("dovetail.abandon_edit"),
10740
- okButtonProps: {
10741
- className: WarningButtonStyle
10742
- },
10743
- onOk: (popModal) => {
10744
- popModal();
10745
- onAbandon();
10746
- },
10747
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx("div", {
10748
- className: Typo.Label.l2_regular,
10749
- children: t2("dovetail.data_expired_body")
10750
- }), /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
10751
- className: `${Typo.Label.l2_regular} ${NoteStyle}`,
10752
- children: t2("dovetail.data_expired_note")
10753
- })]
10754
- });
10755
- }
10756
10704
  const index_az4wrx = "";
10757
10705
  const WrapperStyle$5 = "w1akirqw";
10758
10706
  const TitleStyle$2 = "t30srnq";
@@ -11082,6 +11030,67 @@ function copyToClipboard(text) {
11082
11030
  document.execCommand("copy");
11083
11031
  document.body.removeChild(input);
11084
11032
  }
11033
+ const useGlobalStore = (name2 = "default") => {
11034
+ const globalStores = useContext(GlobalStoreContext);
11035
+ return globalStores[name2];
11036
+ };
11037
+ const ResourceVersionConflictRetryContext = createContext(null);
11038
+ function Retry409Provider({
11039
+ children
11040
+ }) {
11041
+ const initialResourceRef = useRef();
11042
+ return createElement(
11043
+ ResourceVersionConflictRetryContext.Provider,
11044
+ {
11045
+ value: initialResourceRef
11046
+ },
11047
+ children
11048
+ );
11049
+ }
11050
+ function use409Retry({
11051
+ action,
11052
+ dataProviderName,
11053
+ id,
11054
+ mutationMeta
11055
+ }) {
11056
+ const { t: t2 } = useTranslation();
11057
+ const globalStore = useGlobalStore(dataProviderName);
11058
+ const sharedInitialResourceRef = useContext(ResourceVersionConflictRetryContext);
11059
+ const localInitialResourceRef = useRef();
11060
+ const initialResourceRef = sharedInitialResourceRef || localInitialResourceRef;
11061
+ const isEditAction = action === "edit" || !!id;
11062
+ const captureInitialResource = useCallback((resource) => {
11063
+ var _a;
11064
+ if (!isEditAction || initialResourceRef.current || !resource) {
11065
+ return;
11066
+ }
11067
+ const rawResource = (_a = globalStore == null ? void 0 : globalStore.restoreItem) == null ? void 0 : _a.call(globalStore, resource);
11068
+ if (!rawResource) {
11069
+ return;
11070
+ }
11071
+ initialResourceRef.current = cloneDeep(rawResource);
11072
+ }, [globalStore, initialResourceRef, isEditAction]);
11073
+ const retryMutationMeta = useMemo(() => {
11074
+ const restMutationMeta = omit$1(mutationMeta, "resourceVersionConflictRetry");
11075
+ if (!isEditAction) {
11076
+ return restMutationMeta;
11077
+ }
11078
+ return {
11079
+ ...restMutationMeta,
11080
+ resourceVersionConflictRetry: {
11081
+ // refine 的 mutationMeta 在 hook 创建时就会固定;用 getter 让 provider 在保存瞬间读取最新的初始版本。
11082
+ get initialResource() {
11083
+ return initialResourceRef.current;
11084
+ },
11085
+ conflictMessage: t2("dovetail.resource_version_conflict")
11086
+ }
11087
+ };
11088
+ }, [initialResourceRef, isEditAction, mutationMeta, t2]);
11089
+ return {
11090
+ captureInitialResource,
11091
+ mutationMeta: retryMutationMeta
11092
+ };
11093
+ }
11085
11094
  function useK8sYamlEditor() {
11086
11095
  const foldSymbol = useCallback(function(editor, symbol) {
11087
11096
  const model = editor.getModel();
@@ -11192,10 +11201,6 @@ function generateYamlBySchema(defaultValue, schema) {
11192
11201
  const content = yaml$2.dump(merged);
11193
11202
  return content.replace(/(')(#.+?)(')/g, "$2").replace(/( +)(#)/g, "$2$1");
11194
11203
  }
11195
- const useGlobalStore = (name2 = "default") => {
11196
- const globalStores = useContext(GlobalStoreContext);
11197
- return globalStores[name2];
11198
- };
11199
11204
  const useYamlForm = ({
11200
11205
  action: actionFromProps,
11201
11206
  resource,
@@ -11233,7 +11238,7 @@ const useYamlForm = ({
11233
11238
  onSubmitAbort,
11234
11239
  rules
11235
11240
  } = {}) => {
11236
- var _a;
11241
+ var _a, _b;
11237
11242
  const editor = useRef(null);
11238
11243
  const { t: t2 } = useTranslation();
11239
11244
  const [isYamlValid, setIsYamlValid] = useState(true);
@@ -11244,7 +11249,17 @@ const useYamlForm = ({
11244
11249
  const [beforeSubmitErrors, setBeforeSubmitErrors] = useState([]);
11245
11250
  const [errorResponseBody, setErrorResponseBody] = useState(null);
11246
11251
  const useResourceResult = useResource();
11247
- const globalStore = useGlobalStore();
11252
+ const globalStore = useGlobalStore(dataProviderName);
11253
+ const action = useMemo(
11254
+ () => actionFromProps || useResourceResult.action,
11255
+ [actionFromProps, useResourceResult.action]
11256
+ );
11257
+ const { captureInitialResource, mutationMeta: finalMutationMeta } = use409Retry({
11258
+ action,
11259
+ dataProviderName,
11260
+ id: idFromProps,
11261
+ mutationMeta
11262
+ });
11248
11263
  const {
11249
11264
  schema,
11250
11265
  loading: isLoadingSchema,
@@ -11281,7 +11296,7 @@ const useYamlForm = ({
11281
11296
  meta: pickNotDeprecated(meta, metaData),
11282
11297
  metaData: pickNotDeprecated(meta, metaData),
11283
11298
  queryMeta,
11284
- mutationMeta,
11299
+ mutationMeta: finalMutationMeta,
11285
11300
  liveMode,
11286
11301
  liveParams,
11287
11302
  mutationMode,
@@ -11296,12 +11311,12 @@ const useYamlForm = ({
11296
11311
  overtimeOptions
11297
11312
  });
11298
11313
  const { formLoading, onFinish, queryResult } = useFormCoreResult;
11314
+ useEffect(() => {
11315
+ var _a2;
11316
+ captureInitialResource((_a2 = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a2.data);
11317
+ }, [captureInitialResource, (_a = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a.data]);
11299
11318
  const { warnWhenUnsavedChanges: warnWhenUnsavedChangesRefine, setWarnWhen } = useWarnAboutChange();
11300
11319
  const warnWhenUnsavedChanges = warnWhenUnsavedChangesProp ?? warnWhenUnsavedChangesRefine;
11301
- const action = useMemo(
11302
- () => actionFromProps || useResourceResult.action,
11303
- [actionFromProps, useResourceResult.action]
11304
- );
11305
11320
  const initialValues = useMemo(() => {
11306
11321
  var _a2;
11307
11322
  const initialValues2 = (action === "edit" && ((_a2 = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a2.data) ? initialValuesForEdit || (globalStore == null ? void 0 : globalStore.restoreItem(queryResult.data.data)) : initialValuesForCreate) || {};
@@ -11344,10 +11359,10 @@ const useYamlForm = ({
11344
11359
  }
11345
11360
  },
11346
11361
  onEditorCreate(editorInstance) {
11347
- var _a3, _b;
11362
+ var _a3, _b2;
11348
11363
  const editorValue = yaml$2.dump(initialValues);
11349
11364
  (_a3 = editor.current) == null ? void 0 : _a3.setEditorValue(editorValue);
11350
- (_b = editor.current) == null ? void 0 : _b.setValue(editorValue);
11365
+ (_b2 = editor.current) == null ? void 0 : _b2.setValue(editorValue);
11351
11366
  if (action === "edit") {
11352
11367
  fold2(editorInstance);
11353
11368
  }
@@ -11360,7 +11375,7 @@ const useYamlForm = ({
11360
11375
  initialValues,
11361
11376
  schemas,
11362
11377
  resource,
11363
- (_a = useResourceResult.resource) == null ? void 0 : _a.name,
11378
+ (_b = useResourceResult.resource) == null ? void 0 : _b.name,
11364
11379
  action,
11365
11380
  finalErrors,
11366
11381
  fold2
@@ -11400,7 +11415,7 @@ const useYamlForm = ({
11400
11415
  formProps: {
11401
11416
  ...formSF.formProps,
11402
11417
  onFinish: async (values) => {
11403
- var _a2, _b;
11418
+ var _a2, _b2;
11404
11419
  setBeforeSubmitErrors([]);
11405
11420
  onSubmitStart == null ? void 0 : onSubmitStart();
11406
11421
  const errors = [
@@ -11420,7 +11435,7 @@ const useYamlForm = ({
11420
11435
  return;
11421
11436
  }
11422
11437
  try {
11423
- const objectValues = editor.current ? yaml$2.load(((_b = editor.current) == null ? void 0 : _b.getEditorValue()) || "") : values;
11438
+ const objectValues = editor.current ? yaml$2.load(((_b2 = editor.current) == null ? void 0 : _b2.getEditorValue()) || "") : values;
11424
11439
  let finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
11425
11440
  if (beforeSubmit) {
11426
11441
  try {
@@ -11522,6 +11537,7 @@ function YamlForm(props) {
11522
11537
  id,
11523
11538
  action: actionFromProps,
11524
11539
  resource: resource == null ? void 0 : resource.name,
11540
+ dataProviderName: resourceConfig.dataProviderName,
11525
11541
  editorOptions: {
11526
11542
  isSkipSchema: schemaStrategy === "None"
11527
11543
  /* None */
@@ -11644,31 +11660,6 @@ function YamlFormContainer({
11644
11660
  onSaveButtonPropsChange
11645
11661
  }) {
11646
11662
  const action = id ? "edit" : "create";
11647
- const pushModal = usePushModal();
11648
- const popModal = usePopModal();
11649
- const hasShownExpiredRef = useRef(false);
11650
- const [isSubmitting, setIsSubmitting] = useState(false);
11651
- const queryResult = useOne({
11652
- resource: resourceConfig.name,
11653
- id,
11654
- liveMode: id ? "auto" : "off",
11655
- queryOptions: { enabled: !!id }
11656
- });
11657
- const isExpired = useResourceVersionCheck({ queryResult });
11658
- useEffect(() => {
11659
- if (!isExpired || isSubmitting || hasShownExpiredRef.current) {
11660
- return;
11661
- }
11662
- hasShownExpiredRef.current = true;
11663
- pushModal({
11664
- component: DataExpiredModal,
11665
- props: {
11666
- onAbandon: () => {
11667
- popModal();
11668
- }
11669
- }
11670
- });
11671
- }, [isExpired, isSubmitting, pushModal, popModal]);
11672
11663
  const { transformInitValues, transformApplyValues } = usePathMap({
11673
11664
  pathMap: formConfig == null ? void 0 : formConfig.pathMap,
11674
11665
  transformInitValues: formConfig == null ? void 0 : formConfig.transformInitValues,
@@ -11688,13 +11679,7 @@ function YamlFormContainer({
11688
11679
  action,
11689
11680
  isShowLayout: false,
11690
11681
  useFormProps: {
11691
- redirect: false,
11692
- onSubmitStart: () => {
11693
- setIsSubmitting(true);
11694
- },
11695
- onSubmitAbort: () => {
11696
- setIsSubmitting(false);
11697
- }
11682
+ redirect: false
11698
11683
  },
11699
11684
  rules: void 0,
11700
11685
  onSaveButtonPropsChange,
@@ -16049,6 +16034,8 @@ function ResourceShow(props) {
16049
16034
  }
16050
16035
  );
16051
16036
  }
16037
+ const button_1v659kh = "";
16038
+ const WarningButtonStyle = "wwyz7ti";
16052
16039
  const modal_1eijuvm = "";
16053
16040
  const SmallModalStyle = "s1nc293e";
16054
16041
  function FormModeSegmentControl({
@@ -16884,9 +16871,16 @@ const useForm = ({
16884
16871
  onSubmitAbort,
16885
16872
  ...rest
16886
16873
  } = {}) => {
16874
+ var _a;
16887
16875
  const { options } = useRefineContext();
16888
16876
  const disableServerSideValidation = (options == null ? void 0 : options.disableServerSideValidation) || disableServerSideValidationProp;
16889
16877
  const translate = useTranslate();
16878
+ const { captureInitialResource, mutationMeta } = use409Retry({
16879
+ action: refineCoreProps == null ? void 0 : refineCoreProps.action,
16880
+ dataProviderName: refineCoreProps == null ? void 0 : refineCoreProps.dataProviderName,
16881
+ id: refineCoreProps == null ? void 0 : refineCoreProps.id,
16882
+ mutationMeta: refineCoreProps == null ? void 0 : refineCoreProps.mutationMeta
16883
+ });
16890
16884
  const { warnWhenUnsavedChanges: warnWhenUnsavedChangesRefine, setWarnWhen } = useWarnAboutChange();
16891
16885
  const warnWhenUnsavedChanges = warnWhenUnsavedChangesProp ?? warnWhenUnsavedChangesRefine;
16892
16886
  const useHookFormResult = useForm$3({
@@ -16906,10 +16900,11 @@ const useForm = ({
16906
16900
  } = useHookFormResult;
16907
16901
  const useFormCoreResult = useForm$2({
16908
16902
  ...refineCoreProps,
16903
+ mutationMeta,
16909
16904
  onMutationError: (error, _variables, _context) => {
16910
- var _a, _b;
16905
+ var _a2, _b;
16911
16906
  if (disableServerSideValidation) {
16912
- (_a = refineCoreProps == null ? void 0 : refineCoreProps.onMutationError) == null ? void 0 : _a.call(refineCoreProps, error, _variables, _context);
16907
+ (_a2 = refineCoreProps == null ? void 0 : refineCoreProps.onMutationError) == null ? void 0 : _a2.call(refineCoreProps, error, _variables, _context);
16913
16908
  return;
16914
16909
  }
16915
16910
  const errors = error == null ? void 0 : error.errors;
@@ -16942,10 +16937,14 @@ const useForm = ({
16942
16937
  });
16943
16938
  const { queryResult, onFinish, formLoading, onFinishAutoSave } = useFormCoreResult;
16944
16939
  useEffect(() => {
16945
- var _a;
16940
+ var _a2;
16941
+ captureInitialResource((_a2 = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a2.data);
16942
+ }, [captureInitialResource, (_a = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a.data]);
16943
+ useEffect(() => {
16944
+ var _a2;
16946
16945
  if (formState.isDirty)
16947
16946
  return;
16948
- const data2 = (_a = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a.data;
16947
+ const data2 = (_a2 = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a2.data;
16949
16948
  if (!data2)
16950
16949
  return;
16951
16950
  const transformedData = transformInitValues ? transformInitValues(data2) : data2;
@@ -16973,13 +16972,13 @@ const useForm = ({
16973
16972
  }, [watch]);
16974
16973
  const onValuesChange = useCallback(
16975
16974
  (changeValues) => {
16976
- var _a;
16975
+ var _a2;
16977
16976
  if (warnWhenUnsavedChanges) {
16978
16977
  setWarnWhen(true);
16979
16978
  }
16980
16979
  if (refineCoreProps == null ? void 0 : refineCoreProps.autoSave) {
16981
16980
  setWarnWhen(false);
16982
- const onFinishProps = (_a = refineCoreProps.autoSave) == null ? void 0 : _a.onFinish;
16981
+ const onFinishProps = (_a2 = refineCoreProps.autoSave) == null ? void 0 : _a2.onFinish;
16983
16982
  if (onFinishProps) {
16984
16983
  return onFinishAutoSave(onFinishProps(changeValues));
16985
16984
  }
@@ -17093,6 +17092,7 @@ const useRefineForm = (props) => {
17093
17092
  resource: resourceConfig.name,
17094
17093
  action: id ? "edit" : "create",
17095
17094
  id,
17095
+ dataProviderName: resourceConfig.dataProviderName,
17096
17096
  liveMode: id ? "auto" : "off",
17097
17097
  ...refineProps
17098
17098
  },
@@ -17106,10 +17106,11 @@ const useRefineForm = (props) => {
17106
17106
  ...formConfig == null ? void 0 : formConfig.useFormProps
17107
17107
  });
17108
17108
  useEffect(() => {
17109
- var _a, _b;
17109
+ var _a, _b, _c;
17110
17110
  const response = (_a = result.refineCore.mutationResult.error) == null ? void 0 : _a.response;
17111
+ const message2 = (_b = result.refineCore.mutationResult.error) == null ? void 0 : _b.message;
17111
17112
  if (response && !(response == null ? void 0 : response.bodyUsed)) {
17112
- (_b = response.json) == null ? void 0 : _b.call(response).then((body) => {
17113
+ (_c = response.json) == null ? void 0 : _c.call(response).then((body) => {
17113
17114
  var _a2;
17114
17115
  setResponseErrorMsgs(
17115
17116
  [].concat(
@@ -17117,8 +17118,10 @@ const useRefineForm = (props) => {
17117
17118
  )
17118
17119
  );
17119
17120
  });
17121
+ } else if (message2 && responseErrorMsgs[0] !== message2) {
17122
+ setResponseErrorMsgs([message2]);
17120
17123
  }
17121
- }, [formConfig, result, i18n2]);
17124
+ }, [formConfig, result, i18n2, responseErrorMsgs]);
17122
17125
  return {
17123
17126
  formResult: result,
17124
17127
  responseErrorMsgs,
@@ -17139,10 +17142,6 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17139
17142
  }, ref) {
17140
17143
  var _a, _b;
17141
17144
  const action = id ? "edit" : "create";
17142
- const pushModal = usePushModal();
17143
- const popModal = usePopModal();
17144
- const hasShownExpiredRef = useRef(false);
17145
- const [isSubmitting, setIsSubmitting] = useState(false);
17146
17145
  const refineFormResult = useRefineForm({
17147
17146
  resourceConfig,
17148
17147
  id,
@@ -17151,7 +17150,6 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17151
17150
  onSuccess == null ? void 0 : onSuccess(data2);
17152
17151
  },
17153
17152
  onMutationError() {
17154
- setIsSubmitting(false);
17155
17153
  onError == null ? void 0 : onError();
17156
17154
  },
17157
17155
  redirect: false,
@@ -17165,35 +17163,11 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17165
17163
  ...options,
17166
17164
  onBeforeSubmitError: (errors) => {
17167
17165
  if (errors.length) {
17168
- setIsSubmitting(false);
17169
17166
  onError == null ? void 0 : onError();
17170
17167
  }
17171
- },
17172
- onSubmitStart: () => {
17173
- setIsSubmitting(true);
17174
- },
17175
- onSubmitAbort: () => {
17176
- setIsSubmitting(false);
17177
17168
  }
17178
17169
  }
17179
17170
  });
17180
- const isExpired = useResourceVersionCheck({
17181
- queryResult: refineFormResult.formResult.refineCore.queryResult
17182
- });
17183
- useEffect(() => {
17184
- if (!isExpired || isSubmitting || hasShownExpiredRef.current) {
17185
- return;
17186
- }
17187
- hasShownExpiredRef.current = true;
17188
- pushModal({
17189
- component: DataExpiredModal,
17190
- props: {
17191
- onAbandon: () => {
17192
- popModal();
17193
- }
17194
- }
17195
- });
17196
- }, [isExpired, isSubmitting, pushModal, popModal]);
17197
17171
  const fieldsConfig = useFieldsConfig(
17198
17172
  resourceConfig,
17199
17173
  { fields: formConfig == null ? void 0 : formConfig.fields },
@@ -17225,13 +17199,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
17225
17199
  action,
17226
17200
  isShowLayout: false,
17227
17201
  useFormProps: {
17228
- redirect: false,
17229
- onSubmitStart: () => {
17230
- setIsSubmitting(true);
17231
- },
17232
- onSubmitAbort: () => {
17233
- setIsSubmitting(false);
17234
- }
17202
+ redirect: false
17235
17203
  },
17236
17204
  rules: fieldsConfig == null ? void 0 : fieldsConfig.filter(
17237
17205
  (config) => "isSkipValidationInYaml" in config && !config.isSkipValidationInYaml
@@ -17479,37 +17447,39 @@ function FormModal(props) {
17479
17447
  setStep(nextStep);
17480
17448
  }
17481
17449
  }, [step]);
17482
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(WizardDialog, {
17483
- style: {
17484
- "--max-modal-width": isYamlForm || !isDisabledChangeMode ? "1024px" : "648px"
17485
- },
17486
- title: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
17487
- className: TitleWrapperStyle,
17488
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx("span", {
17489
- children: title
17490
- }), ((_b = resourceConfig.formConfig) == null ? void 0 : _b.formType) === FormType.FORM ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormModeSegmentControl, {
17491
- formConfig: resourceConfig.formConfig,
17492
- mode,
17493
- onChangeMode
17494
- }) : null]
17495
- }),
17496
- error: errorText,
17497
- steps,
17498
- step,
17499
- onStepChange: handleStepChange,
17500
- onOk,
17501
- okButtonProps: {
17502
- ...omit$1(saveButtonProps, "onClick"),
17503
- children: (_c = resourceConfig.formConfig) == null ? void 0 : _c.saveButtonText
17504
- },
17505
- okText: ((_d = resourceConfig.formConfig) == null ? void 0 : _d.saveButtonText) || okText,
17506
- destroyOnClose: true,
17507
- destroyOtherStep: true,
17508
- ...modalProps,
17509
- children: [desc ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
17510
- className: FormDescStyle,
17511
- children: desc
17512
- }) : void 0, formEle]
17450
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Retry409Provider, {
17451
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(WizardDialog, {
17452
+ style: {
17453
+ "--max-modal-width": isYamlForm || !isDisabledChangeMode ? "1024px" : "648px"
17454
+ },
17455
+ title: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
17456
+ className: TitleWrapperStyle,
17457
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx("span", {
17458
+ children: title
17459
+ }), ((_b = resourceConfig.formConfig) == null ? void 0 : _b.formType) === FormType.FORM ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormModeSegmentControl, {
17460
+ formConfig: resourceConfig.formConfig,
17461
+ mode,
17462
+ onChangeMode
17463
+ }) : null]
17464
+ }),
17465
+ error: errorText,
17466
+ steps,
17467
+ step,
17468
+ onStepChange: handleStepChange,
17469
+ onOk,
17470
+ okButtonProps: {
17471
+ ...omit$1(saveButtonProps, "onClick"),
17472
+ children: (_c = resourceConfig.formConfig) == null ? void 0 : _c.saveButtonText
17473
+ },
17474
+ okText: ((_d = resourceConfig.formConfig) == null ? void 0 : _d.saveButtonText) || okText,
17475
+ destroyOnClose: true,
17476
+ destroyOtherStep: true,
17477
+ ...modalProps,
17478
+ children: [desc ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
17479
+ className: FormDescStyle,
17480
+ children: desc
17481
+ }) : void 0, formEle]
17482
+ })
17513
17483
  });
17514
17484
  }
17515
17485
  const RefineFormPage_1v0fhor = "";