@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/components/Form/FormModal.d.ts +1 -1
- package/dist/components/Form/RawYamlFormModal.d.ts +1 -1
- package/dist/components/Form/RefineFormContainer.d.ts +1 -1
- package/dist/components/Form/useReactHookForm.d.ts +1 -2
- package/dist/components/Form/useRefineForm.d.ts +1 -1
- package/dist/hooks/use409Retry.d.ts +68 -0
- package/dist/hooks/useOpenForm.d.ts +1 -1
- package/dist/i18n.d.ts +2 -0
- package/dist/locales/en-US/index.d.ts +1 -0
- package/dist/locales/zh-CN/index.d.ts +1 -0
- package/dist/refine.cjs +150 -180
- package/dist/refine.js +152 -182
- package/dist/style.css +57 -107
- package/package.json +2 -2
package/dist/refine.cjs
CHANGED
|
@@ -641,6 +641,7 @@ const edit_form$1 = "Edit form";
|
|
|
641
641
|
const data_expired$1 = "Data expired";
|
|
642
642
|
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.";
|
|
643
643
|
const data_expired_note$1 = "Your current entries will not be saved.";
|
|
644
|
+
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.";
|
|
644
645
|
const abandon_edit$1 = "Discard edit";
|
|
645
646
|
const exit_yaml_tip$1 = "If you go back to the form, any changes made to the YAML file will be lost.";
|
|
646
647
|
const value_optional$1 = "Value (optional)";
|
|
@@ -922,6 +923,7 @@ const dovetail$1 = {
|
|
|
922
923
|
data_expired: data_expired$1,
|
|
923
924
|
data_expired_body: data_expired_body$1,
|
|
924
925
|
data_expired_note: data_expired_note$1,
|
|
926
|
+
resource_version_conflict: resource_version_conflict$1,
|
|
925
927
|
abandon_edit: abandon_edit$1,
|
|
926
928
|
exit_yaml_tip: exit_yaml_tip$1,
|
|
927
929
|
value_optional: value_optional$1,
|
|
@@ -1205,6 +1207,7 @@ const edit_form = "编辑表单";
|
|
|
1205
1207
|
const data_expired = "数据已过期";
|
|
1206
1208
|
const data_expired_body = "当前表单中的数据已不是最新版。为避免保存失败,请放弃本次编辑,并重新打开表单进行编辑。";
|
|
1207
1209
|
const data_expired_note = "当前已填写内容将不会保留。";
|
|
1210
|
+
const resource_version_conflict = "当前表单中的数据已不是最新版,请放弃本次编辑,并重新打开表单进行编辑。";
|
|
1208
1211
|
const abandon_edit = "放弃编辑";
|
|
1209
1212
|
const exit_yaml_tip = "返回编辑表单,不会保留对 YAML 文件做出的所有更改。";
|
|
1210
1213
|
const form = "表单";
|
|
@@ -1485,6 +1488,7 @@ const dovetail = {
|
|
|
1485
1488
|
data_expired,
|
|
1486
1489
|
data_expired_body,
|
|
1487
1490
|
data_expired_note,
|
|
1491
|
+
resource_version_conflict,
|
|
1488
1492
|
abandon_edit,
|
|
1489
1493
|
exit_yaml_tip,
|
|
1490
1494
|
form,
|
|
@@ -10708,26 +10712,6 @@ function usePathMap(options) {
|
|
|
10708
10712
|
transformApplyValues
|
|
10709
10713
|
};
|
|
10710
10714
|
}
|
|
10711
|
-
const useResourceVersionCheck = ({
|
|
10712
|
-
queryResult
|
|
10713
|
-
}) => {
|
|
10714
|
-
var _a, _b, _c;
|
|
10715
|
-
const initialResourceVersionRef = React.useRef();
|
|
10716
|
-
const [isExpired, setIsExpired] = React.useState(false);
|
|
10717
|
-
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;
|
|
10718
|
-
React.useEffect(() => {
|
|
10719
|
-
if (!currentResourceVersion)
|
|
10720
|
-
return;
|
|
10721
|
-
if (!initialResourceVersionRef.current) {
|
|
10722
|
-
initialResourceVersionRef.current = currentResourceVersion;
|
|
10723
|
-
return;
|
|
10724
|
-
}
|
|
10725
|
-
if (currentResourceVersion !== initialResourceVersionRef.current) {
|
|
10726
|
-
setIsExpired(true);
|
|
10727
|
-
}
|
|
10728
|
-
}, [currentResourceVersion]);
|
|
10729
|
-
return isExpired;
|
|
10730
|
-
};
|
|
10731
10715
|
function getInitialValues(resourceConfig) {
|
|
10732
10716
|
return resourceConfig.initValue || {
|
|
10733
10717
|
apiVersion: resourceConfig.apiVersion,
|
|
@@ -10736,42 +10720,6 @@ function getInitialValues(resourceConfig) {
|
|
|
10736
10720
|
spec: {}
|
|
10737
10721
|
};
|
|
10738
10722
|
}
|
|
10739
|
-
const button_1v659kh = "";
|
|
10740
|
-
const WarningButtonStyle = "wwyz7ti";
|
|
10741
|
-
const DataExpiredModal_eazxh6 = "";
|
|
10742
|
-
const NoteStyle = "n609wlp";
|
|
10743
|
-
function DataExpiredModal({
|
|
10744
|
-
onAbandon
|
|
10745
|
-
}) {
|
|
10746
|
-
const {
|
|
10747
|
-
t: t2
|
|
10748
|
-
} = common.useTranslation();
|
|
10749
|
-
return /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.SmallDialog, {
|
|
10750
|
-
title: t2("dovetail.data_expired"),
|
|
10751
|
-
closable: false,
|
|
10752
|
-
maskClosable: false,
|
|
10753
|
-
cancelButtonProps: {
|
|
10754
|
-
style: {
|
|
10755
|
-
display: "none"
|
|
10756
|
-
}
|
|
10757
|
-
},
|
|
10758
|
-
okText: t2("dovetail.abandon_edit"),
|
|
10759
|
-
okButtonProps: {
|
|
10760
|
-
className: WarningButtonStyle
|
|
10761
|
-
},
|
|
10762
|
-
onOk: (popModal) => {
|
|
10763
|
-
popModal();
|
|
10764
|
-
onAbandon();
|
|
10765
|
-
},
|
|
10766
|
-
children: [/* @__PURE__ */ common.jsxRuntimeExports.jsx("div", {
|
|
10767
|
-
className: eagle.Typo.Label.l2_regular,
|
|
10768
|
-
children: t2("dovetail.data_expired_body")
|
|
10769
|
-
}), /* @__PURE__ */ common.jsxRuntimeExports.jsx("div", {
|
|
10770
|
-
className: `${eagle.Typo.Label.l2_regular} ${NoteStyle}`,
|
|
10771
|
-
children: t2("dovetail.data_expired_note")
|
|
10772
|
-
})]
|
|
10773
|
-
});
|
|
10774
|
-
}
|
|
10775
10723
|
const index_az4wrx = "";
|
|
10776
10724
|
const WrapperStyle$5 = "w1akirqw";
|
|
10777
10725
|
const TitleStyle$2 = "t30srnq";
|
|
@@ -11101,6 +11049,67 @@ function copyToClipboard(text) {
|
|
|
11101
11049
|
document.execCommand("copy");
|
|
11102
11050
|
document.body.removeChild(input);
|
|
11103
11051
|
}
|
|
11052
|
+
const useGlobalStore = (name2 = "default") => {
|
|
11053
|
+
const globalStores = React.useContext(GlobalStoreContext);
|
|
11054
|
+
return globalStores[name2];
|
|
11055
|
+
};
|
|
11056
|
+
const ResourceVersionConflictRetryContext = React.createContext(null);
|
|
11057
|
+
function Retry409Provider({
|
|
11058
|
+
children
|
|
11059
|
+
}) {
|
|
11060
|
+
const initialResourceRef = React.useRef();
|
|
11061
|
+
return React.createElement(
|
|
11062
|
+
ResourceVersionConflictRetryContext.Provider,
|
|
11063
|
+
{
|
|
11064
|
+
value: initialResourceRef
|
|
11065
|
+
},
|
|
11066
|
+
children
|
|
11067
|
+
);
|
|
11068
|
+
}
|
|
11069
|
+
function use409Retry({
|
|
11070
|
+
action,
|
|
11071
|
+
dataProviderName,
|
|
11072
|
+
id,
|
|
11073
|
+
mutationMeta
|
|
11074
|
+
}) {
|
|
11075
|
+
const { t: t2 } = common.useTranslation();
|
|
11076
|
+
const globalStore = useGlobalStore(dataProviderName);
|
|
11077
|
+
const sharedInitialResourceRef = React.useContext(ResourceVersionConflictRetryContext);
|
|
11078
|
+
const localInitialResourceRef = React.useRef();
|
|
11079
|
+
const initialResourceRef = sharedInitialResourceRef || localInitialResourceRef;
|
|
11080
|
+
const isEditAction = action === "edit" || !!id;
|
|
11081
|
+
const captureInitialResource = React.useCallback((resource) => {
|
|
11082
|
+
var _a;
|
|
11083
|
+
if (!isEditAction || initialResourceRef.current || !resource) {
|
|
11084
|
+
return;
|
|
11085
|
+
}
|
|
11086
|
+
const rawResource = (_a = globalStore == null ? void 0 : globalStore.restoreItem) == null ? void 0 : _a.call(globalStore, resource);
|
|
11087
|
+
if (!rawResource) {
|
|
11088
|
+
return;
|
|
11089
|
+
}
|
|
11090
|
+
initialResourceRef.current = lodashEs.cloneDeep(rawResource);
|
|
11091
|
+
}, [globalStore, initialResourceRef, isEditAction]);
|
|
11092
|
+
const retryMutationMeta = React.useMemo(() => {
|
|
11093
|
+
const restMutationMeta = lodashEs.omit(mutationMeta, "resourceVersionConflictRetry");
|
|
11094
|
+
if (!isEditAction) {
|
|
11095
|
+
return restMutationMeta;
|
|
11096
|
+
}
|
|
11097
|
+
return {
|
|
11098
|
+
...restMutationMeta,
|
|
11099
|
+
resourceVersionConflictRetry: {
|
|
11100
|
+
// refine 的 mutationMeta 在 hook 创建时就会固定;用 getter 让 provider 在保存瞬间读取最新的初始版本。
|
|
11101
|
+
get initialResource() {
|
|
11102
|
+
return initialResourceRef.current;
|
|
11103
|
+
},
|
|
11104
|
+
conflictMessage: t2("dovetail.resource_version_conflict")
|
|
11105
|
+
}
|
|
11106
|
+
};
|
|
11107
|
+
}, [initialResourceRef, isEditAction, mutationMeta, t2]);
|
|
11108
|
+
return {
|
|
11109
|
+
captureInitialResource,
|
|
11110
|
+
mutationMeta: retryMutationMeta
|
|
11111
|
+
};
|
|
11112
|
+
}
|
|
11104
11113
|
function useK8sYamlEditor() {
|
|
11105
11114
|
const foldSymbol = React.useCallback(function(editor, symbol) {
|
|
11106
11115
|
const model = editor.getModel();
|
|
@@ -11211,10 +11220,6 @@ function generateYamlBySchema(defaultValue, schema) {
|
|
|
11211
11220
|
const content = yaml$2.dump(merged);
|
|
11212
11221
|
return content.replace(/(')(#.+?)(')/g, "$2").replace(/( +)(#)/g, "$2$1");
|
|
11213
11222
|
}
|
|
11214
|
-
const useGlobalStore = (name2 = "default") => {
|
|
11215
|
-
const globalStores = React.useContext(GlobalStoreContext);
|
|
11216
|
-
return globalStores[name2];
|
|
11217
|
-
};
|
|
11218
11223
|
const useYamlForm = ({
|
|
11219
11224
|
action: actionFromProps,
|
|
11220
11225
|
resource,
|
|
@@ -11252,7 +11257,7 @@ const useYamlForm = ({
|
|
|
11252
11257
|
onSubmitAbort,
|
|
11253
11258
|
rules
|
|
11254
11259
|
} = {}) => {
|
|
11255
|
-
var _a;
|
|
11260
|
+
var _a, _b;
|
|
11256
11261
|
const editor = React.useRef(null);
|
|
11257
11262
|
const { t: t2 } = common.useTranslation();
|
|
11258
11263
|
const [isYamlValid, setIsYamlValid] = React.useState(true);
|
|
@@ -11263,7 +11268,17 @@ const useYamlForm = ({
|
|
|
11263
11268
|
const [beforeSubmitErrors, setBeforeSubmitErrors] = React.useState([]);
|
|
11264
11269
|
const [errorResponseBody, setErrorResponseBody] = React.useState(null);
|
|
11265
11270
|
const useResourceResult = core.useResource();
|
|
11266
|
-
const globalStore = useGlobalStore();
|
|
11271
|
+
const globalStore = useGlobalStore(dataProviderName);
|
|
11272
|
+
const action = React.useMemo(
|
|
11273
|
+
() => actionFromProps || useResourceResult.action,
|
|
11274
|
+
[actionFromProps, useResourceResult.action]
|
|
11275
|
+
);
|
|
11276
|
+
const { captureInitialResource, mutationMeta: finalMutationMeta } = use409Retry({
|
|
11277
|
+
action,
|
|
11278
|
+
dataProviderName,
|
|
11279
|
+
id: idFromProps,
|
|
11280
|
+
mutationMeta
|
|
11281
|
+
});
|
|
11267
11282
|
const {
|
|
11268
11283
|
schema,
|
|
11269
11284
|
loading: isLoadingSchema,
|
|
@@ -11300,7 +11315,7 @@ const useYamlForm = ({
|
|
|
11300
11315
|
meta: core.pickNotDeprecated(meta, metaData),
|
|
11301
11316
|
metaData: core.pickNotDeprecated(meta, metaData),
|
|
11302
11317
|
queryMeta,
|
|
11303
|
-
mutationMeta,
|
|
11318
|
+
mutationMeta: finalMutationMeta,
|
|
11304
11319
|
liveMode,
|
|
11305
11320
|
liveParams,
|
|
11306
11321
|
mutationMode,
|
|
@@ -11315,12 +11330,12 @@ const useYamlForm = ({
|
|
|
11315
11330
|
overtimeOptions
|
|
11316
11331
|
});
|
|
11317
11332
|
const { formLoading, onFinish, queryResult } = useFormCoreResult;
|
|
11333
|
+
React.useEffect(() => {
|
|
11334
|
+
var _a2;
|
|
11335
|
+
captureInitialResource((_a2 = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a2.data);
|
|
11336
|
+
}, [captureInitialResource, (_a = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a.data]);
|
|
11318
11337
|
const { warnWhenUnsavedChanges: warnWhenUnsavedChangesRefine, setWarnWhen } = core.useWarnAboutChange();
|
|
11319
11338
|
const warnWhenUnsavedChanges = warnWhenUnsavedChangesProp ?? warnWhenUnsavedChangesRefine;
|
|
11320
|
-
const action = React.useMemo(
|
|
11321
|
-
() => actionFromProps || useResourceResult.action,
|
|
11322
|
-
[actionFromProps, useResourceResult.action]
|
|
11323
|
-
);
|
|
11324
11339
|
const initialValues = React.useMemo(() => {
|
|
11325
11340
|
var _a2;
|
|
11326
11341
|
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) || {};
|
|
@@ -11363,10 +11378,10 @@ const useYamlForm = ({
|
|
|
11363
11378
|
}
|
|
11364
11379
|
},
|
|
11365
11380
|
onEditorCreate(editorInstance) {
|
|
11366
|
-
var _a3,
|
|
11381
|
+
var _a3, _b2;
|
|
11367
11382
|
const editorValue = yaml$2.dump(initialValues);
|
|
11368
11383
|
(_a3 = editor.current) == null ? void 0 : _a3.setEditorValue(editorValue);
|
|
11369
|
-
(
|
|
11384
|
+
(_b2 = editor.current) == null ? void 0 : _b2.setValue(editorValue);
|
|
11370
11385
|
if (action === "edit") {
|
|
11371
11386
|
fold2(editorInstance);
|
|
11372
11387
|
}
|
|
@@ -11379,7 +11394,7 @@ const useYamlForm = ({
|
|
|
11379
11394
|
initialValues,
|
|
11380
11395
|
schemas,
|
|
11381
11396
|
resource,
|
|
11382
|
-
(
|
|
11397
|
+
(_b = useResourceResult.resource) == null ? void 0 : _b.name,
|
|
11383
11398
|
action,
|
|
11384
11399
|
finalErrors,
|
|
11385
11400
|
fold2
|
|
@@ -11419,7 +11434,7 @@ const useYamlForm = ({
|
|
|
11419
11434
|
formProps: {
|
|
11420
11435
|
...formSF.formProps,
|
|
11421
11436
|
onFinish: async (values) => {
|
|
11422
|
-
var _a2,
|
|
11437
|
+
var _a2, _b2;
|
|
11423
11438
|
setBeforeSubmitErrors([]);
|
|
11424
11439
|
onSubmitStart == null ? void 0 : onSubmitStart();
|
|
11425
11440
|
const errors = [
|
|
@@ -11439,7 +11454,7 @@ const useYamlForm = ({
|
|
|
11439
11454
|
return;
|
|
11440
11455
|
}
|
|
11441
11456
|
try {
|
|
11442
|
-
const objectValues = editor.current ? yaml$2.load(((
|
|
11457
|
+
const objectValues = editor.current ? yaml$2.load(((_b2 = editor.current) == null ? void 0 : _b2.getEditorValue()) || "") : values;
|
|
11443
11458
|
let finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
|
|
11444
11459
|
if (beforeSubmit) {
|
|
11445
11460
|
try {
|
|
@@ -11541,6 +11556,7 @@ function YamlForm(props) {
|
|
|
11541
11556
|
id,
|
|
11542
11557
|
action: actionFromProps,
|
|
11543
11558
|
resource: resource == null ? void 0 : resource.name,
|
|
11559
|
+
dataProviderName: resourceConfig.dataProviderName,
|
|
11544
11560
|
editorOptions: {
|
|
11545
11561
|
isSkipSchema: schemaStrategy === "None"
|
|
11546
11562
|
/* None */
|
|
@@ -11663,31 +11679,6 @@ function YamlFormContainer({
|
|
|
11663
11679
|
onSaveButtonPropsChange
|
|
11664
11680
|
}) {
|
|
11665
11681
|
const action = id ? "edit" : "create";
|
|
11666
|
-
const pushModal = eagle.usePushModal();
|
|
11667
|
-
const popModal = eagle.usePopModal();
|
|
11668
|
-
const hasShownExpiredRef = React.useRef(false);
|
|
11669
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11670
|
-
const queryResult = core.useOne({
|
|
11671
|
-
resource: resourceConfig.name,
|
|
11672
|
-
id,
|
|
11673
|
-
liveMode: id ? "auto" : "off",
|
|
11674
|
-
queryOptions: { enabled: !!id }
|
|
11675
|
-
});
|
|
11676
|
-
const isExpired = useResourceVersionCheck({ queryResult });
|
|
11677
|
-
React.useEffect(() => {
|
|
11678
|
-
if (!isExpired || isSubmitting || hasShownExpiredRef.current) {
|
|
11679
|
-
return;
|
|
11680
|
-
}
|
|
11681
|
-
hasShownExpiredRef.current = true;
|
|
11682
|
-
pushModal({
|
|
11683
|
-
component: DataExpiredModal,
|
|
11684
|
-
props: {
|
|
11685
|
-
onAbandon: () => {
|
|
11686
|
-
popModal();
|
|
11687
|
-
}
|
|
11688
|
-
}
|
|
11689
|
-
});
|
|
11690
|
-
}, [isExpired, isSubmitting, pushModal, popModal]);
|
|
11691
11682
|
const { transformInitValues, transformApplyValues } = usePathMap({
|
|
11692
11683
|
pathMap: formConfig == null ? void 0 : formConfig.pathMap,
|
|
11693
11684
|
transformInitValues: formConfig == null ? void 0 : formConfig.transformInitValues,
|
|
@@ -11707,13 +11698,7 @@ function YamlFormContainer({
|
|
|
11707
11698
|
action,
|
|
11708
11699
|
isShowLayout: false,
|
|
11709
11700
|
useFormProps: {
|
|
11710
|
-
redirect: false
|
|
11711
|
-
onSubmitStart: () => {
|
|
11712
|
-
setIsSubmitting(true);
|
|
11713
|
-
},
|
|
11714
|
-
onSubmitAbort: () => {
|
|
11715
|
-
setIsSubmitting(false);
|
|
11716
|
-
}
|
|
11701
|
+
redirect: false
|
|
11717
11702
|
},
|
|
11718
11703
|
rules: void 0,
|
|
11719
11704
|
onSaveButtonPropsChange,
|
|
@@ -16068,6 +16053,8 @@ function ResourceShow(props) {
|
|
|
16068
16053
|
}
|
|
16069
16054
|
);
|
|
16070
16055
|
}
|
|
16056
|
+
const button_1v659kh = "";
|
|
16057
|
+
const WarningButtonStyle = "wwyz7ti";
|
|
16071
16058
|
const modal_1eijuvm = "";
|
|
16072
16059
|
const SmallModalStyle = "s1nc293e";
|
|
16073
16060
|
function FormModeSegmentControl({
|
|
@@ -16903,9 +16890,16 @@ const useForm = ({
|
|
|
16903
16890
|
onSubmitAbort,
|
|
16904
16891
|
...rest
|
|
16905
16892
|
} = {}) => {
|
|
16893
|
+
var _a;
|
|
16906
16894
|
const { options } = core.useRefineContext();
|
|
16907
16895
|
const disableServerSideValidation = (options == null ? void 0 : options.disableServerSideValidation) || disableServerSideValidationProp;
|
|
16908
16896
|
const translate = core.useTranslate();
|
|
16897
|
+
const { captureInitialResource, mutationMeta } = use409Retry({
|
|
16898
|
+
action: refineCoreProps == null ? void 0 : refineCoreProps.action,
|
|
16899
|
+
dataProviderName: refineCoreProps == null ? void 0 : refineCoreProps.dataProviderName,
|
|
16900
|
+
id: refineCoreProps == null ? void 0 : refineCoreProps.id,
|
|
16901
|
+
mutationMeta: refineCoreProps == null ? void 0 : refineCoreProps.mutationMeta
|
|
16902
|
+
});
|
|
16909
16903
|
const { warnWhenUnsavedChanges: warnWhenUnsavedChangesRefine, setWarnWhen } = core.useWarnAboutChange();
|
|
16910
16904
|
const warnWhenUnsavedChanges = warnWhenUnsavedChangesProp ?? warnWhenUnsavedChangesRefine;
|
|
16911
16905
|
const useHookFormResult = reactHookForm.useForm({
|
|
@@ -16925,10 +16919,11 @@ const useForm = ({
|
|
|
16925
16919
|
} = useHookFormResult;
|
|
16926
16920
|
const useFormCoreResult = core.useForm({
|
|
16927
16921
|
...refineCoreProps,
|
|
16922
|
+
mutationMeta,
|
|
16928
16923
|
onMutationError: (error, _variables, _context) => {
|
|
16929
|
-
var
|
|
16924
|
+
var _a2, _b;
|
|
16930
16925
|
if (disableServerSideValidation) {
|
|
16931
|
-
(
|
|
16926
|
+
(_a2 = refineCoreProps == null ? void 0 : refineCoreProps.onMutationError) == null ? void 0 : _a2.call(refineCoreProps, error, _variables, _context);
|
|
16932
16927
|
return;
|
|
16933
16928
|
}
|
|
16934
16929
|
const errors = error == null ? void 0 : error.errors;
|
|
@@ -16961,10 +16956,14 @@ const useForm = ({
|
|
|
16961
16956
|
});
|
|
16962
16957
|
const { queryResult, onFinish, formLoading, onFinishAutoSave } = useFormCoreResult;
|
|
16963
16958
|
React.useEffect(() => {
|
|
16964
|
-
var
|
|
16959
|
+
var _a2;
|
|
16960
|
+
captureInitialResource((_a2 = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a2.data);
|
|
16961
|
+
}, [captureInitialResource, (_a = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a.data]);
|
|
16962
|
+
React.useEffect(() => {
|
|
16963
|
+
var _a2;
|
|
16965
16964
|
if (formState.isDirty)
|
|
16966
16965
|
return;
|
|
16967
|
-
const data2 = (
|
|
16966
|
+
const data2 = (_a2 = queryResult == null ? void 0 : queryResult.data) == null ? void 0 : _a2.data;
|
|
16968
16967
|
if (!data2)
|
|
16969
16968
|
return;
|
|
16970
16969
|
const transformedData = transformInitValues ? transformInitValues(data2) : data2;
|
|
@@ -16992,13 +16991,13 @@ const useForm = ({
|
|
|
16992
16991
|
}, [watch]);
|
|
16993
16992
|
const onValuesChange = React.useCallback(
|
|
16994
16993
|
(changeValues) => {
|
|
16995
|
-
var
|
|
16994
|
+
var _a2;
|
|
16996
16995
|
if (warnWhenUnsavedChanges) {
|
|
16997
16996
|
setWarnWhen(true);
|
|
16998
16997
|
}
|
|
16999
16998
|
if (refineCoreProps == null ? void 0 : refineCoreProps.autoSave) {
|
|
17000
16999
|
setWarnWhen(false);
|
|
17001
|
-
const onFinishProps = (
|
|
17000
|
+
const onFinishProps = (_a2 = refineCoreProps.autoSave) == null ? void 0 : _a2.onFinish;
|
|
17002
17001
|
if (onFinishProps) {
|
|
17003
17002
|
return onFinishAutoSave(onFinishProps(changeValues));
|
|
17004
17003
|
}
|
|
@@ -17112,6 +17111,7 @@ const useRefineForm = (props) => {
|
|
|
17112
17111
|
resource: resourceConfig.name,
|
|
17113
17112
|
action: id ? "edit" : "create",
|
|
17114
17113
|
id,
|
|
17114
|
+
dataProviderName: resourceConfig.dataProviderName,
|
|
17115
17115
|
liveMode: id ? "auto" : "off",
|
|
17116
17116
|
...refineProps
|
|
17117
17117
|
},
|
|
@@ -17125,10 +17125,11 @@ const useRefineForm = (props) => {
|
|
|
17125
17125
|
...formConfig == null ? void 0 : formConfig.useFormProps
|
|
17126
17126
|
});
|
|
17127
17127
|
React.useEffect(() => {
|
|
17128
|
-
var _a, _b;
|
|
17128
|
+
var _a, _b, _c;
|
|
17129
17129
|
const response = (_a = result.refineCore.mutationResult.error) == null ? void 0 : _a.response;
|
|
17130
|
+
const message2 = (_b = result.refineCore.mutationResult.error) == null ? void 0 : _b.message;
|
|
17130
17131
|
if (response && !(response == null ? void 0 : response.bodyUsed)) {
|
|
17131
|
-
(
|
|
17132
|
+
(_c = response.json) == null ? void 0 : _c.call(response).then((body) => {
|
|
17132
17133
|
var _a2;
|
|
17133
17134
|
setResponseErrorMsgs(
|
|
17134
17135
|
[].concat(
|
|
@@ -17136,8 +17137,10 @@ const useRefineForm = (props) => {
|
|
|
17136
17137
|
)
|
|
17137
17138
|
);
|
|
17138
17139
|
});
|
|
17140
|
+
} else if (message2 && responseErrorMsgs[0] !== message2) {
|
|
17141
|
+
setResponseErrorMsgs([message2]);
|
|
17139
17142
|
}
|
|
17140
|
-
}, [formConfig, result, i18n2]);
|
|
17143
|
+
}, [formConfig, result, i18n2, responseErrorMsgs]);
|
|
17141
17144
|
return {
|
|
17142
17145
|
formResult: result,
|
|
17143
17146
|
responseErrorMsgs,
|
|
@@ -17158,10 +17161,6 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17158
17161
|
}, ref) {
|
|
17159
17162
|
var _a, _b;
|
|
17160
17163
|
const action = id ? "edit" : "create";
|
|
17161
|
-
const pushModal = eagle.usePushModal();
|
|
17162
|
-
const popModal = eagle.usePopModal();
|
|
17163
|
-
const hasShownExpiredRef = React.useRef(false);
|
|
17164
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
17165
17164
|
const refineFormResult = useRefineForm({
|
|
17166
17165
|
resourceConfig,
|
|
17167
17166
|
id,
|
|
@@ -17170,7 +17169,6 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17170
17169
|
onSuccess == null ? void 0 : onSuccess(data2);
|
|
17171
17170
|
},
|
|
17172
17171
|
onMutationError() {
|
|
17173
|
-
setIsSubmitting(false);
|
|
17174
17172
|
onError == null ? void 0 : onError();
|
|
17175
17173
|
},
|
|
17176
17174
|
redirect: false,
|
|
@@ -17184,35 +17182,11 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17184
17182
|
...options,
|
|
17185
17183
|
onBeforeSubmitError: (errors) => {
|
|
17186
17184
|
if (errors.length) {
|
|
17187
|
-
setIsSubmitting(false);
|
|
17188
17185
|
onError == null ? void 0 : onError();
|
|
17189
17186
|
}
|
|
17190
|
-
},
|
|
17191
|
-
onSubmitStart: () => {
|
|
17192
|
-
setIsSubmitting(true);
|
|
17193
|
-
},
|
|
17194
|
-
onSubmitAbort: () => {
|
|
17195
|
-
setIsSubmitting(false);
|
|
17196
17187
|
}
|
|
17197
17188
|
}
|
|
17198
17189
|
});
|
|
17199
|
-
const isExpired = useResourceVersionCheck({
|
|
17200
|
-
queryResult: refineFormResult.formResult.refineCore.queryResult
|
|
17201
|
-
});
|
|
17202
|
-
React.useEffect(() => {
|
|
17203
|
-
if (!isExpired || isSubmitting || hasShownExpiredRef.current) {
|
|
17204
|
-
return;
|
|
17205
|
-
}
|
|
17206
|
-
hasShownExpiredRef.current = true;
|
|
17207
|
-
pushModal({
|
|
17208
|
-
component: DataExpiredModal,
|
|
17209
|
-
props: {
|
|
17210
|
-
onAbandon: () => {
|
|
17211
|
-
popModal();
|
|
17212
|
-
}
|
|
17213
|
-
}
|
|
17214
|
-
});
|
|
17215
|
-
}, [isExpired, isSubmitting, pushModal, popModal]);
|
|
17216
17190
|
const fieldsConfig = useFieldsConfig(
|
|
17217
17191
|
resourceConfig,
|
|
17218
17192
|
{ fields: formConfig == null ? void 0 : formConfig.fields },
|
|
@@ -17244,13 +17218,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17244
17218
|
action,
|
|
17245
17219
|
isShowLayout: false,
|
|
17246
17220
|
useFormProps: {
|
|
17247
|
-
redirect: false
|
|
17248
|
-
onSubmitStart: () => {
|
|
17249
|
-
setIsSubmitting(true);
|
|
17250
|
-
},
|
|
17251
|
-
onSubmitAbort: () => {
|
|
17252
|
-
setIsSubmitting(false);
|
|
17253
|
-
}
|
|
17221
|
+
redirect: false
|
|
17254
17222
|
},
|
|
17255
17223
|
rules: fieldsConfig == null ? void 0 : fieldsConfig.filter(
|
|
17256
17224
|
(config) => "isSkipValidationInYaml" in config && !config.isSkipValidationInYaml
|
|
@@ -17498,37 +17466,39 @@ function FormModal(props) {
|
|
|
17498
17466
|
setStep(nextStep);
|
|
17499
17467
|
}
|
|
17500
17468
|
}, [step]);
|
|
17501
|
-
return /* @__PURE__ */ common.jsxRuntimeExports.
|
|
17502
|
-
|
|
17503
|
-
|
|
17504
|
-
|
|
17505
|
-
|
|
17506
|
-
|
|
17507
|
-
|
|
17508
|
-
children:
|
|
17509
|
-
|
|
17510
|
-
formConfig:
|
|
17511
|
-
|
|
17512
|
-
|
|
17513
|
-
|
|
17514
|
-
|
|
17515
|
-
|
|
17516
|
-
|
|
17517
|
-
|
|
17518
|
-
|
|
17519
|
-
|
|
17520
|
-
|
|
17521
|
-
|
|
17522
|
-
|
|
17523
|
-
|
|
17524
|
-
|
|
17525
|
-
|
|
17526
|
-
|
|
17527
|
-
|
|
17528
|
-
|
|
17529
|
-
|
|
17530
|
-
|
|
17531
|
-
|
|
17469
|
+
return /* @__PURE__ */ common.jsxRuntimeExports.jsx(Retry409Provider, {
|
|
17470
|
+
children: /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.WizardDialog, {
|
|
17471
|
+
style: {
|
|
17472
|
+
"--max-modal-width": isYamlForm || !isDisabledChangeMode ? "1024px" : "648px"
|
|
17473
|
+
},
|
|
17474
|
+
title: /* @__PURE__ */ common.jsxRuntimeExports.jsxs("div", {
|
|
17475
|
+
className: TitleWrapperStyle,
|
|
17476
|
+
children: [/* @__PURE__ */ common.jsxRuntimeExports.jsx("span", {
|
|
17477
|
+
children: title
|
|
17478
|
+
}), ((_b = resourceConfig.formConfig) == null ? void 0 : _b.formType) === FormType.FORM ? /* @__PURE__ */ common.jsxRuntimeExports.jsx(FormModeSegmentControl, {
|
|
17479
|
+
formConfig: resourceConfig.formConfig,
|
|
17480
|
+
mode,
|
|
17481
|
+
onChangeMode
|
|
17482
|
+
}) : null]
|
|
17483
|
+
}),
|
|
17484
|
+
error: errorText,
|
|
17485
|
+
steps,
|
|
17486
|
+
step,
|
|
17487
|
+
onStepChange: handleStepChange,
|
|
17488
|
+
onOk,
|
|
17489
|
+
okButtonProps: {
|
|
17490
|
+
...lodashEs.omit(saveButtonProps, "onClick"),
|
|
17491
|
+
children: (_c = resourceConfig.formConfig) == null ? void 0 : _c.saveButtonText
|
|
17492
|
+
},
|
|
17493
|
+
okText: ((_d = resourceConfig.formConfig) == null ? void 0 : _d.saveButtonText) || okText,
|
|
17494
|
+
destroyOnClose: true,
|
|
17495
|
+
destroyOtherStep: true,
|
|
17496
|
+
...modalProps,
|
|
17497
|
+
children: [desc ? /* @__PURE__ */ common.jsxRuntimeExports.jsx("div", {
|
|
17498
|
+
className: FormDescStyle,
|
|
17499
|
+
children: desc
|
|
17500
|
+
}) : void 0, formEle]
|
|
17501
|
+
})
|
|
17532
17502
|
});
|
|
17533
17503
|
}
|
|
17534
17504
|
const RefineFormPage_1v0fhor = "";
|