@dovetail-v2/refine 0.3.29-alpha.2 → 0.3.30-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.
- package/dist/components/Form/DataExpiredModal.d.ts +5 -0
- package/dist/hooks/useResourceVersionCheck.d.ts +9 -0
- package/dist/i18n.d.ts +8 -0
- package/dist/locales/en-US/index.d.ts +4 -0
- package/dist/locales/zh-CN/index.d.ts +4 -0
- package/dist/refine.cjs +125 -6
- package/dist/refine.js +126 -7
- package/dist/style.css +108 -58
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseRecord } from '@refinedev/core';
|
|
2
|
+
import { QueryObserverResult } from '@tanstack/react-query';
|
|
3
|
+
interface UseResourceVersionCheckParams {
|
|
4
|
+
queryResult?: QueryObserverResult<{
|
|
5
|
+
data: BaseRecord;
|
|
6
|
+
}>;
|
|
7
|
+
}
|
|
8
|
+
export declare const useResourceVersionCheck: ({ queryResult, }: UseResourceVersionCheckParams) => boolean;
|
|
9
|
+
export {};
|
package/dist/i18n.d.ts
CHANGED
|
@@ -184,6 +184,10 @@ export declare const resources: {
|
|
|
184
184
|
connecting: string;
|
|
185
185
|
reconnect: string;
|
|
186
186
|
edit_form: string;
|
|
187
|
+
data_expired: string;
|
|
188
|
+
data_expired_body: string;
|
|
189
|
+
data_expired_note: string;
|
|
190
|
+
abandon_edit: string;
|
|
187
191
|
exit_yaml_tip: string;
|
|
188
192
|
value_optional: string;
|
|
189
193
|
effect: string;
|
|
@@ -466,6 +470,10 @@ export declare const resources: {
|
|
|
466
470
|
reconnect: string;
|
|
467
471
|
search: string;
|
|
468
472
|
edit_form: string;
|
|
473
|
+
data_expired: string;
|
|
474
|
+
data_expired_body: string;
|
|
475
|
+
data_expired_note: string;
|
|
476
|
+
abandon_edit: string;
|
|
469
477
|
exit_yaml_tip: string;
|
|
470
478
|
form: string;
|
|
471
479
|
yaml: string;
|
|
@@ -181,6 +181,10 @@ declare const _default: {
|
|
|
181
181
|
connecting: string;
|
|
182
182
|
reconnect: string;
|
|
183
183
|
edit_form: string;
|
|
184
|
+
data_expired: string;
|
|
185
|
+
data_expired_body: string;
|
|
186
|
+
data_expired_note: string;
|
|
187
|
+
abandon_edit: string;
|
|
184
188
|
exit_yaml_tip: string;
|
|
185
189
|
value_optional: string;
|
|
186
190
|
effect: string;
|
|
@@ -183,6 +183,10 @@ declare const _default: {
|
|
|
183
183
|
reconnect: string;
|
|
184
184
|
search: string;
|
|
185
185
|
edit_form: string;
|
|
186
|
+
data_expired: string;
|
|
187
|
+
data_expired_body: string;
|
|
188
|
+
data_expired_note: string;
|
|
189
|
+
abandon_edit: string;
|
|
186
190
|
exit_yaml_tip: string;
|
|
187
191
|
form: string;
|
|
188
192
|
yaml: string;
|
package/dist/refine.cjs
CHANGED
|
@@ -638,6 +638,10 @@ const disconnected$1 = "Connection Error.";
|
|
|
638
638
|
const connecting$1 = "Connecting...";
|
|
639
639
|
const reconnect$1 = "Reconnect";
|
|
640
640
|
const edit_form$1 = "Edit form";
|
|
641
|
+
const data_expired$1 = "Data expired";
|
|
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
|
+
const data_expired_note$1 = "Your current entries will not be saved.";
|
|
644
|
+
const abandon_edit$1 = "Discard edit";
|
|
641
645
|
const exit_yaml_tip$1 = "If you go back to the form, any changes made to the YAML file will be lost.";
|
|
642
646
|
const value_optional$1 = "Value (optional)";
|
|
643
647
|
const effect$1 = "Effect";
|
|
@@ -915,6 +919,10 @@ const dovetail$1 = {
|
|
|
915
919
|
connecting: connecting$1,
|
|
916
920
|
reconnect: reconnect$1,
|
|
917
921
|
edit_form: edit_form$1,
|
|
922
|
+
data_expired: data_expired$1,
|
|
923
|
+
data_expired_body: data_expired_body$1,
|
|
924
|
+
data_expired_note: data_expired_note$1,
|
|
925
|
+
abandon_edit: abandon_edit$1,
|
|
918
926
|
exit_yaml_tip: exit_yaml_tip$1,
|
|
919
927
|
value_optional: value_optional$1,
|
|
920
928
|
effect: effect$1,
|
|
@@ -1194,6 +1202,10 @@ const connecting = "正在连接...";
|
|
|
1194
1202
|
const reconnect = "重新连接";
|
|
1195
1203
|
const search = "搜索";
|
|
1196
1204
|
const edit_form = "编辑表单";
|
|
1205
|
+
const data_expired = "数据已过期";
|
|
1206
|
+
const data_expired_body = "当前表单中的数据已不是最新版。为避免保存失败,请放弃本次编辑,并重新打开表单进行编辑。";
|
|
1207
|
+
const data_expired_note = "当前已填写内容将不会保留。";
|
|
1208
|
+
const abandon_edit = "放弃编辑";
|
|
1197
1209
|
const exit_yaml_tip = "返回编辑表单,不会保留对 YAML 文件做出的所有更改。";
|
|
1198
1210
|
const form = "表单";
|
|
1199
1211
|
const yaml = "YAML";
|
|
@@ -1470,6 +1482,10 @@ const dovetail = {
|
|
|
1470
1482
|
reconnect,
|
|
1471
1483
|
search,
|
|
1472
1484
|
edit_form,
|
|
1485
|
+
data_expired,
|
|
1486
|
+
data_expired_body,
|
|
1487
|
+
data_expired_note,
|
|
1488
|
+
abandon_edit,
|
|
1473
1489
|
exit_yaml_tip,
|
|
1474
1490
|
form,
|
|
1475
1491
|
yaml,
|
|
@@ -8048,7 +8064,7 @@ function MetadataForm() {
|
|
|
8048
8064
|
}
|
|
8049
8065
|
const ComponentContext = React.createContext({});
|
|
8050
8066
|
const GlobalStoreContext = React.createContext({});
|
|
8051
|
-
const
|
|
8067
|
+
const index_1s9fcl3 = "";
|
|
8052
8068
|
const ErrorWrapper = /* @__PURE__ */ styled_default("div")({
|
|
8053
8069
|
name: "ErrorWrapper",
|
|
8054
8070
|
class: "egn3dbn",
|
|
@@ -10685,6 +10701,26 @@ function usePathMap(options) {
|
|
|
10685
10701
|
transformApplyValues
|
|
10686
10702
|
};
|
|
10687
10703
|
}
|
|
10704
|
+
const useResourceVersionCheck = ({
|
|
10705
|
+
queryResult
|
|
10706
|
+
}) => {
|
|
10707
|
+
var _a, _b, _c;
|
|
10708
|
+
const initialResourceVersionRef = React.useRef();
|
|
10709
|
+
const [isExpired, setIsExpired] = React.useState(false);
|
|
10710
|
+
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;
|
|
10711
|
+
React.useEffect(() => {
|
|
10712
|
+
if (!currentResourceVersion)
|
|
10713
|
+
return;
|
|
10714
|
+
if (!initialResourceVersionRef.current) {
|
|
10715
|
+
initialResourceVersionRef.current = currentResourceVersion;
|
|
10716
|
+
return;
|
|
10717
|
+
}
|
|
10718
|
+
if (currentResourceVersion !== initialResourceVersionRef.current) {
|
|
10719
|
+
setIsExpired(true);
|
|
10720
|
+
}
|
|
10721
|
+
}, [currentResourceVersion]);
|
|
10722
|
+
return isExpired;
|
|
10723
|
+
};
|
|
10688
10724
|
function getInitialValues(resourceConfig) {
|
|
10689
10725
|
return resourceConfig.initValue || {
|
|
10690
10726
|
apiVersion: resourceConfig.apiVersion,
|
|
@@ -10693,6 +10729,42 @@ function getInitialValues(resourceConfig) {
|
|
|
10693
10729
|
spec: {}
|
|
10694
10730
|
};
|
|
10695
10731
|
}
|
|
10732
|
+
const button_1v659kh = "";
|
|
10733
|
+
const WarningButtonStyle = "wwyz7ti";
|
|
10734
|
+
const DataExpiredModal_eazxh6 = "";
|
|
10735
|
+
const NoteStyle = "n609wlp";
|
|
10736
|
+
function DataExpiredModal({
|
|
10737
|
+
onAbandon
|
|
10738
|
+
}) {
|
|
10739
|
+
const {
|
|
10740
|
+
t: t2
|
|
10741
|
+
} = common.useTranslation();
|
|
10742
|
+
return /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.SmallDialog, {
|
|
10743
|
+
title: t2("dovetail.data_expired"),
|
|
10744
|
+
closable: false,
|
|
10745
|
+
maskClosable: false,
|
|
10746
|
+
cancelButtonProps: {
|
|
10747
|
+
style: {
|
|
10748
|
+
display: "none"
|
|
10749
|
+
}
|
|
10750
|
+
},
|
|
10751
|
+
okText: t2("dovetail.abandon_edit"),
|
|
10752
|
+
okButtonProps: {
|
|
10753
|
+
className: WarningButtonStyle
|
|
10754
|
+
},
|
|
10755
|
+
onOk: (popModal) => {
|
|
10756
|
+
popModal();
|
|
10757
|
+
onAbandon();
|
|
10758
|
+
},
|
|
10759
|
+
children: [/* @__PURE__ */ common.jsxRuntimeExports.jsx("div", {
|
|
10760
|
+
className: eagle.Typo.Label.l2_regular,
|
|
10761
|
+
children: t2("dovetail.data_expired_body")
|
|
10762
|
+
}), /* @__PURE__ */ common.jsxRuntimeExports.jsx("div", {
|
|
10763
|
+
className: `${eagle.Typo.Label.l2_regular} ${NoteStyle}`,
|
|
10764
|
+
children: t2("dovetail.data_expired_note")
|
|
10765
|
+
})]
|
|
10766
|
+
});
|
|
10767
|
+
}
|
|
10696
10768
|
const index_az4wrx = "";
|
|
10697
10769
|
const WrapperStyle$5 = "w1akirqw";
|
|
10698
10770
|
const TitleStyle$2 = "t30srnq";
|
|
@@ -11575,6 +11647,29 @@ function YamlFormContainer({
|
|
|
11575
11647
|
onSaveButtonPropsChange
|
|
11576
11648
|
}) {
|
|
11577
11649
|
const action = id ? "edit" : "create";
|
|
11650
|
+
const pushModal = eagle.usePushModal();
|
|
11651
|
+
const popModal = eagle.usePopModal();
|
|
11652
|
+
const hasShownExpiredRef = React.useRef(false);
|
|
11653
|
+
const queryResult = core.useOne({
|
|
11654
|
+
resource: resourceConfig.name,
|
|
11655
|
+
id,
|
|
11656
|
+
liveMode: id ? "auto" : "off",
|
|
11657
|
+
queryOptions: { enabled: !!id }
|
|
11658
|
+
});
|
|
11659
|
+
const isExpired = useResourceVersionCheck({ queryResult });
|
|
11660
|
+
React.useEffect(() => {
|
|
11661
|
+
if (isExpired && !hasShownExpiredRef.current) {
|
|
11662
|
+
hasShownExpiredRef.current = true;
|
|
11663
|
+
pushModal({
|
|
11664
|
+
component: DataExpiredModal,
|
|
11665
|
+
props: {
|
|
11666
|
+
onAbandon: () => {
|
|
11667
|
+
popModal();
|
|
11668
|
+
}
|
|
11669
|
+
}
|
|
11670
|
+
});
|
|
11671
|
+
}
|
|
11672
|
+
}, [isExpired, pushModal, popModal]);
|
|
11578
11673
|
const { transformInitValues, transformApplyValues } = usePathMap({
|
|
11579
11674
|
pathMap: formConfig == null ? void 0 : formConfig.pathMap,
|
|
11580
11675
|
transformInitValues: formConfig == null ? void 0 : formConfig.transformInitValues,
|
|
@@ -12061,11 +12156,18 @@ function K8sDropdown(props) {
|
|
|
12061
12156
|
}
|
|
12062
12157
|
});
|
|
12063
12158
|
const formType = (_b = config == null ? void 0 : config.formConfig) == null ? void 0 : _b.formType;
|
|
12159
|
+
const { action } = core.useParsed();
|
|
12160
|
+
const { resource } = core.useResource();
|
|
12161
|
+
const isInShowPage = action === "show";
|
|
12162
|
+
const isSameResource = resourceName === (resource == null ? void 0 : resource.name);
|
|
12163
|
+
const isShowPageSameResource = isInShowPage && isSameResource;
|
|
12164
|
+
const shouldHideEdit = hideEditProp || isShowPageSameResource;
|
|
12165
|
+
const shouldHideEditYaml = hideEditYaml || formType !== FormType.FORM;
|
|
12064
12166
|
return /* @__PURE__ */ common.jsxRuntimeExports.jsx(common.jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
12065
12167
|
eagle.Dropdown,
|
|
12066
12168
|
{
|
|
12067
12169
|
overlay: /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.Menu, { children: [
|
|
12068
|
-
|
|
12170
|
+
shouldHideEdit || (canEditData == null ? void 0 : canEditData.can) === false || (config == null ? void 0 : config.hideEdit) ? null : /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
12069
12171
|
eagle.Menu.Item,
|
|
12070
12172
|
{
|
|
12071
12173
|
onClick: () => openForm({ id: record.id, resourceName, resourceConfig: config }),
|
|
@@ -12075,7 +12177,7 @@ function K8sDropdown(props) {
|
|
|
12075
12177
|
)}` : t2("dovetail.edit_yaml") })
|
|
12076
12178
|
}
|
|
12077
12179
|
),
|
|
12078
|
-
|
|
12180
|
+
shouldHideEditYaml || (canEditData == null ? void 0 : canEditData.can) === false || (config == null ? void 0 : config.hideEdit) ? null : /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
12079
12181
|
eagle.Menu.Item,
|
|
12080
12182
|
{
|
|
12081
12183
|
onClick: () => openForm({
|
|
@@ -15938,8 +16040,6 @@ function ResourceShow(props) {
|
|
|
15938
16040
|
}
|
|
15939
16041
|
);
|
|
15940
16042
|
}
|
|
15941
|
-
const button_1v659kh = "";
|
|
15942
|
-
const WarningButtonStyle = "wwyz7ti";
|
|
15943
16043
|
const modal_1eijuvm = "";
|
|
15944
16044
|
const SmallModalStyle = "s1nc293e";
|
|
15945
16045
|
function FormModeSegmentControl({
|
|
@@ -16972,7 +17072,7 @@ const useRefineForm = (props) => {
|
|
|
16972
17072
|
resource: resourceConfig.name,
|
|
16973
17073
|
action: id ? "edit" : "create",
|
|
16974
17074
|
id,
|
|
16975
|
-
liveMode: "off",
|
|
17075
|
+
liveMode: id ? "auto" : "off",
|
|
16976
17076
|
...refineProps
|
|
16977
17077
|
},
|
|
16978
17078
|
defaultValues: (options == null ? void 0 : options.initialValues) || (resourceConfig == null ? void 0 : resourceConfig.initValue),
|
|
@@ -17016,6 +17116,9 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17016
17116
|
}, ref) {
|
|
17017
17117
|
var _a, _b;
|
|
17018
17118
|
const action = id ? "edit" : "create";
|
|
17119
|
+
const pushModal = eagle.usePushModal();
|
|
17120
|
+
const popModal = eagle.usePopModal();
|
|
17121
|
+
const hasShownExpiredRef = React.useRef(false);
|
|
17019
17122
|
const refineFormResult = useRefineForm({
|
|
17020
17123
|
resourceConfig,
|
|
17021
17124
|
id,
|
|
@@ -17042,6 +17145,22 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17042
17145
|
}
|
|
17043
17146
|
}
|
|
17044
17147
|
});
|
|
17148
|
+
const isExpired = useResourceVersionCheck({
|
|
17149
|
+
queryResult: refineFormResult.formResult.refineCore.queryResult
|
|
17150
|
+
});
|
|
17151
|
+
React.useEffect(() => {
|
|
17152
|
+
if (isExpired && !hasShownExpiredRef.current) {
|
|
17153
|
+
hasShownExpiredRef.current = true;
|
|
17154
|
+
pushModal({
|
|
17155
|
+
component: DataExpiredModal,
|
|
17156
|
+
props: {
|
|
17157
|
+
onAbandon: () => {
|
|
17158
|
+
popModal();
|
|
17159
|
+
}
|
|
17160
|
+
}
|
|
17161
|
+
});
|
|
17162
|
+
}
|
|
17163
|
+
}, [isExpired, pushModal, popModal]);
|
|
17045
17164
|
const fieldsConfig = useFieldsConfig(
|
|
17046
17165
|
resourceConfig,
|
|
17047
17166
|
{ fields: formConfig == null ? void 0 : formConfig.fields },
|
package/dist/refine.js
CHANGED
|
@@ -7,7 +7,7 @@ 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, 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, useOne, 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";
|
|
@@ -619,6 +619,10 @@ const disconnected$1 = "Connection Error.";
|
|
|
619
619
|
const connecting$1 = "Connecting...";
|
|
620
620
|
const reconnect$1 = "Reconnect";
|
|
621
621
|
const edit_form$1 = "Edit form";
|
|
622
|
+
const data_expired$1 = "Data expired";
|
|
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
|
+
const data_expired_note$1 = "Your current entries will not be saved.";
|
|
625
|
+
const abandon_edit$1 = "Discard edit";
|
|
622
626
|
const exit_yaml_tip$1 = "If you go back to the form, any changes made to the YAML file will be lost.";
|
|
623
627
|
const value_optional$1 = "Value (optional)";
|
|
624
628
|
const effect$1 = "Effect";
|
|
@@ -896,6 +900,10 @@ const dovetail$1 = {
|
|
|
896
900
|
connecting: connecting$1,
|
|
897
901
|
reconnect: reconnect$1,
|
|
898
902
|
edit_form: edit_form$1,
|
|
903
|
+
data_expired: data_expired$1,
|
|
904
|
+
data_expired_body: data_expired_body$1,
|
|
905
|
+
data_expired_note: data_expired_note$1,
|
|
906
|
+
abandon_edit: abandon_edit$1,
|
|
899
907
|
exit_yaml_tip: exit_yaml_tip$1,
|
|
900
908
|
value_optional: value_optional$1,
|
|
901
909
|
effect: effect$1,
|
|
@@ -1175,6 +1183,10 @@ const connecting = "正在连接...";
|
|
|
1175
1183
|
const reconnect = "重新连接";
|
|
1176
1184
|
const search = "搜索";
|
|
1177
1185
|
const edit_form = "编辑表单";
|
|
1186
|
+
const data_expired = "数据已过期";
|
|
1187
|
+
const data_expired_body = "当前表单中的数据已不是最新版。为避免保存失败,请放弃本次编辑,并重新打开表单进行编辑。";
|
|
1188
|
+
const data_expired_note = "当前已填写内容将不会保留。";
|
|
1189
|
+
const abandon_edit = "放弃编辑";
|
|
1178
1190
|
const exit_yaml_tip = "返回编辑表单,不会保留对 YAML 文件做出的所有更改。";
|
|
1179
1191
|
const form = "表单";
|
|
1180
1192
|
const yaml = "YAML";
|
|
@@ -1451,6 +1463,10 @@ const dovetail = {
|
|
|
1451
1463
|
reconnect,
|
|
1452
1464
|
search,
|
|
1453
1465
|
edit_form,
|
|
1466
|
+
data_expired,
|
|
1467
|
+
data_expired_body,
|
|
1468
|
+
data_expired_note,
|
|
1469
|
+
abandon_edit,
|
|
1454
1470
|
exit_yaml_tip,
|
|
1455
1471
|
form,
|
|
1456
1472
|
yaml,
|
|
@@ -8029,7 +8045,7 @@ function MetadataForm() {
|
|
|
8029
8045
|
}
|
|
8030
8046
|
const ComponentContext = createContext({});
|
|
8031
8047
|
const GlobalStoreContext = createContext({});
|
|
8032
|
-
const
|
|
8048
|
+
const index_1s9fcl3 = "";
|
|
8033
8049
|
const ErrorWrapper = /* @__PURE__ */ styled_default("div")({
|
|
8034
8050
|
name: "ErrorWrapper",
|
|
8035
8051
|
class: "egn3dbn",
|
|
@@ -10666,6 +10682,26 @@ function usePathMap(options) {
|
|
|
10666
10682
|
transformApplyValues
|
|
10667
10683
|
};
|
|
10668
10684
|
}
|
|
10685
|
+
const useResourceVersionCheck = ({
|
|
10686
|
+
queryResult
|
|
10687
|
+
}) => {
|
|
10688
|
+
var _a, _b, _c;
|
|
10689
|
+
const initialResourceVersionRef = useRef();
|
|
10690
|
+
const [isExpired, setIsExpired] = useState(false);
|
|
10691
|
+
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;
|
|
10692
|
+
useEffect(() => {
|
|
10693
|
+
if (!currentResourceVersion)
|
|
10694
|
+
return;
|
|
10695
|
+
if (!initialResourceVersionRef.current) {
|
|
10696
|
+
initialResourceVersionRef.current = currentResourceVersion;
|
|
10697
|
+
return;
|
|
10698
|
+
}
|
|
10699
|
+
if (currentResourceVersion !== initialResourceVersionRef.current) {
|
|
10700
|
+
setIsExpired(true);
|
|
10701
|
+
}
|
|
10702
|
+
}, [currentResourceVersion]);
|
|
10703
|
+
return isExpired;
|
|
10704
|
+
};
|
|
10669
10705
|
function getInitialValues(resourceConfig) {
|
|
10670
10706
|
return resourceConfig.initValue || {
|
|
10671
10707
|
apiVersion: resourceConfig.apiVersion,
|
|
@@ -10674,6 +10710,42 @@ function getInitialValues(resourceConfig) {
|
|
|
10674
10710
|
spec: {}
|
|
10675
10711
|
};
|
|
10676
10712
|
}
|
|
10713
|
+
const button_1v659kh = "";
|
|
10714
|
+
const WarningButtonStyle = "wwyz7ti";
|
|
10715
|
+
const DataExpiredModal_eazxh6 = "";
|
|
10716
|
+
const NoteStyle = "n609wlp";
|
|
10717
|
+
function DataExpiredModal({
|
|
10718
|
+
onAbandon
|
|
10719
|
+
}) {
|
|
10720
|
+
const {
|
|
10721
|
+
t: t2
|
|
10722
|
+
} = useTranslation();
|
|
10723
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(SmallDialog, {
|
|
10724
|
+
title: t2("dovetail.data_expired"),
|
|
10725
|
+
closable: false,
|
|
10726
|
+
maskClosable: false,
|
|
10727
|
+
cancelButtonProps: {
|
|
10728
|
+
style: {
|
|
10729
|
+
display: "none"
|
|
10730
|
+
}
|
|
10731
|
+
},
|
|
10732
|
+
okText: t2("dovetail.abandon_edit"),
|
|
10733
|
+
okButtonProps: {
|
|
10734
|
+
className: WarningButtonStyle
|
|
10735
|
+
},
|
|
10736
|
+
onOk: (popModal) => {
|
|
10737
|
+
popModal();
|
|
10738
|
+
onAbandon();
|
|
10739
|
+
},
|
|
10740
|
+
children: [/* @__PURE__ */ jsxRuntimeExports.jsx("div", {
|
|
10741
|
+
className: Typo.Label.l2_regular,
|
|
10742
|
+
children: t2("dovetail.data_expired_body")
|
|
10743
|
+
}), /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
|
|
10744
|
+
className: `${Typo.Label.l2_regular} ${NoteStyle}`,
|
|
10745
|
+
children: t2("dovetail.data_expired_note")
|
|
10746
|
+
})]
|
|
10747
|
+
});
|
|
10748
|
+
}
|
|
10677
10749
|
const index_az4wrx = "";
|
|
10678
10750
|
const WrapperStyle$5 = "w1akirqw";
|
|
10679
10751
|
const TitleStyle$2 = "t30srnq";
|
|
@@ -11556,6 +11628,29 @@ function YamlFormContainer({
|
|
|
11556
11628
|
onSaveButtonPropsChange
|
|
11557
11629
|
}) {
|
|
11558
11630
|
const action = id ? "edit" : "create";
|
|
11631
|
+
const pushModal = usePushModal();
|
|
11632
|
+
const popModal = usePopModal();
|
|
11633
|
+
const hasShownExpiredRef = useRef(false);
|
|
11634
|
+
const queryResult = useOne({
|
|
11635
|
+
resource: resourceConfig.name,
|
|
11636
|
+
id,
|
|
11637
|
+
liveMode: id ? "auto" : "off",
|
|
11638
|
+
queryOptions: { enabled: !!id }
|
|
11639
|
+
});
|
|
11640
|
+
const isExpired = useResourceVersionCheck({ queryResult });
|
|
11641
|
+
useEffect(() => {
|
|
11642
|
+
if (isExpired && !hasShownExpiredRef.current) {
|
|
11643
|
+
hasShownExpiredRef.current = true;
|
|
11644
|
+
pushModal({
|
|
11645
|
+
component: DataExpiredModal,
|
|
11646
|
+
props: {
|
|
11647
|
+
onAbandon: () => {
|
|
11648
|
+
popModal();
|
|
11649
|
+
}
|
|
11650
|
+
}
|
|
11651
|
+
});
|
|
11652
|
+
}
|
|
11653
|
+
}, [isExpired, pushModal, popModal]);
|
|
11559
11654
|
const { transformInitValues, transformApplyValues } = usePathMap({
|
|
11560
11655
|
pathMap: formConfig == null ? void 0 : formConfig.pathMap,
|
|
11561
11656
|
transformInitValues: formConfig == null ? void 0 : formConfig.transformInitValues,
|
|
@@ -12042,11 +12137,18 @@ function K8sDropdown(props) {
|
|
|
12042
12137
|
}
|
|
12043
12138
|
});
|
|
12044
12139
|
const formType = (_b = config == null ? void 0 : config.formConfig) == null ? void 0 : _b.formType;
|
|
12140
|
+
const { action } = useParsed();
|
|
12141
|
+
const { resource } = useResource();
|
|
12142
|
+
const isInShowPage = action === "show";
|
|
12143
|
+
const isSameResource = resourceName === (resource == null ? void 0 : resource.name);
|
|
12144
|
+
const isShowPageSameResource = isInShowPage && isSameResource;
|
|
12145
|
+
const shouldHideEdit = hideEditProp || isShowPageSameResource;
|
|
12146
|
+
const shouldHideEditYaml = hideEditYaml || formType !== FormType.FORM;
|
|
12045
12147
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
12046
12148
|
Dropdown,
|
|
12047
12149
|
{
|
|
12048
12150
|
overlay: /* @__PURE__ */ jsxRuntimeExports.jsxs(Menu$1, { children: [
|
|
12049
|
-
|
|
12151
|
+
shouldHideEdit || (canEditData == null ? void 0 : canEditData.can) === false || (config == null ? void 0 : config.hideEdit) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
12050
12152
|
Menu$1.Item,
|
|
12051
12153
|
{
|
|
12052
12154
|
onClick: () => openForm({ id: record.id, resourceName, resourceConfig: config }),
|
|
@@ -12056,7 +12158,7 @@ function K8sDropdown(props) {
|
|
|
12056
12158
|
)}` : t2("dovetail.edit_yaml") })
|
|
12057
12159
|
}
|
|
12058
12160
|
),
|
|
12059
|
-
|
|
12161
|
+
shouldHideEditYaml || (canEditData == null ? void 0 : canEditData.can) === false || (config == null ? void 0 : config.hideEdit) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
12060
12162
|
Menu$1.Item,
|
|
12061
12163
|
{
|
|
12062
12164
|
onClick: () => openForm({
|
|
@@ -15919,8 +16021,6 @@ function ResourceShow(props) {
|
|
|
15919
16021
|
}
|
|
15920
16022
|
);
|
|
15921
16023
|
}
|
|
15922
|
-
const button_1v659kh = "";
|
|
15923
|
-
const WarningButtonStyle = "wwyz7ti";
|
|
15924
16024
|
const modal_1eijuvm = "";
|
|
15925
16025
|
const SmallModalStyle = "s1nc293e";
|
|
15926
16026
|
function FormModeSegmentControl({
|
|
@@ -16953,7 +17053,7 @@ const useRefineForm = (props) => {
|
|
|
16953
17053
|
resource: resourceConfig.name,
|
|
16954
17054
|
action: id ? "edit" : "create",
|
|
16955
17055
|
id,
|
|
16956
|
-
liveMode: "off",
|
|
17056
|
+
liveMode: id ? "auto" : "off",
|
|
16957
17057
|
...refineProps
|
|
16958
17058
|
},
|
|
16959
17059
|
defaultValues: (options == null ? void 0 : options.initialValues) || (resourceConfig == null ? void 0 : resourceConfig.initValue),
|
|
@@ -16997,6 +17097,9 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
16997
17097
|
}, ref) {
|
|
16998
17098
|
var _a, _b;
|
|
16999
17099
|
const action = id ? "edit" : "create";
|
|
17100
|
+
const pushModal = usePushModal();
|
|
17101
|
+
const popModal = usePopModal();
|
|
17102
|
+
const hasShownExpiredRef = useRef(false);
|
|
17000
17103
|
const refineFormResult = useRefineForm({
|
|
17001
17104
|
resourceConfig,
|
|
17002
17105
|
id,
|
|
@@ -17023,6 +17126,22 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17023
17126
|
}
|
|
17024
17127
|
}
|
|
17025
17128
|
});
|
|
17129
|
+
const isExpired = useResourceVersionCheck({
|
|
17130
|
+
queryResult: refineFormResult.formResult.refineCore.queryResult
|
|
17131
|
+
});
|
|
17132
|
+
useEffect(() => {
|
|
17133
|
+
if (isExpired && !hasShownExpiredRef.current) {
|
|
17134
|
+
hasShownExpiredRef.current = true;
|
|
17135
|
+
pushModal({
|
|
17136
|
+
component: DataExpiredModal,
|
|
17137
|
+
props: {
|
|
17138
|
+
onAbandon: () => {
|
|
17139
|
+
popModal();
|
|
17140
|
+
}
|
|
17141
|
+
}
|
|
17142
|
+
});
|
|
17143
|
+
}
|
|
17144
|
+
}, [isExpired, pushModal, popModal]);
|
|
17026
17145
|
const fieldsConfig = useFieldsConfig(
|
|
17027
17146
|
resourceConfig,
|
|
17028
17147
|
{ fields: formConfig == null ? void 0 : formConfig.fields },
|
package/dist/style.css
CHANGED
|
@@ -716,7 +716,7 @@
|
|
|
716
716
|
color: rgba(44, 56, 82, 0.6);
|
|
717
717
|
}
|
|
718
718
|
.egn3dbn.card {
|
|
719
|
-
padding:
|
|
719
|
+
padding: 8px 0;
|
|
720
720
|
}
|
|
721
721
|
.egn3dbn.card .title {
|
|
722
722
|
color: rgba(0, 21, 64, 0.3);
|
|
@@ -1148,6 +1148,113 @@
|
|
|
1148
1148
|
/* box shadow */
|
|
1149
1149
|
/* fisheye */
|
|
1150
1150
|
/* z-index */
|
|
1151
|
+
.wwyz7ti.ant-btn.ant-btn.ant-btn-primary {
|
|
1152
|
+
background-color: #fea008;
|
|
1153
|
+
}
|
|
1154
|
+
.wwyz7ti.ant-btn.ant-btn.ant-btn-primary:hover {
|
|
1155
|
+
background-color: #feba33;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
.c1xsou5f.ant-btn {
|
|
1159
|
+
border-radius: 6px;
|
|
1160
|
+
border: 1px solid rgba(172, 186, 211, 0.6) !important;
|
|
1161
|
+
}/* // basic */
|
|
1162
|
+
/* FishEye Color Variables and Functions */
|
|
1163
|
+
/*
|
|
1164
|
+
--------------------------- Primary Color ---------------------------
|
|
1165
|
+
*/
|
|
1166
|
+
/*
|
|
1167
|
+
---------------------------When necessary to add at any time---------------------------
|
|
1168
|
+
*/
|
|
1169
|
+
/* computed */
|
|
1170
|
+
/* blue */
|
|
1171
|
+
/* green */
|
|
1172
|
+
/* yellow */
|
|
1173
|
+
/* red */
|
|
1174
|
+
/* purple */
|
|
1175
|
+
/* palette global token*/
|
|
1176
|
+
/* color opaque */
|
|
1177
|
+
/* color transparent */
|
|
1178
|
+
/* blue transparent */
|
|
1179
|
+
/* green transparent */
|
|
1180
|
+
/* yellow transparent */
|
|
1181
|
+
/* red transparent */
|
|
1182
|
+
/* gray transparent */
|
|
1183
|
+
/* white transparent */
|
|
1184
|
+
/* gradient opaque */
|
|
1185
|
+
/* blue radial gradient */
|
|
1186
|
+
/* blue linear gradient */
|
|
1187
|
+
/* green radial gradient */
|
|
1188
|
+
/* yellow radial gradient */
|
|
1189
|
+
/* red radial gradient */
|
|
1190
|
+
/* gray radial gradient */
|
|
1191
|
+
/* white to gray radial gradient */
|
|
1192
|
+
/* white to gray linear gradient */
|
|
1193
|
+
/* gradient transparent */
|
|
1194
|
+
/* secondary palette */
|
|
1195
|
+
/* purple radial gradient */
|
|
1196
|
+
/* refine alias color */
|
|
1197
|
+
/* text */
|
|
1198
|
+
/* link */
|
|
1199
|
+
/* fill */
|
|
1200
|
+
/* fill element */
|
|
1201
|
+
/* fill interaction */
|
|
1202
|
+
/* stroke */
|
|
1203
|
+
/* background */
|
|
1204
|
+
/* dim */
|
|
1205
|
+
/* box shadow */
|
|
1206
|
+
/* fisheye */
|
|
1207
|
+
/* z-index */
|
|
1208
|
+
.n609wlp {
|
|
1209
|
+
margin-top: 8px;
|
|
1210
|
+
color: #2d3a56;
|
|
1211
|
+
}/* // basic */
|
|
1212
|
+
/* FishEye Color Variables and Functions */
|
|
1213
|
+
/*
|
|
1214
|
+
--------------------------- Primary Color ---------------------------
|
|
1215
|
+
*/
|
|
1216
|
+
/*
|
|
1217
|
+
---------------------------When necessary to add at any time---------------------------
|
|
1218
|
+
*/
|
|
1219
|
+
/* computed */
|
|
1220
|
+
/* blue */
|
|
1221
|
+
/* green */
|
|
1222
|
+
/* yellow */
|
|
1223
|
+
/* red */
|
|
1224
|
+
/* purple */
|
|
1225
|
+
/* palette global token*/
|
|
1226
|
+
/* color opaque */
|
|
1227
|
+
/* color transparent */
|
|
1228
|
+
/* blue transparent */
|
|
1229
|
+
/* green transparent */
|
|
1230
|
+
/* yellow transparent */
|
|
1231
|
+
/* red transparent */
|
|
1232
|
+
/* gray transparent */
|
|
1233
|
+
/* white transparent */
|
|
1234
|
+
/* gradient opaque */
|
|
1235
|
+
/* blue radial gradient */
|
|
1236
|
+
/* blue linear gradient */
|
|
1237
|
+
/* green radial gradient */
|
|
1238
|
+
/* yellow radial gradient */
|
|
1239
|
+
/* red radial gradient */
|
|
1240
|
+
/* gray radial gradient */
|
|
1241
|
+
/* white to gray radial gradient */
|
|
1242
|
+
/* white to gray linear gradient */
|
|
1243
|
+
/* gradient transparent */
|
|
1244
|
+
/* secondary palette */
|
|
1245
|
+
/* purple radial gradient */
|
|
1246
|
+
/* refine alias color */
|
|
1247
|
+
/* text */
|
|
1248
|
+
/* link */
|
|
1249
|
+
/* fill */
|
|
1250
|
+
/* fill element */
|
|
1251
|
+
/* fill interaction */
|
|
1252
|
+
/* stroke */
|
|
1253
|
+
/* background */
|
|
1254
|
+
/* dim */
|
|
1255
|
+
/* box shadow */
|
|
1256
|
+
/* fisheye */
|
|
1257
|
+
/* z-index */
|
|
1151
1258
|
.w1akirqw {
|
|
1152
1259
|
height: 100%;
|
|
1153
1260
|
display: flex;
|
|
@@ -4269,63 +4376,6 @@
|
|
|
4269
4376
|
/* box shadow */
|
|
4270
4377
|
/* fisheye */
|
|
4271
4378
|
/* z-index */
|
|
4272
|
-
.wwyz7ti.ant-btn.ant-btn.ant-btn-primary {
|
|
4273
|
-
background-color: #fea008;
|
|
4274
|
-
}
|
|
4275
|
-
.wwyz7ti.ant-btn.ant-btn.ant-btn-primary:hover {
|
|
4276
|
-
background-color: #feba33;
|
|
4277
|
-
}
|
|
4278
|
-
|
|
4279
|
-
.c1xsou5f.ant-btn {
|
|
4280
|
-
border-radius: 6px;
|
|
4281
|
-
border: 1px solid rgba(172, 186, 211, 0.6) !important;
|
|
4282
|
-
}/* // basic */
|
|
4283
|
-
/* FishEye Color Variables and Functions */
|
|
4284
|
-
/*
|
|
4285
|
-
--------------------------- Primary Color ---------------------------
|
|
4286
|
-
*/
|
|
4287
|
-
/*
|
|
4288
|
-
---------------------------When necessary to add at any time---------------------------
|
|
4289
|
-
*/
|
|
4290
|
-
/* computed */
|
|
4291
|
-
/* blue */
|
|
4292
|
-
/* green */
|
|
4293
|
-
/* yellow */
|
|
4294
|
-
/* red */
|
|
4295
|
-
/* purple */
|
|
4296
|
-
/* palette global token*/
|
|
4297
|
-
/* color opaque */
|
|
4298
|
-
/* color transparent */
|
|
4299
|
-
/* blue transparent */
|
|
4300
|
-
/* green transparent */
|
|
4301
|
-
/* yellow transparent */
|
|
4302
|
-
/* red transparent */
|
|
4303
|
-
/* gray transparent */
|
|
4304
|
-
/* white transparent */
|
|
4305
|
-
/* gradient opaque */
|
|
4306
|
-
/* blue radial gradient */
|
|
4307
|
-
/* blue linear gradient */
|
|
4308
|
-
/* green radial gradient */
|
|
4309
|
-
/* yellow radial gradient */
|
|
4310
|
-
/* red radial gradient */
|
|
4311
|
-
/* gray radial gradient */
|
|
4312
|
-
/* white to gray radial gradient */
|
|
4313
|
-
/* white to gray linear gradient */
|
|
4314
|
-
/* gradient transparent */
|
|
4315
|
-
/* secondary palette */
|
|
4316
|
-
/* purple radial gradient */
|
|
4317
|
-
/* refine alias color */
|
|
4318
|
-
/* text */
|
|
4319
|
-
/* link */
|
|
4320
|
-
/* fill */
|
|
4321
|
-
/* fill element */
|
|
4322
|
-
/* fill interaction */
|
|
4323
|
-
/* stroke */
|
|
4324
|
-
/* background */
|
|
4325
|
-
/* dim */
|
|
4326
|
-
/* box shadow */
|
|
4327
|
-
/* fisheye */
|
|
4328
|
-
/* z-index */
|
|
4329
4379
|
.fq4465w.ant-modal.fullscreen .ant-modal-header {
|
|
4330
4380
|
padding: 60px 0 32px 0;
|
|
4331
4381
|
max-width: var(--max-modal-width, 1024px);
|