@dovetail-v2/refine 0.1.31 → 0.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{MonacoYamlDiffEditor-fec09973.js → MonacoYamlDiffEditor-b8952aa0.js} +1 -1
- package/dist/{index-f8de0e3f.js → index-fd721293.js} +518 -303
- package/dist/refine.js +90 -87
- package/dist/refine.umd.cjs +417 -202
- package/dist/style.css +1 -10
- package/lib/components/ErrorContent/index.d.ts +1 -1
- package/lib/components/Form/FormModal.d.ts +10 -2
- package/lib/components/Form/FormModeSegmentControl.d.ts +9 -0
- package/lib/components/Form/RefineFormContainer.d.ts +17 -0
- package/lib/components/Form/RefineFormContent.d.ts +4 -1
- package/lib/components/Form/YamlForm.d.ts +5 -2
- package/lib/components/Form/YamlFormContainer.d.ts +17 -0
- package/lib/components/Form/type.d.ts +17 -3
- package/lib/components/Form/useFieldsConfig.d.ts +2 -2
- package/lib/components/Form/useRefineForm.d.ts +3 -2
- package/lib/components/InternalBaseTable/index.d.ts +2 -2
- package/lib/hooks/useOpenForm.d.ts +0 -3
- package/lib/hooks/usePathMap.d.ts +26 -0
- package/lib/pages/storageclasses/form/index.d.ts +4 -4
- package/lib/pages/storageclasses/index.d.ts +3 -51
- package/lib/types/resource.d.ts +148 -22
- package/lib/utils/object.d.ts +1 -0
- package/package.json +1 -1
package/dist/style.css
CHANGED
|
@@ -3402,8 +3402,7 @@
|
|
|
3402
3402
|
padding: 11px;
|
|
3403
3403
|
border-bottom: 1px solid rgba(211, 218, 235, 0.6);
|
|
3404
3404
|
background: rgba(225, 230, 241, 0.6);
|
|
3405
|
-
border-
|
|
3406
|
-
border-top-right-radius: 8px;
|
|
3405
|
+
border-radius: 8px;
|
|
3407
3406
|
}
|
|
3408
3407
|
.t1joof7s.collapsed {
|
|
3409
3408
|
border-bottom: 0;
|
|
@@ -4231,14 +4230,6 @@
|
|
|
4231
4230
|
}
|
|
4232
4231
|
|
|
4233
4232
|
.c1c9j4da {
|
|
4234
|
-
width: 100%;
|
|
4235
|
-
}
|
|
4236
|
-
|
|
4237
|
-
.cjxv8cf {
|
|
4238
|
-
color: rgba(44, 56, 82, 0.6);
|
|
4239
|
-
}
|
|
4240
|
-
|
|
4241
|
-
.c1xsnuvk {
|
|
4242
4233
|
flex-basis: 58%;
|
|
4243
4234
|
width: 100%;
|
|
4244
4235
|
margin: 0 auto;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { YamlFormProps } from './YamlForm';
|
|
3
|
+
export type SaveButtonProps = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
onClick: (e: React.BaseSyntheticEvent) => void;
|
|
6
|
+
} | {
|
|
7
|
+
loading?: boolean | {
|
|
8
|
+
delay?: number | undefined;
|
|
9
|
+
} | undefined;
|
|
10
|
+
onClick?: (() => void) | undefined;
|
|
11
|
+
};
|
|
3
12
|
export interface ConfirmModalProps {
|
|
4
13
|
onOk?: () => void;
|
|
5
14
|
}
|
|
6
15
|
export type FormModalProps = {
|
|
7
16
|
resource?: string;
|
|
8
17
|
id?: string;
|
|
9
|
-
|
|
10
|
-
renderForm?: (props: YamlFormProps) => React.ReactNode;
|
|
18
|
+
yamlFormProps?: YamlFormProps;
|
|
11
19
|
};
|
|
12
20
|
export declare function FormModal(props: FormModalProps): JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CommonFormConfig, RefineFormConfig, FormMode } from 'src/types';
|
|
3
|
+
interface FormModeSegmentControlProps {
|
|
4
|
+
formConfig: CommonFormConfig & RefineFormConfig;
|
|
5
|
+
mode: FormMode;
|
|
6
|
+
onChangeMode: (mode: FormMode) => void;
|
|
7
|
+
}
|
|
8
|
+
declare function FormModeSegmentControl({ formConfig, mode, onChangeMode, }: FormModeSegmentControlProps): JSX.Element | null;
|
|
9
|
+
export default FormModeSegmentControl;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type SaveButtonProps } from 'src/components/Form/FormModal';
|
|
3
|
+
import { ResourceConfig } from 'src/types';
|
|
4
|
+
import { CommonFormConfig, RefineFormConfig } from 'src/types';
|
|
5
|
+
import { YamlFormProps } from './YamlForm';
|
|
6
|
+
interface RefineFormContainerProps {
|
|
7
|
+
id: string;
|
|
8
|
+
isYamlMode: boolean;
|
|
9
|
+
config: ResourceConfig;
|
|
10
|
+
formConfig: (RefineFormConfig & CommonFormConfig) | undefined;
|
|
11
|
+
customYamlFormProps?: YamlFormProps;
|
|
12
|
+
onSaveButtonPropsChange?: (props: SaveButtonProps) => void;
|
|
13
|
+
onError?: () => void;
|
|
14
|
+
onSuccess?: () => void;
|
|
15
|
+
}
|
|
16
|
+
declare function RefineFormContainer({ id, config, customYamlFormProps, formConfig, isYamlMode, onSuccess, onError, onSaveButtonPropsChange, }: RefineFormContainerProps): JSX.Element;
|
|
17
|
+
export default RefineFormContainer;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { UseFormReturnType } from '@refinedev/react-hook-form';
|
|
3
|
+
import { RefineFormFieldRenderProps } from 'src/components/Form/type';
|
|
3
4
|
import { ResourceModel } from 'src/models';
|
|
4
|
-
import { ResourceConfig } from 'src/types';
|
|
5
|
+
import { CommonFormConfig, RefineFormConfig, ResourceConfig } from 'src/types';
|
|
5
6
|
type Props<Model extends ResourceModel> = {
|
|
6
7
|
config?: ResourceConfig<Model>;
|
|
8
|
+
formConfig?: CommonFormConfig & RefineFormConfig;
|
|
7
9
|
formResult: UseFormReturnType;
|
|
8
10
|
errorMsgs?: string[];
|
|
9
11
|
resourceId?: string;
|
|
10
12
|
};
|
|
13
|
+
export declare function renderCommonFormFiled(props: RefineFormFieldRenderProps): JSX.Element;
|
|
11
14
|
export declare const RefineFormContent: <Model extends ResourceModel<import("k8s-api-provider").Unstructured>>(props: Props<Model>) => JSX.Element;
|
|
12
15
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { FormAction } from '@refinedev/core';
|
|
3
3
|
import { Unstructured } from 'k8s-api-provider';
|
|
4
|
+
import { ResourceModel } from 'src/models';
|
|
5
|
+
import { ResourceConfig } from 'src/types';
|
|
4
6
|
import useYamlForm from './useYamlForm';
|
|
5
7
|
import { YamlFormRule } from './useYamlForm';
|
|
6
8
|
export declare enum SchemaStrategy {
|
|
@@ -8,9 +10,10 @@ export declare enum SchemaStrategy {
|
|
|
8
10
|
Optional = "Optional",
|
|
9
11
|
None = "None"
|
|
10
12
|
}
|
|
11
|
-
export interface YamlFormProps {
|
|
13
|
+
export interface YamlFormProps<Model extends ResourceModel = ResourceModel> {
|
|
12
14
|
id?: string;
|
|
13
15
|
action?: FormAction;
|
|
16
|
+
config: ResourceConfig<Model>;
|
|
14
17
|
initialValuesForCreate?: Record<string, unknown>;
|
|
15
18
|
initialValuesForEdit?: Record<string, unknown>;
|
|
16
19
|
schemaStrategy?: SchemaStrategy;
|
|
@@ -29,4 +32,4 @@ export interface YamlFormProps {
|
|
|
29
32
|
onErrorsChange?: (errors: string[]) => void;
|
|
30
33
|
onFinish?: () => void;
|
|
31
34
|
}
|
|
32
|
-
export declare function YamlForm(props: YamlFormProps): JSX.Element;
|
|
35
|
+
export declare function YamlForm<Model extends ResourceModel = ResourceModel>(props: YamlFormProps<Model>): JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type SaveButtonProps } from 'src/components/Form/FormModal';
|
|
3
|
+
import { ResourceConfig } from 'src/types';
|
|
4
|
+
import { CommonFormConfig } from 'src/types';
|
|
5
|
+
import { YamlFormConfig } from 'src/types';
|
|
6
|
+
import { YamlFormProps } from './YamlForm';
|
|
7
|
+
interface YamlFormContainerProps {
|
|
8
|
+
id: string;
|
|
9
|
+
config: ResourceConfig;
|
|
10
|
+
customYamlFormProps?: YamlFormProps;
|
|
11
|
+
formConfig?: YamlFormConfig & CommonFormConfig;
|
|
12
|
+
onSuccess?: () => void;
|
|
13
|
+
onError?: () => void;
|
|
14
|
+
onSaveButtonPropsChange?: (props: SaveButtonProps) => void;
|
|
15
|
+
}
|
|
16
|
+
declare function YamlFormContainer({ id, customYamlFormProps, config, formConfig, onSuccess, onError, onSaveButtonPropsChange }: YamlFormContainerProps): JSX.Element;
|
|
17
|
+
export default YamlFormContainer;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Control } from 'react-hook-form';
|
|
3
|
-
|
|
2
|
+
import { Control, UseFormTrigger, FieldValues, ControllerRenderProps } from 'react-hook-form';
|
|
3
|
+
import { FormType } from 'src/types/resource';
|
|
4
|
+
export type RefineFormValidator = (value: unknown, formValue: unknown, formMode: FormType) => {
|
|
4
5
|
isValid: boolean;
|
|
5
6
|
errorMsg: string;
|
|
6
7
|
};
|
|
8
|
+
export type RefineFormFieldRenderProps = {
|
|
9
|
+
field: ControllerRenderProps<FieldValues, string>;
|
|
10
|
+
fieldConfig: RefineFormField;
|
|
11
|
+
action: 'edit' | 'create';
|
|
12
|
+
control: Control;
|
|
13
|
+
trigger: UseFormTrigger<FieldValues>;
|
|
14
|
+
};
|
|
7
15
|
export type RefineFormField = {
|
|
8
16
|
path: string[];
|
|
9
17
|
key: string;
|
|
@@ -13,5 +21,11 @@ export type RefineFormField = {
|
|
|
13
21
|
type?: 'number';
|
|
14
22
|
validators?: RefineFormValidator[];
|
|
15
23
|
disabledWhenEdit?: boolean;
|
|
16
|
-
render?: (
|
|
24
|
+
render?: (props: RefineFormFieldRenderProps) => React.ReactElement;
|
|
25
|
+
/**
|
|
26
|
+
* 表单项条件渲染函数
|
|
27
|
+
* @param formValue 表单值
|
|
28
|
+
* @returns 是否渲染
|
|
29
|
+
*/
|
|
30
|
+
condition?: (formValue: Record<string, unknown>, value: unknown) => boolean;
|
|
17
31
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ResourceModel } from 'src/models';
|
|
2
|
-
import { ResourceConfig } from 'src/types';
|
|
3
|
-
declare function useFieldsConfig<Model extends ResourceModel>(config?: ResourceConfig<Model>, resourceId?: string): import("./type").RefineFormField[] | undefined;
|
|
2
|
+
import { CommonFormConfig, RefineFormConfig, ResourceConfig } from 'src/types';
|
|
3
|
+
declare function useFieldsConfig<Model extends ResourceModel>(config?: ResourceConfig<Model>, formConfig?: CommonFormConfig & RefineFormConfig, resourceId?: string): import("./type").RefineFormField[] | undefined;
|
|
4
4
|
export default useFieldsConfig;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ResourceConfig } from '../../types';
|
|
1
|
+
import { CommonFormConfig, RefineFormConfig, ResourceConfig } from '../../types';
|
|
2
2
|
import { UseFormProps } from './useReactHookForm';
|
|
3
3
|
export declare const useRefineForm: (props: {
|
|
4
|
-
|
|
4
|
+
formConfig?: RefineFormConfig & CommonFormConfig;
|
|
5
5
|
id?: string;
|
|
6
|
+
config: ResourceConfig;
|
|
6
7
|
refineProps?: UseFormProps['refineCoreProps'];
|
|
7
8
|
useFormProps?: UseFormProps;
|
|
8
9
|
}) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TableProps as BaseTableProps, RequiredColumnProps } from '@cloudtower/eagle';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { FormContainerType } from 'src/types';
|
|
4
4
|
export type IDObject = {
|
|
5
5
|
id: string;
|
|
6
6
|
};
|
|
@@ -32,7 +32,7 @@ export type InternalTableProps<Data extends {
|
|
|
32
32
|
onSorterChange?: (order: SorterOrder | null, key?: string) => void;
|
|
33
33
|
RowMenu?: React.FC<{
|
|
34
34
|
record: Data;
|
|
35
|
-
formType?:
|
|
35
|
+
formType?: FormContainerType;
|
|
36
36
|
}>;
|
|
37
37
|
empty?: string;
|
|
38
38
|
showMenuColumn?: boolean;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { YamlFormProps } from '../components';
|
|
3
1
|
interface UseOpenFormOptions {
|
|
4
2
|
id?: string;
|
|
5
|
-
renderForm?: (props: YamlFormProps) => React.ReactNode;
|
|
6
3
|
}
|
|
7
4
|
export declare function useOpenForm(options?: UseOpenFormOptions): () => void;
|
|
8
5
|
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility hook for transforming data structures by mapping paths between different object structures.
|
|
3
|
+
* Useful for converting between form values and API data structures.
|
|
4
|
+
*/
|
|
5
|
+
import { Unstructured } from 'k8s-api-provider';
|
|
6
|
+
interface UsePathMapOptions {
|
|
7
|
+
/** Array of path mappings, each containing source path and target path arrays */
|
|
8
|
+
pathMap?: {
|
|
9
|
+
from: string[];
|
|
10
|
+
to: string[];
|
|
11
|
+
}[];
|
|
12
|
+
/** Optional function to transform initial values after path mapping */
|
|
13
|
+
transformInitValues?: (values: Record<string, unknown>) => Record<string, unknown>;
|
|
14
|
+
/** Optional function to transform values before applying/saving */
|
|
15
|
+
transformApplyValues?: (values: Record<string, unknown>) => Unstructured;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Hook that provides functions to transform data between different object structures using path mappings
|
|
19
|
+
* @param options Configuration options including path mappings and transform functions
|
|
20
|
+
* @returns Object containing transformation functions for init and apply operations
|
|
21
|
+
*/
|
|
22
|
+
declare function usePathMap(options: UsePathMapOptions): {
|
|
23
|
+
transformInitValues: (values: Record<string, unknown>) => Record<string, unknown>;
|
|
24
|
+
transformApplyValues: (values: Record<string, unknown>) => Unstructured;
|
|
25
|
+
};
|
|
26
|
+
export default usePathMap;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StorageClassModel } from 'src/models';
|
|
2
2
|
import { ResourceConfig } from 'src/types';
|
|
3
3
|
type GenerateStorageClassFormConfig = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
isEnabledProvisionerA?: boolean;
|
|
5
|
+
isEnabledProvisionerB?: boolean;
|
|
6
6
|
isVmKsc?: boolean;
|
|
7
7
|
};
|
|
8
|
-
export declare function generateStorageClassFormConfig(options: GenerateStorageClassFormConfig): ResourceConfig<
|
|
8
|
+
export declare function generateStorageClassFormConfig(options: GenerateStorageClassFormConfig): ResourceConfig<StorageClassModel>['formConfig'];
|
|
9
9
|
export {};
|
|
@@ -1,53 +1,5 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { i18n as I18n } from 'i18next';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
basePath: string;
|
|
7
|
-
kind: string;
|
|
8
|
-
parent: RESOURCE_GROUP;
|
|
9
|
-
label: string;
|
|
10
|
-
initValue: {
|
|
11
|
-
apiVersion: string;
|
|
12
|
-
kind: string;
|
|
13
|
-
metadata: {
|
|
14
|
-
name: string;
|
|
15
|
-
};
|
|
16
|
-
parameters: {
|
|
17
|
-
'csi.storage.k8s.io/fstype': string;
|
|
18
|
-
};
|
|
19
|
-
provisioner: string;
|
|
20
|
-
reclaimPolicy: string;
|
|
21
|
-
allowVolumeExpansion: boolean;
|
|
22
|
-
volumeBindingMode: string;
|
|
23
|
-
};
|
|
24
|
-
formConfig: {
|
|
25
|
-
fields?: ((props: {
|
|
26
|
-
record?: import("../..").ResourceModel<import("k8s-api-provider").Unstructured> | undefined;
|
|
27
|
-
records: import("../..").ResourceModel<import("k8s-api-provider").Unstructured>[];
|
|
28
|
-
action: "create" | "edit";
|
|
29
|
-
}) => import("../../components").RefineFormField[]) | undefined;
|
|
30
|
-
saveButtonText?: string | undefined;
|
|
31
|
-
renderForm?: ((props: import("../../components").YamlFormProps) => import("react").ReactNode) | undefined;
|
|
32
|
-
formType?: import("src/types").FormType | undefined;
|
|
33
|
-
transformInitValues?: ((values: Record<string, unknown>) => Record<string, unknown>) | undefined;
|
|
34
|
-
transformApplyValues?: ((values: Record<string, unknown>) => import("k8s-api-provider").Unstructured) | undefined;
|
|
35
|
-
formTitle?: string | ((action: "create" | "edit") => string) | undefined;
|
|
36
|
-
formDesc?: string | ((action: "create" | "edit") => string) | undefined;
|
|
37
|
-
labelWidth?: string | undefined;
|
|
38
|
-
formatError?: ((errorBody: unknown) => string) | undefined;
|
|
39
|
-
refineCoreProps?: import("@refinedev/core").UseFormProps<import("@refinedev/core").BaseRecord, import("@refinedev/core").HttpError, import("react-hook-form").FieldValues, import("@refinedev/core").BaseRecord, import("@refinedev/core").BaseRecord, import("@refinedev/core").HttpError> | undefined;
|
|
40
|
-
useFormProps?: import("@refinedev/react-hook-form").UseFormProps | undefined;
|
|
41
|
-
isDisabledChangeMode?: boolean | undefined;
|
|
42
|
-
CustomFormModal?: import("react").FC<import("../../components").FormModalProps> | undefined;
|
|
43
|
-
} | undefined;
|
|
44
|
-
columns: () => (import("../../components").Column<import("../..").ResourceModel<import("k8s-api-provider").Unstructured>> | import("../../components").Column<import("../..").StorageClassModel>)[];
|
|
45
|
-
showConfig: () => {
|
|
46
|
-
tabs: {
|
|
47
|
-
title: string;
|
|
48
|
-
key: string;
|
|
49
|
-
groups: import("../../components").ShowGroup<import("../..").StorageClassModel>[];
|
|
50
|
-
}[];
|
|
51
|
-
};
|
|
52
|
-
};
|
|
2
|
+
import { StorageClassModel } from 'src/models';
|
|
3
|
+
import { ResourceConfig } from 'src/types';
|
|
4
|
+
export declare const StorageClassConfig: (i18n: I18n) => ResourceConfig<StorageClassModel>;
|
|
53
5
|
export * from './form';
|
package/lib/types/resource.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { UseFormProps } from '@refinedev/react-hook-form';
|
|
3
|
-
import { YamlFormProps } from '../components';
|
|
4
3
|
import { FormModalProps, RefineFormField } from '../components/Form';
|
|
5
4
|
import { Column, InternalTableProps } from '../components/InternalBaseTable';
|
|
6
5
|
import { ShowConfig } from '../components/ShowContent';
|
|
@@ -16,55 +15,182 @@ export declare enum RESOURCE_GROUP {
|
|
|
16
15
|
NODE_MANAGEMENT = "NODE_MANAGEMENT",
|
|
17
16
|
PROJECT = "PROJECT"
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* 表单容器类型
|
|
20
|
+
*/
|
|
21
|
+
export declare enum FormContainerType {
|
|
20
22
|
PAGE = "PAGE",
|
|
21
23
|
MODAL = "MODAL"
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* 表单类型
|
|
27
|
+
*/
|
|
28
|
+
export declare enum FormType {
|
|
29
|
+
YAML = "YAML",
|
|
30
|
+
FORM = "FORM"
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 允许切换的表单模式
|
|
34
|
+
*/
|
|
35
|
+
export declare enum FormMode {
|
|
36
|
+
FORM = "FORM",
|
|
37
|
+
YAML = "YAML"
|
|
38
|
+
}
|
|
23
39
|
export type WithId<T> = T & {
|
|
24
40
|
id: string;
|
|
25
41
|
};
|
|
42
|
+
export type RefineFormConfig<Model extends ResourceModel = ResourceModel> = {
|
|
43
|
+
formType: FormType.FORM;
|
|
44
|
+
/**
|
|
45
|
+
* 表单字段配置函数
|
|
46
|
+
* @param props 包含记录和动作类型的配置对象
|
|
47
|
+
* @returns 表单字段配置数组
|
|
48
|
+
*/
|
|
49
|
+
fields?: (props: {
|
|
50
|
+
record?: Model;
|
|
51
|
+
records: Model[];
|
|
52
|
+
action: 'create' | 'edit';
|
|
53
|
+
}) => RefineFormField[];
|
|
54
|
+
/** Refine Core 的表单属性 */
|
|
55
|
+
refineCoreProps?: UseFormProps['refineCoreProps'];
|
|
56
|
+
/** React Hook Form 的配置属性 */
|
|
57
|
+
useFormProps?: UseFormProps;
|
|
58
|
+
/** 是否禁用切换表单模式(在 YAML 和表单之间切换) */
|
|
59
|
+
isDisabledChangeMode?: boolean;
|
|
60
|
+
/** 表单标签的宽度
|
|
61
|
+
* 默认是 216px
|
|
62
|
+
*/
|
|
63
|
+
labelWidth?: string;
|
|
64
|
+
/**
|
|
65
|
+
* 自定义表单渲染函数
|
|
66
|
+
* @returns React节点
|
|
67
|
+
*/
|
|
68
|
+
renderForm?: () => React.ReactNode;
|
|
69
|
+
};
|
|
70
|
+
export type YamlFormConfig = {
|
|
71
|
+
formType: FormType.YAML;
|
|
72
|
+
};
|
|
73
|
+
export type ErrorBody = {
|
|
74
|
+
kind: string;
|
|
75
|
+
apiVersion: string;
|
|
76
|
+
metadata: object;
|
|
77
|
+
status: string;
|
|
78
|
+
message: string;
|
|
79
|
+
reason: string;
|
|
80
|
+
details: {
|
|
81
|
+
name: string;
|
|
82
|
+
group: string;
|
|
83
|
+
kind: string;
|
|
84
|
+
causes?: {
|
|
85
|
+
reason: string;
|
|
86
|
+
message: string;
|
|
87
|
+
field: string;
|
|
88
|
+
}[];
|
|
89
|
+
};
|
|
90
|
+
code: number;
|
|
91
|
+
};
|
|
92
|
+
export type CommonFormConfig<Model extends ResourceModel = ResourceModel> = {
|
|
93
|
+
/** 自定义表单模态框组件 */
|
|
94
|
+
CustomFormModal?: React.FC<FormModalProps>;
|
|
95
|
+
/**
|
|
96
|
+
* 初始值转换函数
|
|
97
|
+
* @param values 原始值
|
|
98
|
+
* @returns 转换后的值
|
|
99
|
+
*/
|
|
100
|
+
transformInitValues?: (values: Record<string, unknown>) => Record<string, unknown>;
|
|
101
|
+
/**
|
|
102
|
+
* 提交值转换函数,转换为 YAML 格式
|
|
103
|
+
* @param values 表单值
|
|
104
|
+
* @returns YAML格式的数据
|
|
105
|
+
*/
|
|
106
|
+
transformApplyValues?: (values: Record<string, unknown>) => Model['_rawYaml'];
|
|
107
|
+
/** 表单容器类型:页面形式或模态框形式
|
|
108
|
+
* PAGE 或者 MODAL
|
|
109
|
+
*/
|
|
110
|
+
formContainerType?: FormContainerType;
|
|
111
|
+
/**
|
|
112
|
+
* 表单标题,可以是字符串或根据操作类型返回不同标题的函数
|
|
113
|
+
* @param action 操作类型:create 或 edit
|
|
114
|
+
*/
|
|
115
|
+
formTitle?: string | ((action: 'create' | 'edit') => string);
|
|
116
|
+
/**
|
|
117
|
+
* 表单描述,可以是字符串或根据操作类型返回不同描述的函数
|
|
118
|
+
* @param action 操作类型:create 或 edit
|
|
119
|
+
*/
|
|
120
|
+
formDesc?: string | ((action: 'create' | 'edit') => string);
|
|
121
|
+
/** 保存按钮文本 */
|
|
122
|
+
saveButtonText?: string;
|
|
123
|
+
/**
|
|
124
|
+
* 错误信息格式化函数,待完善
|
|
125
|
+
* @param errorBody 错误信息体
|
|
126
|
+
* @returns 格式化后的错误信息
|
|
127
|
+
*/
|
|
128
|
+
formatError?: (errorBody: ErrorBody) => string;
|
|
129
|
+
/**
|
|
130
|
+
* 路径映射,用于在表单中映射路径
|
|
131
|
+
*/
|
|
132
|
+
pathMap?: {
|
|
133
|
+
from: string[];
|
|
134
|
+
to: string[];
|
|
135
|
+
}[];
|
|
136
|
+
};
|
|
26
137
|
export type ResourceConfig<Model extends ResourceModel = ResourceModel> = {
|
|
138
|
+
/** 资源名称,用于 API 调用和路由。
|
|
139
|
+
* 默认复数形式,如:deployments
|
|
140
|
+
*/
|
|
27
141
|
name: string;
|
|
142
|
+
/** Kubernetes 资源类型
|
|
143
|
+
* 如:Deployment
|
|
144
|
+
*/
|
|
28
145
|
kind: string;
|
|
146
|
+
/** API 请求的基础路径
|
|
147
|
+
* 实际效果为:{apiUrl}{basePath}{apiVersion}{name}
|
|
148
|
+
*/
|
|
29
149
|
basePath: string;
|
|
150
|
+
/** Kubernetes API 版本,会影响请求 URL
|
|
151
|
+
* 实际效果为:{apiUrl}{basePath}{apiVersion}{name}
|
|
152
|
+
*/
|
|
30
153
|
apiVersion: string;
|
|
154
|
+
/** 资源在界面上显示的名称 */
|
|
31
155
|
displayName?: string;
|
|
156
|
+
/** 是否隐藏列表页的工具栏。会连标题和描述一起去掉 */
|
|
32
157
|
hideListToolBar?: boolean;
|
|
158
|
+
/** 是否隐藏命名空间过滤器 */
|
|
33
159
|
hideNamespacesFilter?: boolean;
|
|
160
|
+
/** 是否隐藏编辑功能。会隐藏 Dropdown 和详情中的编辑按钮 */
|
|
34
161
|
hideEdit?: boolean;
|
|
162
|
+
/** 是否隐藏创建功能 */
|
|
35
163
|
hideCreate?: boolean;
|
|
164
|
+
/** 资源的描述信息 */
|
|
36
165
|
description?: string;
|
|
166
|
+
/** 父级资源名称,用于建立资源层级关系。在 Dovetail2 中用不到这个 */
|
|
37
167
|
parent?: string;
|
|
168
|
+
/** 格式化数据参数,目前暂未完全实现,可能会删除 */
|
|
38
169
|
formatter?: (v: Model) => Model;
|
|
170
|
+
/** 创建资源时的初始值 */
|
|
39
171
|
initValue?: Record<string, unknown>;
|
|
172
|
+
/** 定义资源列表的表格列配置 */
|
|
40
173
|
columns?: () => Column<Model>[];
|
|
174
|
+
/** 是否禁用详情页面。禁用后,表格的名称将无法点击。仅对配置型表格有效。 */
|
|
41
175
|
noShow?: boolean;
|
|
176
|
+
/** 详情页面的配置 */
|
|
42
177
|
showConfig?: () => ShowConfig<Model>;
|
|
178
|
+
/** 自定义下拉菜单组件 */
|
|
43
179
|
Dropdown?: React.FC<{
|
|
44
180
|
record: Model;
|
|
45
181
|
}>;
|
|
182
|
+
/** 表格组件的额外属性配置。会被传递给表格组件。仅对配置型表格有效。 */
|
|
46
183
|
tableProps?: Partial<InternalTableProps<Model>>;
|
|
184
|
+
/** 是否为自定义资源。
|
|
185
|
+
* 开启后,Dovetail不会为该资源创建路由,也不会渲染默认的UI组件。
|
|
186
|
+
*/
|
|
47
187
|
isCustom?: boolean;
|
|
188
|
+
/** 创建按钮的文本 */
|
|
48
189
|
createButtonText?: string;
|
|
190
|
+
/** 删除操作的提示文本
|
|
191
|
+
* 默认是:该操作无法被撤回。
|
|
192
|
+
*/
|
|
49
193
|
deleteTip?: string;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
record?: Model;
|
|
53
|
-
records: Model[];
|
|
54
|
-
action: 'create' | 'edit';
|
|
55
|
-
}) => RefineFormField[];
|
|
56
|
-
saveButtonText?: string;
|
|
57
|
-
renderForm?: (props: YamlFormProps) => React.ReactNode;
|
|
58
|
-
formType?: FormType;
|
|
59
|
-
transformInitValues?: (values: Record<string, unknown>) => Record<string, unknown>;
|
|
60
|
-
transformApplyValues?: (values: Record<string, unknown>) => Model['_rawYaml'];
|
|
61
|
-
formTitle?: string | ((action: 'create' | 'edit') => string);
|
|
62
|
-
formDesc?: string | ((action: 'create' | 'edit') => string);
|
|
63
|
-
labelWidth?: string;
|
|
64
|
-
formatError?: (errorBody: unknown) => string;
|
|
65
|
-
refineCoreProps?: UseFormProps['refineCoreProps'];
|
|
66
|
-
useFormProps?: UseFormProps;
|
|
67
|
-
isDisabledChangeMode?: boolean;
|
|
68
|
-
CustomFormModal?: React.FC<FormModalProps>;
|
|
69
|
-
};
|
|
194
|
+
/** 表单相关配置 */
|
|
195
|
+
formConfig?: (RefineFormConfig<Model> | YamlFormConfig) & CommonFormConfig<Model>;
|
|
70
196
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function immutableSet<T extends Record<string, unknown> | unknown[] = Record<string, unknown>>(obj: T, path: string | string[], value: unknown): T;
|