@dovetail-v2/refine 0.4.1 → 0.4.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/EditMetadataForm/LabelFormatPopover.d.ts +0 -1
- package/dist/components/Form/YamlForm.d.ts +2 -0
- package/dist/components/Form/useReactHookForm.d.ts +3 -1
- package/dist/components/Form/useYamlForm.d.ts +3 -1
- package/dist/components/KeyValueTableForm/FormatRulePopover.d.ts +7 -0
- package/dist/components/KeyValueTableForm/index.d.ts +3 -1
- package/dist/hooks/useEagleTable/useEagleTable.d.ts +1 -1
- package/dist/refine.cjs +137 -89
- package/dist/refine.js +137 -89
- package/dist/style.css +11 -23
- package/dist/types/resource.d.ts +20 -0
- package/package.json +10 -3
|
@@ -24,6 +24,8 @@ export interface YamlFormProps<Model extends ResourceModel = ResourceModel> {
|
|
|
24
24
|
transformInitValues?: (values: Record<string, unknown>) => Record<string, unknown>;
|
|
25
25
|
transformApplyValues?: (values: Unstructured) => Unstructured;
|
|
26
26
|
beforeSubmit?: (values: Unstructured, setErrors: (errors: string[]) => void) => Promise<Unstructured>;
|
|
27
|
+
/** 自定义提交函数,存在时替代 refine core 的 onFinish */
|
|
28
|
+
onSubmit?: (values: Record<string, unknown>) => Promise<unknown>;
|
|
27
29
|
onSaveButtonPropsChange?: (saveButtonProps: {
|
|
28
30
|
disabled?: boolean;
|
|
29
31
|
onClick: () => void;
|
|
@@ -34,5 +34,7 @@ export type UseFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError ex
|
|
|
34
34
|
onBeforeSubmitError?: (errors: string[]) => void;
|
|
35
35
|
onSubmitStart?: () => void;
|
|
36
36
|
onSubmitAbort?: () => void;
|
|
37
|
+
/** 自定义提交函数,存在时替代 refine core 的 onFinish */
|
|
38
|
+
onSubmit?: (values: Record<string, unknown>) => Promise<unknown>;
|
|
37
39
|
} & UseHookFormProps<TVariables, TContext>;
|
|
38
|
-
export declare const useForm: <TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables extends FieldValues = FieldValues, TContext extends object = object, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>({ refineCoreProps, warnWhenUnsavedChanges: warnWhenUnsavedChangesProp, disableServerSideValidation: disableServerSideValidationProp, transformApplyValues, transformInitValues, beforeSubmit, onBeforeSubmitError, onSubmitStart, onSubmitAbort, ...rest }?: UseFormProps<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>;
|
|
40
|
+
export declare const useForm: <TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables extends FieldValues = FieldValues, TContext extends object = object, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>({ refineCoreProps, warnWhenUnsavedChanges: warnWhenUnsavedChangesProp, disableServerSideValidation: disableServerSideValidationProp, transformApplyValues, transformInitValues, beforeSubmit, onBeforeSubmitError, onSubmitStart, onSubmitAbort, onSubmit, ...rest }?: UseFormProps<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>;
|
|
@@ -31,6 +31,8 @@ export type UseFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError ex
|
|
|
31
31
|
onBeforeSubmitError?: (errors: string[]) => void;
|
|
32
32
|
onSubmitStart?: () => void;
|
|
33
33
|
onSubmitAbort?: () => void;
|
|
34
|
+
/** 自定义提交函数,存在时替代 refine core 的 onFinish */
|
|
35
|
+
onSubmit?: (values: Record<string, unknown>) => Promise<unknown>;
|
|
34
36
|
rules?: YamlFormRule[];
|
|
35
37
|
};
|
|
36
38
|
export type UseFormReturnType<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables extends object = object, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError> = UseFormReturnTypeCore<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError> & {
|
|
@@ -55,5 +57,5 @@ declare const useYamlForm: <TQueryFnData extends Unstructured = Unstructured & {
|
|
|
55
57
|
[prop: string]: unknown;
|
|
56
58
|
} = {
|
|
57
59
|
[prop: string]: unknown;
|
|
58
|
-
}, TData extends Unstructured = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>({ action: actionFromProps, resource, onMutationSuccess: onMutationSuccessProp, onMutationError, submitOnEnter, warnWhenUnsavedChanges: warnWhenUnsavedChangesProp, redirect, successNotification, errorNotification, meta, metaData, queryMeta, mutationMeta, liveMode, liveParams, mutationMode, dataProviderName, onLiveEvent, invalidates, undoableTimeout, queryOptions, createMutationOptions, updateMutationOptions, id: idFromProps, overtimeOptions, editorOptions, initialValuesForCreate, initialValuesForEdit, transformInitValues, transformApplyValues, beforeSubmit, onBeforeSubmitError, onSubmitStart, onSubmitAbort, rules, }?: UseFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>;
|
|
60
|
+
}, TData extends Unstructured = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>({ action: actionFromProps, resource, onMutationSuccess: onMutationSuccessProp, onMutationError, submitOnEnter, warnWhenUnsavedChanges: warnWhenUnsavedChangesProp, redirect, successNotification, errorNotification, meta, metaData, queryMeta, mutationMeta, liveMode, liveParams, mutationMode, dataProviderName, onLiveEvent, invalidates, undoableTimeout, queryOptions, createMutationOptions, updateMutationOptions, id: idFromProps, overtimeOptions, editorOptions, initialValuesForCreate, initialValuesForEdit, transformInitValues, transformApplyValues, beforeSubmit, onBeforeSubmitError, onSubmitStart, onSubmitAbort, onSubmit, rules, }?: UseFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>;
|
|
59
61
|
export default useYamlForm;
|
|
@@ -31,6 +31,7 @@ interface KeyValueTableFormProps<T extends KeyValuePair> {
|
|
|
31
31
|
};
|
|
32
32
|
onSubmit?: (value: T[]) => Promise<unknown> | undefined;
|
|
33
33
|
keyTitle?: string;
|
|
34
|
+
formatPopover?: React.ReactNode;
|
|
34
35
|
}
|
|
35
36
|
export type KeyValueTableFormHandle<T extends KeyValuePair = KeyValuePair> = {
|
|
36
37
|
validate: () => Promise<boolean>;
|
|
@@ -38,4 +39,5 @@ export type KeyValueTableFormHandle<T extends KeyValuePair = KeyValuePair> = {
|
|
|
38
39
|
setValue: (value: T[]) => void;
|
|
39
40
|
};
|
|
40
41
|
export declare const KeyValueTableForm: React.ForwardRefExoticComponent<KeyValueTableFormProps<KeyValuePair> & React.RefAttributes<KeyValueTableFormHandle<KeyValuePair>>>;
|
|
41
|
-
export {};
|
|
42
|
+
export { FormatRulePopover } from './FormatRulePopover';
|
|
43
|
+
export type { FormatRulePopoverProps } from './FormatRulePopover';
|
|
@@ -27,7 +27,7 @@ export declare function addDefaultRenderToColumns<Data, Col extends RequiredColu
|
|
|
27
27
|
} & Col)[];
|
|
28
28
|
export declare const useEagleTable: <Model extends ResourceModel<import("k8s-api-provider").Unstructured>>(params: Params<Model>) => {
|
|
29
29
|
setCurrent: (current: number) => void;
|
|
30
|
-
tableQueryResult: import("@tanstack/query
|
|
30
|
+
tableQueryResult: import("@tanstack/react-query").QueryObserverResult<import("@refinedev/core").GetListResponse<Model>, import("@refinedev/core").HttpError>;
|
|
31
31
|
sorter: CrudSorting;
|
|
32
32
|
sorters: CrudSorting;
|
|
33
33
|
setSorter: (sorter: CrudSorting) => void;
|
package/dist/refine.cjs
CHANGED
|
@@ -65,18 +65,14 @@ var zh = { exports: {} };
|
|
|
65
65
|
});
|
|
66
66
|
})(zh);
|
|
67
67
|
function _extends() {
|
|
68
|
-
_extends = Object.assign ? Object.assign.bind() : function(
|
|
69
|
-
for (var
|
|
70
|
-
var
|
|
71
|
-
for (var
|
|
72
|
-
|
|
73
|
-
target[key2] = source[key2];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
68
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n2) {
|
|
69
|
+
for (var e2 = 1; e2 < arguments.length; e2++) {
|
|
70
|
+
var t2 = arguments[e2];
|
|
71
|
+
for (var r2 in t2)
|
|
72
|
+
({}).hasOwnProperty.call(t2, r2) && (n2[r2] = t2[r2]);
|
|
76
73
|
}
|
|
77
|
-
return
|
|
78
|
-
};
|
|
79
|
-
return _extends.apply(this, arguments);
|
|
74
|
+
return n2;
|
|
75
|
+
}, _extends.apply(null, arguments);
|
|
80
76
|
}
|
|
81
77
|
var voidElements = {
|
|
82
78
|
"area": true,
|
|
@@ -8247,7 +8243,9 @@ function useTableData({ data: data2, columns, pageSize = 10, defaultSorters }) {
|
|
|
8247
8243
|
pageSize,
|
|
8248
8244
|
current: currentPage
|
|
8249
8245
|
},
|
|
8246
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8250
8247
|
k8sApiProvider.sortData(sorters, data2)
|
|
8248
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8251
8249
|
),
|
|
8252
8250
|
currentPage,
|
|
8253
8251
|
onPageChange: setCurrentPage,
|
|
@@ -11250,6 +11248,7 @@ const useYamlForm = ({
|
|
|
11250
11248
|
onBeforeSubmitError,
|
|
11251
11249
|
onSubmitStart,
|
|
11252
11250
|
onSubmitAbort,
|
|
11251
|
+
onSubmit,
|
|
11253
11252
|
rules
|
|
11254
11253
|
} = {}) => {
|
|
11255
11254
|
var _a;
|
|
@@ -11463,6 +11462,11 @@ const useYamlForm = ({
|
|
|
11463
11462
|
setIsBeforeSubmitLoading(false);
|
|
11464
11463
|
}
|
|
11465
11464
|
}
|
|
11465
|
+
if (onSubmit) {
|
|
11466
|
+
const result = await onSubmit(finalValues);
|
|
11467
|
+
onMutationSuccessProp == null ? void 0 : onMutationSuccessProp({ data: result }, {}, {});
|
|
11468
|
+
return result;
|
|
11469
|
+
}
|
|
11466
11470
|
return onFinish(finalValues);
|
|
11467
11471
|
} catch (error) {
|
|
11468
11472
|
onSubmitAbort == null ? void 0 : onSubmitAbort();
|
|
@@ -11512,6 +11516,7 @@ function YamlForm(props) {
|
|
|
11512
11516
|
transformInitValues,
|
|
11513
11517
|
transformApplyValues,
|
|
11514
11518
|
beforeSubmit,
|
|
11519
|
+
onSubmit,
|
|
11515
11520
|
onSaveButtonPropsChange,
|
|
11516
11521
|
onErrorsChange,
|
|
11517
11522
|
rules
|
|
@@ -11550,6 +11555,7 @@ function YamlForm(props) {
|
|
|
11550
11555
|
initialValuesForEdit: props.initialValuesForEdit,
|
|
11551
11556
|
rules,
|
|
11552
11557
|
beforeSubmit,
|
|
11558
|
+
onSubmit,
|
|
11553
11559
|
successNotification(data2) {
|
|
11554
11560
|
var _a;
|
|
11555
11561
|
const displayName = resourceConfig.displayName || ((_a = resource == null ? void 0 : resource.meta) == null ? void 0 : _a.kind);
|
|
@@ -12515,13 +12521,16 @@ const CronjobJobsTable = ({
|
|
|
12515
12521
|
kind: "Job"
|
|
12516
12522
|
},
|
|
12517
12523
|
filters: {
|
|
12518
|
-
permanent: [
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
|
|
12524
|
+
permanent: [
|
|
12525
|
+
{
|
|
12526
|
+
field: "",
|
|
12527
|
+
value: "",
|
|
12528
|
+
fn(item) {
|
|
12529
|
+
return owner ? matchOwner(item, owner) : true;
|
|
12530
|
+
}
|
|
12523
12531
|
}
|
|
12524
|
-
|
|
12532
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12533
|
+
]
|
|
12525
12534
|
}
|
|
12526
12535
|
}
|
|
12527
12536
|
}), [columns, owner]);
|
|
@@ -12989,31 +12998,63 @@ function readFileAsBase64(file) {
|
|
|
12989
12998
|
reader.readAsArrayBuffer(file);
|
|
12990
12999
|
});
|
|
12991
13000
|
}
|
|
12992
|
-
const
|
|
12993
|
-
const
|
|
12994
|
-
const
|
|
12995
|
-
|
|
12996
|
-
|
|
12997
|
-
|
|
12998
|
-
|
|
12999
|
-
|
|
13000
|
-
|
|
13001
|
-
|
|
13002
|
-
|
|
13003
|
-
|
|
13004
|
-
|
|
13005
|
-
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13001
|
+
const FormatRulePopover_1b8vyke = "";
|
|
13002
|
+
const FormatRulePopoverStyle = "f1eyh8ow";
|
|
13003
|
+
const FormatRulePopover = ({
|
|
13004
|
+
buttonText,
|
|
13005
|
+
columns,
|
|
13006
|
+
dataSource
|
|
13007
|
+
}) => /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Popover, {
|
|
13008
|
+
trigger: "click",
|
|
13009
|
+
overlayClassName: FormatRulePopoverStyle,
|
|
13010
|
+
placement: "bottomRight",
|
|
13011
|
+
content: /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.AntdTable, {
|
|
13012
|
+
bordered: true,
|
|
13013
|
+
dataSource,
|
|
13014
|
+
columns,
|
|
13015
|
+
pagination: false,
|
|
13016
|
+
rowKey: (_, index2) => String(index2)
|
|
13017
|
+
}),
|
|
13018
|
+
children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Button, {
|
|
13019
|
+
size: "small",
|
|
13020
|
+
type: "link",
|
|
13021
|
+
children: buttonText
|
|
13022
|
+
})
|
|
13023
|
+
});
|
|
13024
|
+
const LabelFormatPopover = ({ noValueValidation }) => {
|
|
13025
|
+
const { t: t2 } = common.useTranslation();
|
|
13026
|
+
const data2 = [
|
|
13027
|
+
{
|
|
13028
|
+
object: t2("dovetail.key"),
|
|
13029
|
+
contains: t2("dovetail.prefix"),
|
|
13030
|
+
optional: t2("dovetail.no"),
|
|
13031
|
+
rule: [
|
|
13032
|
+
t2("dovetail.prefix_format_rule_1"),
|
|
13033
|
+
t2("dovetail.prefix_format_rule_2"),
|
|
13034
|
+
t2("dovetail.prefix_format_rule_3")
|
|
13035
|
+
]
|
|
13036
|
+
},
|
|
13037
|
+
{
|
|
13038
|
+
object: t2("dovetail.key"),
|
|
13039
|
+
contains: t2("dovetail.name"),
|
|
13040
|
+
optional: t2("dovetail.yes"),
|
|
13041
|
+
rule: [
|
|
13042
|
+
t2("dovetail.name_format_rule_1"),
|
|
13043
|
+
t2("dovetail.name_format_rule_2"),
|
|
13044
|
+
t2("dovetail.name_format_rule_3")
|
|
13045
|
+
]
|
|
13046
|
+
}
|
|
13047
|
+
];
|
|
13011
13048
|
if (!noValueValidation) {
|
|
13012
13049
|
data2.push({
|
|
13013
13050
|
object: t2("dovetail.value"),
|
|
13014
13051
|
contains: t2("dovetail.name"),
|
|
13015
13052
|
optional: t2("dovetail.no"),
|
|
13016
|
-
rule: [
|
|
13053
|
+
rule: [
|
|
13054
|
+
t2("dovetail.name_format_rule_1"),
|
|
13055
|
+
t2("dovetail.name_format_rule_2"),
|
|
13056
|
+
t2("dovetail.name_format_rule_3")
|
|
13057
|
+
]
|
|
13017
13058
|
});
|
|
13018
13059
|
} else {
|
|
13019
13060
|
data2.push({
|
|
@@ -13023,57 +13064,42 @@ const LabelFormatPopover = ({
|
|
|
13023
13064
|
rule: [t2("dovetail.no_limitation_rule")]
|
|
13024
13065
|
});
|
|
13025
13066
|
}
|
|
13026
|
-
return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
content: /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.AntdTable, {
|
|
13031
|
-
bordered: true,
|
|
13067
|
+
return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
13068
|
+
FormatRulePopover,
|
|
13069
|
+
{
|
|
13070
|
+
buttonText: t2("dovetail.look_format_requirement"),
|
|
13032
13071
|
dataSource: data2,
|
|
13033
|
-
columns: [
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13038
|
-
|
|
13039
|
-
children: /* @__PURE__ */ common.jsxRuntimeExports.jsx("span", {
|
|
13040
|
-
className: eagle.Typo.Label.l4_bold,
|
|
13041
|
-
children: cell
|
|
13042
|
-
}),
|
|
13072
|
+
columns: [
|
|
13073
|
+
{
|
|
13074
|
+
key: "object",
|
|
13075
|
+
title: t2("dovetail.object"),
|
|
13076
|
+
dataIndex: "object",
|
|
13077
|
+
render: (cell, _record, index2) => ({
|
|
13078
|
+
children: /* @__PURE__ */ common.jsxRuntimeExports.jsx("span", { className: eagle.Typo.Label.l4_bold, children: cell }),
|
|
13043
13079
|
props: {
|
|
13044
13080
|
rowSpan: index2 === 0 ? 2 : index2 === 1 ? 0 : 1
|
|
13045
13081
|
}
|
|
13046
|
-
}
|
|
13047
|
-
}
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
children: cell.map((rule2, index2) => /* @__PURE__ */ common.jsxRuntimeExports.jsx("li", {
|
|
13064
|
-
children: rule2
|
|
13065
|
-
}, index2))
|
|
13066
|
-
});
|
|
13082
|
+
})
|
|
13083
|
+
},
|
|
13084
|
+
{
|
|
13085
|
+
key: "contains",
|
|
13086
|
+
title: t2("dovetail.contains"),
|
|
13087
|
+
dataIndex: "contains"
|
|
13088
|
+
},
|
|
13089
|
+
{
|
|
13090
|
+
key: "optional",
|
|
13091
|
+
title: t2("dovetail.optional"),
|
|
13092
|
+
dataIndex: "optional"
|
|
13093
|
+
},
|
|
13094
|
+
{
|
|
13095
|
+
key: "rule",
|
|
13096
|
+
title: t2("dovetail.format_requirements"),
|
|
13097
|
+
dataIndex: "rule",
|
|
13098
|
+
render: (cell) => /* @__PURE__ */ common.jsxRuntimeExports.jsx("ul", { style: { listStyle: "disc", listStylePosition: "inside" }, children: cell.map((rule2, i2) => /* @__PURE__ */ common.jsxRuntimeExports.jsx("li", { style: { textIndent: 8 }, children: rule2 }, i2)) })
|
|
13067
13099
|
}
|
|
13068
|
-
|
|
13069
|
-
|
|
13070
|
-
|
|
13071
|
-
children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Button, {
|
|
13072
|
-
size: "small",
|
|
13073
|
-
type: "link",
|
|
13074
|
-
children: t2("dovetail.look_format_requirement")
|
|
13075
|
-
})
|
|
13076
|
-
});
|
|
13100
|
+
]
|
|
13101
|
+
}
|
|
13102
|
+
);
|
|
13077
13103
|
};
|
|
13078
13104
|
const index_t3zi07 = "";
|
|
13079
13105
|
function _KeyValueTableForm(props, ref) {
|
|
@@ -13094,7 +13120,8 @@ function _KeyValueTableForm(props, ref) {
|
|
|
13094
13120
|
validateKey,
|
|
13095
13121
|
validateValue,
|
|
13096
13122
|
onSubmit,
|
|
13097
|
-
keyTitle
|
|
13123
|
+
keyTitle,
|
|
13124
|
+
formatPopover
|
|
13098
13125
|
} = props;
|
|
13099
13126
|
const {
|
|
13100
13127
|
t: t2,
|
|
@@ -13278,7 +13305,7 @@ function _KeyValueTableForm(props, ref) {
|
|
|
13278
13305
|
validateTriggerType: eagle.ValidateTriggerType.Aggressive,
|
|
13279
13306
|
disableBatchFilling: true,
|
|
13280
13307
|
hideEmptyTable: true
|
|
13281
|
-
}), isHideLabelFormatPopover || _value.length === 0 ? null : /* @__PURE__ */ common.jsxRuntimeExports.jsx(LabelFormatPopover, {
|
|
13308
|
+
}), isHideLabelFormatPopover || _value.length === 0 ? null : formatPopover ?? /* @__PURE__ */ common.jsxRuntimeExports.jsx(LabelFormatPopover, {
|
|
13282
13309
|
noValueValidation
|
|
13283
13310
|
})]
|
|
13284
13311
|
});
|
|
@@ -13759,6 +13786,7 @@ const WorkloadPodsTable = ({
|
|
|
13759
13786
|
fn(item) {
|
|
13760
13787
|
return filter ? filter(item) : matchSelector(item, selector, namespace2);
|
|
13761
13788
|
}
|
|
13789
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13762
13790
|
}]
|
|
13763
13791
|
}
|
|
13764
13792
|
}
|
|
@@ -16906,6 +16934,7 @@ const useForm = ({
|
|
|
16906
16934
|
onBeforeSubmitError,
|
|
16907
16935
|
onSubmitStart,
|
|
16908
16936
|
onSubmitAbort,
|
|
16937
|
+
onSubmit,
|
|
16909
16938
|
...rest
|
|
16910
16939
|
} = {}) => {
|
|
16911
16940
|
const { options } = core.useRefineContext();
|
|
@@ -17029,6 +17058,7 @@ const useForm = ({
|
|
|
17029
17058
|
onSubmitStart == null ? void 0 : onSubmitStart();
|
|
17030
17059
|
handleSubmit(
|
|
17031
17060
|
async (v) => {
|
|
17061
|
+
var _a;
|
|
17032
17062
|
let finalValues = transformApplyValues ? transformApplyValues(v) : v;
|
|
17033
17063
|
if (beforeSubmit) {
|
|
17034
17064
|
try {
|
|
@@ -17055,6 +17085,11 @@ const useForm = ({
|
|
|
17055
17085
|
setIsBeforeSubmitLoading(false);
|
|
17056
17086
|
}
|
|
17057
17087
|
}
|
|
17088
|
+
if (onSubmit) {
|
|
17089
|
+
const result = await onSubmit(finalValues);
|
|
17090
|
+
(_a = refineCoreProps == null ? void 0 : refineCoreProps.onMutationSuccess) == null ? void 0 : _a.call(refineCoreProps, { data: result }, {}, {});
|
|
17091
|
+
return result;
|
|
17092
|
+
}
|
|
17058
17093
|
return onFinish(finalValues);
|
|
17059
17094
|
},
|
|
17060
17095
|
() => {
|
|
@@ -17069,6 +17104,8 @@ const useForm = ({
|
|
|
17069
17104
|
isBeforeSubmitLoading,
|
|
17070
17105
|
handleSubmit,
|
|
17071
17106
|
onFinish,
|
|
17107
|
+
onSubmit,
|
|
17108
|
+
refineCoreProps,
|
|
17072
17109
|
transformApplyValues,
|
|
17073
17110
|
beforeSubmit,
|
|
17074
17111
|
onBeforeSubmitError,
|
|
@@ -17100,6 +17137,10 @@ const useRefineForm = (props) => {
|
|
|
17100
17137
|
errorNotification: false,
|
|
17101
17138
|
successNotification: () => {
|
|
17102
17139
|
var _a;
|
|
17140
|
+
if (formConfig == null ? void 0 : formConfig.successMessage) {
|
|
17141
|
+
const msg = typeof formConfig.successMessage === "function" ? formConfig.successMessage(id ? "edit" : "create") : formConfig.successMessage;
|
|
17142
|
+
return { message: msg, description: "Success", type: "success" };
|
|
17143
|
+
}
|
|
17103
17144
|
const formValue = result.getValues();
|
|
17104
17145
|
return {
|
|
17105
17146
|
message: i18n2.t(id ? "dovetail.edit_resource_success" : "dovetail.create_success_toast", {
|
|
@@ -17127,6 +17168,7 @@ const useRefineForm = (props) => {
|
|
|
17127
17168
|
onBeforeSubmitError: options == null ? void 0 : options.onBeforeSubmitError,
|
|
17128
17169
|
onSubmitStart: options == null ? void 0 : options.onSubmitStart,
|
|
17129
17170
|
onSubmitAbort: options == null ? void 0 : options.onSubmitAbort,
|
|
17171
|
+
onSubmit: formConfig == null ? void 0 : formConfig.onSubmit,
|
|
17130
17172
|
...formConfig == null ? void 0 : formConfig.useFormProps
|
|
17131
17173
|
});
|
|
17132
17174
|
React.useEffect(() => {
|
|
@@ -17161,7 +17203,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17161
17203
|
onError,
|
|
17162
17204
|
onSaveButtonPropsChange
|
|
17163
17205
|
}, ref) {
|
|
17164
|
-
var _a
|
|
17206
|
+
var _a;
|
|
17165
17207
|
const action = id ? "edit" : "create";
|
|
17166
17208
|
const pushModal = eagle.usePushModal();
|
|
17167
17209
|
const popModal = eagle.usePopModal();
|
|
@@ -17232,6 +17274,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17232
17274
|
transformApplyValues: (formConfig == null ? void 0 : formConfig.transformApplyValues) || ((v) => v)
|
|
17233
17275
|
});
|
|
17234
17276
|
const yamlFormProps = React.useMemo(() => {
|
|
17277
|
+
var _a2;
|
|
17235
17278
|
if (isYamlMode) {
|
|
17236
17279
|
return {
|
|
17237
17280
|
...customYamlFormProps,
|
|
@@ -17248,8 +17291,10 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17248
17291
|
id,
|
|
17249
17292
|
action,
|
|
17250
17293
|
isShowLayout: false,
|
|
17294
|
+
onSubmit: formConfig == null ? void 0 : formConfig.onSubmit,
|
|
17251
17295
|
useFormProps: {
|
|
17252
17296
|
redirect: false,
|
|
17297
|
+
mutationMeta: (_a2 = formConfig == null ? void 0 : formConfig.refineCoreProps) == null ? void 0 : _a2.mutationMeta,
|
|
17253
17298
|
onSubmitStart: () => {
|
|
17254
17299
|
setIsSubmitting(true);
|
|
17255
17300
|
},
|
|
@@ -17304,18 +17349,20 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17304
17349
|
}),
|
|
17305
17350
|
[refineFormResult.formResult]
|
|
17306
17351
|
);
|
|
17307
|
-
|
|
17352
|
+
const currentFormValues = refineFormResult.formResult.getValues();
|
|
17353
|
+
const isReady = (formConfig == null ? void 0 : formConfig.isDataReady) ? formConfig.isDataReady(currentFormValues) : !!((_a = currentFormValues == null ? void 0 : currentFormValues.metadata) == null ? void 0 : _a.name);
|
|
17354
|
+
if (action === "edit" && !isReady) {
|
|
17308
17355
|
return /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Loading, {});
|
|
17309
17356
|
}
|
|
17310
17357
|
if (isYamlMode) {
|
|
17311
17358
|
return /* @__PURE__ */ common.jsxRuntimeExports.jsx(YamlForm, { ...yamlFormProps });
|
|
17312
17359
|
}
|
|
17313
17360
|
return /* @__PURE__ */ common.jsxRuntimeExports.jsxs(common.jsxRuntimeExports.Fragment, { children: [
|
|
17314
|
-
!(formConfig == null ? void 0 : formConfig.isDisabledChangeMode) ? /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
17361
|
+
!(formConfig == null ? void 0 : formConfig.isDisabledChangeMode) && (formConfig == null ? void 0 : formConfig.changeModeAlert) !== false ? /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
17315
17362
|
eagle.Alert,
|
|
17316
17363
|
{
|
|
17317
17364
|
type: "warning",
|
|
17318
|
-
message: i18n.t("dovetail.change_form_mode_alert"),
|
|
17365
|
+
message: (formConfig == null ? void 0 : formConfig.changeModeAlert) ?? i18n.t("dovetail.change_form_mode_alert"),
|
|
17319
17366
|
style: { marginBottom: "16px" }
|
|
17320
17367
|
}
|
|
17321
17368
|
) : void 0,
|
|
@@ -20694,6 +20741,7 @@ exports.FormItemLayout = FormItemLayout;
|
|
|
20694
20741
|
exports.FormModal = FormModal;
|
|
20695
20742
|
exports.FormMode = FormMode;
|
|
20696
20743
|
exports.FormType = FormType;
|
|
20744
|
+
exports.FormatRulePopover = FormatRulePopover;
|
|
20697
20745
|
exports.GlobalStoreContext = GlobalStoreContext;
|
|
20698
20746
|
exports.INGRESS_INIT_VALUE = INGRESS_INIT_VALUE;
|
|
20699
20747
|
exports.ImageField = ImageField;
|
package/dist/refine.js
CHANGED
|
@@ -46,18 +46,14 @@ var zh = { exports: {} };
|
|
|
46
46
|
});
|
|
47
47
|
})(zh);
|
|
48
48
|
function _extends() {
|
|
49
|
-
_extends = Object.assign ? Object.assign.bind() : function(
|
|
50
|
-
for (var
|
|
51
|
-
var
|
|
52
|
-
for (var
|
|
53
|
-
|
|
54
|
-
target[key2] = source[key2];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
49
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n2) {
|
|
50
|
+
for (var e2 = 1; e2 < arguments.length; e2++) {
|
|
51
|
+
var t2 = arguments[e2];
|
|
52
|
+
for (var r2 in t2)
|
|
53
|
+
({}).hasOwnProperty.call(t2, r2) && (n2[r2] = t2[r2]);
|
|
57
54
|
}
|
|
58
|
-
return
|
|
59
|
-
};
|
|
60
|
-
return _extends.apply(this, arguments);
|
|
55
|
+
return n2;
|
|
56
|
+
}, _extends.apply(null, arguments);
|
|
61
57
|
}
|
|
62
58
|
var voidElements = {
|
|
63
59
|
"area": true,
|
|
@@ -8228,7 +8224,9 @@ function useTableData({ data: data2, columns, pageSize = 10, defaultSorters }) {
|
|
|
8228
8224
|
pageSize,
|
|
8229
8225
|
current: currentPage
|
|
8230
8226
|
},
|
|
8227
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8231
8228
|
sortData(sorters, data2)
|
|
8229
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8232
8230
|
),
|
|
8233
8231
|
currentPage,
|
|
8234
8232
|
onPageChange: setCurrentPage,
|
|
@@ -11231,6 +11229,7 @@ const useYamlForm = ({
|
|
|
11231
11229
|
onBeforeSubmitError,
|
|
11232
11230
|
onSubmitStart,
|
|
11233
11231
|
onSubmitAbort,
|
|
11232
|
+
onSubmit,
|
|
11234
11233
|
rules
|
|
11235
11234
|
} = {}) => {
|
|
11236
11235
|
var _a;
|
|
@@ -11444,6 +11443,11 @@ const useYamlForm = ({
|
|
|
11444
11443
|
setIsBeforeSubmitLoading(false);
|
|
11445
11444
|
}
|
|
11446
11445
|
}
|
|
11446
|
+
if (onSubmit) {
|
|
11447
|
+
const result = await onSubmit(finalValues);
|
|
11448
|
+
onMutationSuccessProp == null ? void 0 : onMutationSuccessProp({ data: result }, {}, {});
|
|
11449
|
+
return result;
|
|
11450
|
+
}
|
|
11447
11451
|
return onFinish(finalValues);
|
|
11448
11452
|
} catch (error) {
|
|
11449
11453
|
onSubmitAbort == null ? void 0 : onSubmitAbort();
|
|
@@ -11493,6 +11497,7 @@ function YamlForm(props) {
|
|
|
11493
11497
|
transformInitValues,
|
|
11494
11498
|
transformApplyValues,
|
|
11495
11499
|
beforeSubmit,
|
|
11500
|
+
onSubmit,
|
|
11496
11501
|
onSaveButtonPropsChange,
|
|
11497
11502
|
onErrorsChange,
|
|
11498
11503
|
rules
|
|
@@ -11531,6 +11536,7 @@ function YamlForm(props) {
|
|
|
11531
11536
|
initialValuesForEdit: props.initialValuesForEdit,
|
|
11532
11537
|
rules,
|
|
11533
11538
|
beforeSubmit,
|
|
11539
|
+
onSubmit,
|
|
11534
11540
|
successNotification(data2) {
|
|
11535
11541
|
var _a;
|
|
11536
11542
|
const displayName = resourceConfig.displayName || ((_a = resource == null ? void 0 : resource.meta) == null ? void 0 : _a.kind);
|
|
@@ -12496,13 +12502,16 @@ const CronjobJobsTable = ({
|
|
|
12496
12502
|
kind: "Job"
|
|
12497
12503
|
},
|
|
12498
12504
|
filters: {
|
|
12499
|
-
permanent: [
|
|
12500
|
-
|
|
12501
|
-
|
|
12502
|
-
|
|
12503
|
-
|
|
12505
|
+
permanent: [
|
|
12506
|
+
{
|
|
12507
|
+
field: "",
|
|
12508
|
+
value: "",
|
|
12509
|
+
fn(item) {
|
|
12510
|
+
return owner ? matchOwner(item, owner) : true;
|
|
12511
|
+
}
|
|
12504
12512
|
}
|
|
12505
|
-
|
|
12513
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12514
|
+
]
|
|
12506
12515
|
}
|
|
12507
12516
|
}
|
|
12508
12517
|
}), [columns, owner]);
|
|
@@ -12970,31 +12979,63 @@ function readFileAsBase64(file) {
|
|
|
12970
12979
|
reader.readAsArrayBuffer(file);
|
|
12971
12980
|
});
|
|
12972
12981
|
}
|
|
12973
|
-
const
|
|
12974
|
-
const
|
|
12975
|
-
const
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
|
|
12990
|
-
|
|
12991
|
-
|
|
12982
|
+
const FormatRulePopover_1b8vyke = "";
|
|
12983
|
+
const FormatRulePopoverStyle = "f1eyh8ow";
|
|
12984
|
+
const FormatRulePopover = ({
|
|
12985
|
+
buttonText,
|
|
12986
|
+
columns,
|
|
12987
|
+
dataSource
|
|
12988
|
+
}) => /* @__PURE__ */ jsxRuntimeExports.jsx(Popover, {
|
|
12989
|
+
trigger: "click",
|
|
12990
|
+
overlayClassName: FormatRulePopoverStyle,
|
|
12991
|
+
placement: "bottomRight",
|
|
12992
|
+
content: /* @__PURE__ */ jsxRuntimeExports.jsx(AntdTable, {
|
|
12993
|
+
bordered: true,
|
|
12994
|
+
dataSource,
|
|
12995
|
+
columns,
|
|
12996
|
+
pagination: false,
|
|
12997
|
+
rowKey: (_, index2) => String(index2)
|
|
12998
|
+
}),
|
|
12999
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, {
|
|
13000
|
+
size: "small",
|
|
13001
|
+
type: "link",
|
|
13002
|
+
children: buttonText
|
|
13003
|
+
})
|
|
13004
|
+
});
|
|
13005
|
+
const LabelFormatPopover = ({ noValueValidation }) => {
|
|
13006
|
+
const { t: t2 } = useTranslation();
|
|
13007
|
+
const data2 = [
|
|
13008
|
+
{
|
|
13009
|
+
object: t2("dovetail.key"),
|
|
13010
|
+
contains: t2("dovetail.prefix"),
|
|
13011
|
+
optional: t2("dovetail.no"),
|
|
13012
|
+
rule: [
|
|
13013
|
+
t2("dovetail.prefix_format_rule_1"),
|
|
13014
|
+
t2("dovetail.prefix_format_rule_2"),
|
|
13015
|
+
t2("dovetail.prefix_format_rule_3")
|
|
13016
|
+
]
|
|
13017
|
+
},
|
|
13018
|
+
{
|
|
13019
|
+
object: t2("dovetail.key"),
|
|
13020
|
+
contains: t2("dovetail.name"),
|
|
13021
|
+
optional: t2("dovetail.yes"),
|
|
13022
|
+
rule: [
|
|
13023
|
+
t2("dovetail.name_format_rule_1"),
|
|
13024
|
+
t2("dovetail.name_format_rule_2"),
|
|
13025
|
+
t2("dovetail.name_format_rule_3")
|
|
13026
|
+
]
|
|
13027
|
+
}
|
|
13028
|
+
];
|
|
12992
13029
|
if (!noValueValidation) {
|
|
12993
13030
|
data2.push({
|
|
12994
13031
|
object: t2("dovetail.value"),
|
|
12995
13032
|
contains: t2("dovetail.name"),
|
|
12996
13033
|
optional: t2("dovetail.no"),
|
|
12997
|
-
rule: [
|
|
13034
|
+
rule: [
|
|
13035
|
+
t2("dovetail.name_format_rule_1"),
|
|
13036
|
+
t2("dovetail.name_format_rule_2"),
|
|
13037
|
+
t2("dovetail.name_format_rule_3")
|
|
13038
|
+
]
|
|
12998
13039
|
});
|
|
12999
13040
|
} else {
|
|
13000
13041
|
data2.push({
|
|
@@ -13004,57 +13045,42 @@ const LabelFormatPopover = ({
|
|
|
13004
13045
|
rule: [t2("dovetail.no_limitation_rule")]
|
|
13005
13046
|
});
|
|
13006
13047
|
}
|
|
13007
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
content: /* @__PURE__ */ jsxRuntimeExports.jsx(AntdTable, {
|
|
13012
|
-
bordered: true,
|
|
13048
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
13049
|
+
FormatRulePopover,
|
|
13050
|
+
{
|
|
13051
|
+
buttonText: t2("dovetail.look_format_requirement"),
|
|
13013
13052
|
dataSource: data2,
|
|
13014
|
-
columns: [
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
|
|
13021
|
-
className: Typo.Label.l4_bold,
|
|
13022
|
-
children: cell
|
|
13023
|
-
}),
|
|
13053
|
+
columns: [
|
|
13054
|
+
{
|
|
13055
|
+
key: "object",
|
|
13056
|
+
title: t2("dovetail.object"),
|
|
13057
|
+
dataIndex: "object",
|
|
13058
|
+
render: (cell, _record, index2) => ({
|
|
13059
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: Typo.Label.l4_bold, children: cell }),
|
|
13024
13060
|
props: {
|
|
13025
13061
|
rowSpan: index2 === 0 ? 2 : index2 === 1 ? 0 : 1
|
|
13026
13062
|
}
|
|
13027
|
-
}
|
|
13028
|
-
}
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13038
|
-
|
|
13039
|
-
|
|
13040
|
-
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
|
|
13044
|
-
children: cell.map((rule2, index2) => /* @__PURE__ */ jsxRuntimeExports.jsx("li", {
|
|
13045
|
-
children: rule2
|
|
13046
|
-
}, index2))
|
|
13047
|
-
});
|
|
13063
|
+
})
|
|
13064
|
+
},
|
|
13065
|
+
{
|
|
13066
|
+
key: "contains",
|
|
13067
|
+
title: t2("dovetail.contains"),
|
|
13068
|
+
dataIndex: "contains"
|
|
13069
|
+
},
|
|
13070
|
+
{
|
|
13071
|
+
key: "optional",
|
|
13072
|
+
title: t2("dovetail.optional"),
|
|
13073
|
+
dataIndex: "optional"
|
|
13074
|
+
},
|
|
13075
|
+
{
|
|
13076
|
+
key: "rule",
|
|
13077
|
+
title: t2("dovetail.format_requirements"),
|
|
13078
|
+
dataIndex: "rule",
|
|
13079
|
+
render: (cell) => /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { style: { listStyle: "disc", listStylePosition: "inside" }, children: cell.map((rule2, i2) => /* @__PURE__ */ jsxRuntimeExports.jsx("li", { style: { textIndent: 8 }, children: rule2 }, i2)) })
|
|
13048
13080
|
}
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, {
|
|
13053
|
-
size: "small",
|
|
13054
|
-
type: "link",
|
|
13055
|
-
children: t2("dovetail.look_format_requirement")
|
|
13056
|
-
})
|
|
13057
|
-
});
|
|
13081
|
+
]
|
|
13082
|
+
}
|
|
13083
|
+
);
|
|
13058
13084
|
};
|
|
13059
13085
|
const index_t3zi07 = "";
|
|
13060
13086
|
function _KeyValueTableForm(props, ref) {
|
|
@@ -13075,7 +13101,8 @@ function _KeyValueTableForm(props, ref) {
|
|
|
13075
13101
|
validateKey,
|
|
13076
13102
|
validateValue,
|
|
13077
13103
|
onSubmit,
|
|
13078
|
-
keyTitle
|
|
13104
|
+
keyTitle,
|
|
13105
|
+
formatPopover
|
|
13079
13106
|
} = props;
|
|
13080
13107
|
const {
|
|
13081
13108
|
t: t2,
|
|
@@ -13259,7 +13286,7 @@ function _KeyValueTableForm(props, ref) {
|
|
|
13259
13286
|
validateTriggerType: ValidateTriggerType.Aggressive,
|
|
13260
13287
|
disableBatchFilling: true,
|
|
13261
13288
|
hideEmptyTable: true
|
|
13262
|
-
}), isHideLabelFormatPopover || _value.length === 0 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(LabelFormatPopover, {
|
|
13289
|
+
}), isHideLabelFormatPopover || _value.length === 0 ? null : formatPopover ?? /* @__PURE__ */ jsxRuntimeExports.jsx(LabelFormatPopover, {
|
|
13263
13290
|
noValueValidation
|
|
13264
13291
|
})]
|
|
13265
13292
|
});
|
|
@@ -13740,6 +13767,7 @@ const WorkloadPodsTable = ({
|
|
|
13740
13767
|
fn(item) {
|
|
13741
13768
|
return filter ? filter(item) : matchSelector(item, selector, namespace2);
|
|
13742
13769
|
}
|
|
13770
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13743
13771
|
}]
|
|
13744
13772
|
}
|
|
13745
13773
|
}
|
|
@@ -16887,6 +16915,7 @@ const useForm = ({
|
|
|
16887
16915
|
onBeforeSubmitError,
|
|
16888
16916
|
onSubmitStart,
|
|
16889
16917
|
onSubmitAbort,
|
|
16918
|
+
onSubmit,
|
|
16890
16919
|
...rest
|
|
16891
16920
|
} = {}) => {
|
|
16892
16921
|
const { options } = useRefineContext();
|
|
@@ -17010,6 +17039,7 @@ const useForm = ({
|
|
|
17010
17039
|
onSubmitStart == null ? void 0 : onSubmitStart();
|
|
17011
17040
|
handleSubmit(
|
|
17012
17041
|
async (v) => {
|
|
17042
|
+
var _a;
|
|
17013
17043
|
let finalValues = transformApplyValues ? transformApplyValues(v) : v;
|
|
17014
17044
|
if (beforeSubmit) {
|
|
17015
17045
|
try {
|
|
@@ -17036,6 +17066,11 @@ const useForm = ({
|
|
|
17036
17066
|
setIsBeforeSubmitLoading(false);
|
|
17037
17067
|
}
|
|
17038
17068
|
}
|
|
17069
|
+
if (onSubmit) {
|
|
17070
|
+
const result = await onSubmit(finalValues);
|
|
17071
|
+
(_a = refineCoreProps == null ? void 0 : refineCoreProps.onMutationSuccess) == null ? void 0 : _a.call(refineCoreProps, { data: result }, {}, {});
|
|
17072
|
+
return result;
|
|
17073
|
+
}
|
|
17039
17074
|
return onFinish(finalValues);
|
|
17040
17075
|
},
|
|
17041
17076
|
() => {
|
|
@@ -17050,6 +17085,8 @@ const useForm = ({
|
|
|
17050
17085
|
isBeforeSubmitLoading,
|
|
17051
17086
|
handleSubmit,
|
|
17052
17087
|
onFinish,
|
|
17088
|
+
onSubmit,
|
|
17089
|
+
refineCoreProps,
|
|
17053
17090
|
transformApplyValues,
|
|
17054
17091
|
beforeSubmit,
|
|
17055
17092
|
onBeforeSubmitError,
|
|
@@ -17081,6 +17118,10 @@ const useRefineForm = (props) => {
|
|
|
17081
17118
|
errorNotification: false,
|
|
17082
17119
|
successNotification: () => {
|
|
17083
17120
|
var _a;
|
|
17121
|
+
if (formConfig == null ? void 0 : formConfig.successMessage) {
|
|
17122
|
+
const msg = typeof formConfig.successMessage === "function" ? formConfig.successMessage(id ? "edit" : "create") : formConfig.successMessage;
|
|
17123
|
+
return { message: msg, description: "Success", type: "success" };
|
|
17124
|
+
}
|
|
17084
17125
|
const formValue = result.getValues();
|
|
17085
17126
|
return {
|
|
17086
17127
|
message: i18n2.t(id ? "dovetail.edit_resource_success" : "dovetail.create_success_toast", {
|
|
@@ -17108,6 +17149,7 @@ const useRefineForm = (props) => {
|
|
|
17108
17149
|
onBeforeSubmitError: options == null ? void 0 : options.onBeforeSubmitError,
|
|
17109
17150
|
onSubmitStart: options == null ? void 0 : options.onSubmitStart,
|
|
17110
17151
|
onSubmitAbort: options == null ? void 0 : options.onSubmitAbort,
|
|
17152
|
+
onSubmit: formConfig == null ? void 0 : formConfig.onSubmit,
|
|
17111
17153
|
...formConfig == null ? void 0 : formConfig.useFormProps
|
|
17112
17154
|
});
|
|
17113
17155
|
useEffect(() => {
|
|
@@ -17142,7 +17184,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17142
17184
|
onError,
|
|
17143
17185
|
onSaveButtonPropsChange
|
|
17144
17186
|
}, ref) {
|
|
17145
|
-
var _a
|
|
17187
|
+
var _a;
|
|
17146
17188
|
const action = id ? "edit" : "create";
|
|
17147
17189
|
const pushModal = usePushModal();
|
|
17148
17190
|
const popModal = usePopModal();
|
|
@@ -17213,6 +17255,7 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17213
17255
|
transformApplyValues: (formConfig == null ? void 0 : formConfig.transformApplyValues) || ((v) => v)
|
|
17214
17256
|
});
|
|
17215
17257
|
const yamlFormProps = useMemo(() => {
|
|
17258
|
+
var _a2;
|
|
17216
17259
|
if (isYamlMode) {
|
|
17217
17260
|
return {
|
|
17218
17261
|
...customYamlFormProps,
|
|
@@ -17229,8 +17272,10 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17229
17272
|
id,
|
|
17230
17273
|
action,
|
|
17231
17274
|
isShowLayout: false,
|
|
17275
|
+
onSubmit: formConfig == null ? void 0 : formConfig.onSubmit,
|
|
17232
17276
|
useFormProps: {
|
|
17233
17277
|
redirect: false,
|
|
17278
|
+
mutationMeta: (_a2 = formConfig == null ? void 0 : formConfig.refineCoreProps) == null ? void 0 : _a2.mutationMeta,
|
|
17234
17279
|
onSubmitStart: () => {
|
|
17235
17280
|
setIsSubmitting(true);
|
|
17236
17281
|
},
|
|
@@ -17285,18 +17330,20 @@ const RefineFormContainer = React.forwardRef(function RefineFormContainer2({
|
|
|
17285
17330
|
}),
|
|
17286
17331
|
[refineFormResult.formResult]
|
|
17287
17332
|
);
|
|
17288
|
-
|
|
17333
|
+
const currentFormValues = refineFormResult.formResult.getValues();
|
|
17334
|
+
const isReady = (formConfig == null ? void 0 : formConfig.isDataReady) ? formConfig.isDataReady(currentFormValues) : !!((_a = currentFormValues == null ? void 0 : currentFormValues.metadata) == null ? void 0 : _a.name);
|
|
17335
|
+
if (action === "edit" && !isReady) {
|
|
17289
17336
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Loading, {});
|
|
17290
17337
|
}
|
|
17291
17338
|
if (isYamlMode) {
|
|
17292
17339
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(YamlForm, { ...yamlFormProps });
|
|
17293
17340
|
}
|
|
17294
17341
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
17295
|
-
!(formConfig == null ? void 0 : formConfig.isDisabledChangeMode) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
17342
|
+
!(formConfig == null ? void 0 : formConfig.isDisabledChangeMode) && (formConfig == null ? void 0 : formConfig.changeModeAlert) !== false ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
17296
17343
|
Alert,
|
|
17297
17344
|
{
|
|
17298
17345
|
type: "warning",
|
|
17299
|
-
message: i18n.t("dovetail.change_form_mode_alert"),
|
|
17346
|
+
message: (formConfig == null ? void 0 : formConfig.changeModeAlert) ?? i18n.t("dovetail.change_form_mode_alert"),
|
|
17300
17347
|
style: { marginBottom: "16px" }
|
|
17301
17348
|
}
|
|
17302
17349
|
) : void 0,
|
|
@@ -20676,6 +20723,7 @@ export {
|
|
|
20676
20723
|
FormModal,
|
|
20677
20724
|
FormMode,
|
|
20678
20725
|
FormType,
|
|
20726
|
+
FormatRulePopover,
|
|
20679
20727
|
GlobalStoreContext,
|
|
20680
20728
|
INGRESS_INIT_VALUE,
|
|
20681
20729
|
ImageField,
|
package/dist/style.css
CHANGED
|
@@ -2068,47 +2068,35 @@
|
|
|
2068
2068
|
/* box shadow */
|
|
2069
2069
|
/* fisheye */
|
|
2070
2070
|
/* z-index */
|
|
2071
|
-
.
|
|
2071
|
+
.f1eyh8ow .ant-popover-inner {
|
|
2072
2072
|
border-radius: 8px;
|
|
2073
2073
|
}
|
|
2074
|
-
.
|
|
2075
|
-
padding: 12px;
|
|
2076
|
-
}
|
|
2077
|
-
.p5jt6nm .ant-popover-content > .ant-popover-arrow {
|
|
2074
|
+
.f1eyh8ow .ant-popover-content > .ant-popover-arrow {
|
|
2078
2075
|
display: none;
|
|
2079
2076
|
}
|
|
2080
|
-
.
|
|
2081
|
-
vertical-align: middle;
|
|
2082
|
-
}
|
|
2083
|
-
.p5jt6nm .rule-list {
|
|
2084
|
-
list-style: disc;
|
|
2085
|
-
list-style-position: inside;
|
|
2086
|
-
}
|
|
2087
|
-
.p5jt6nm .ant-table {
|
|
2077
|
+
.f1eyh8ow .ant-table {
|
|
2088
2078
|
font-size: 12px;
|
|
2089
2079
|
line-height: 18px;
|
|
2090
2080
|
}
|
|
2091
|
-
.
|
|
2081
|
+
.f1eyh8ow .ant-table .ant-table-container {
|
|
2092
2082
|
border: none !important;
|
|
2093
2083
|
}
|
|
2094
|
-
.
|
|
2084
|
+
.f1eyh8ow .ant-table .ant-table-thead {
|
|
2095
2085
|
font-weight: 700;
|
|
2096
2086
|
}
|
|
2097
|
-
.
|
|
2087
|
+
.f1eyh8ow .ant-table .ant-table-thead > tr > th {
|
|
2098
2088
|
background: #fff;
|
|
2099
2089
|
}
|
|
2100
|
-
.
|
|
2101
|
-
.
|
|
2090
|
+
.f1eyh8ow .ant-table thead > tr > th:last-child,
|
|
2091
|
+
.f1eyh8ow .ant-table tbody > tr > td:last-child {
|
|
2102
2092
|
border-right: none !important;
|
|
2103
2093
|
}
|
|
2104
|
-
.
|
|
2094
|
+
.f1eyh8ow .ant-table tbody > tr:last-child > td {
|
|
2105
2095
|
border-bottom: none;
|
|
2106
2096
|
}
|
|
2107
|
-
.
|
|
2097
|
+
.f1eyh8ow .ant-table .ant-table-cell {
|
|
2108
2098
|
padding: 4px 8px !important;
|
|
2109
|
-
|
|
2110
|
-
.p5jt6nm .ant-table li {
|
|
2111
|
-
text-indent: 8px;
|
|
2099
|
+
vertical-align: middle;
|
|
2112
2100
|
}/* // basic */
|
|
2113
2101
|
/* FishEye Color Variables and Functions */
|
|
2114
2102
|
/*
|
package/dist/types/resource.d.ts
CHANGED
|
@@ -149,6 +149,26 @@ export type CommonFormConfig<Model extends ResourceModel = ResourceModel> = {
|
|
|
149
149
|
from: string[];
|
|
150
150
|
to: string[];
|
|
151
151
|
}[];
|
|
152
|
+
/**
|
|
153
|
+
* 自定义数据就绪检查(编辑模式下判断初始数据是否加载完成)
|
|
154
|
+
* 默认检查 metadata.name,非标准 K8s 资源可覆盖
|
|
155
|
+
*/
|
|
156
|
+
isDataReady?: (formValues: Record<string, unknown>) => boolean;
|
|
157
|
+
/**
|
|
158
|
+
* 自定义提交函数,存在时替代 refine core 的 onFinish
|
|
159
|
+
* 用于非标准 K8s 资源或需要自定义 API 调用的场景
|
|
160
|
+
*/
|
|
161
|
+
onSubmit?: (values: Record<string, unknown>) => Promise<unknown>;
|
|
162
|
+
/**
|
|
163
|
+
* 自定义成功 toast 消息
|
|
164
|
+
*/
|
|
165
|
+
successMessage?: string | ((action: 'create' | 'edit') => string);
|
|
166
|
+
/**
|
|
167
|
+
* 自定义切换 YAML 模式时的提示 Alert 内容
|
|
168
|
+
* 设为 false 可隐藏 Alert,设为 string/ReactNode 可替换默认文案
|
|
169
|
+
* 默认显示 dovetail.change_form_mode_alert
|
|
170
|
+
*/
|
|
171
|
+
changeModeAlert?: React.ReactNode | false;
|
|
152
172
|
};
|
|
153
173
|
export type ResourceConfig<Model extends ResourceModel = ResourceModel> = {
|
|
154
174
|
/** 资源名称,用于 API 调用和路由。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dovetail-v2/refine",
|
|
3
|
-
"version": "0.4.1",
|
|
3
|
+
"version": "0.4.2-alpha.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -58,11 +58,14 @@
|
|
|
58
58
|
"@playwright/test": "^1.39.0",
|
|
59
59
|
"@refinedev/cli": "^2.9.0",
|
|
60
60
|
"@rollup/pluginutils": "^4.2.1",
|
|
61
|
+
"@tanstack/react-query": "^4.35.3",
|
|
61
62
|
"@testing-library/react-hooks": "7",
|
|
62
63
|
"@types/body-parser": "^1.19.5",
|
|
64
|
+
"@types/history": "^4.7.11",
|
|
63
65
|
"@types/jest": "^29",
|
|
64
66
|
"@types/js-yaml": "^4.0.6",
|
|
65
67
|
"@types/json-schema": "^7.0.13",
|
|
68
|
+
"@types/lodash": "^4.14.198",
|
|
66
69
|
"@types/lodash-es": "^4.17.9",
|
|
67
70
|
"@types/node": "^18.16.2",
|
|
68
71
|
"@types/qs": "^6.9.8",
|
|
@@ -74,16 +77,20 @@
|
|
|
74
77
|
"@vitejs/plugin-react": "^4.0.0",
|
|
75
78
|
"body-parser": "^1.20.2",
|
|
76
79
|
"eslint": "^8.38.0",
|
|
80
|
+
"history": "^4.10.1",
|
|
77
81
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
78
82
|
"eslint-plugin-react-refresh": "^0.3.4",
|
|
79
83
|
"jest": "^29",
|
|
84
|
+
"json-schema": "^0.4.0",
|
|
80
85
|
"jest-environment-jsdom": "^30.0.0",
|
|
81
86
|
"kubernetes-types": "^1.26.0",
|
|
87
|
+
"lodash": "^4.17.21",
|
|
82
88
|
"prettier": "2.8.8",
|
|
83
89
|
"sass": "1.51.0",
|
|
84
90
|
"ts-jest": "^29",
|
|
85
91
|
"vite": "^4.5.2",
|
|
86
|
-
"vite-plugin-commonjs": "^0.10.0"
|
|
92
|
+
"vite-plugin-commonjs": "^0.10.0",
|
|
93
|
+
"ws": "^8.18.2"
|
|
87
94
|
},
|
|
88
95
|
"peerDependencies": {
|
|
89
96
|
"@cloudtower/eagle": "^490.0.1",
|
|
@@ -103,7 +110,7 @@
|
|
|
103
110
|
"refine": "refine",
|
|
104
111
|
"unit-test": "jest",
|
|
105
112
|
"playwright-test": "npx playwright test --workers 1",
|
|
106
|
-
"test": "
|
|
113
|
+
"test": "pnpm unit-test && pnpm playwright-test",
|
|
107
114
|
"lint": "eslint src --ext .ts,.tsx"
|
|
108
115
|
},
|
|
109
116
|
"browserslist": {
|