@dovetail-v2/refine 0.3.19-alpha.0 → 0.3.19-alpha.2
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/Dropdowns/K8sDropdown/index.d.ts +2 -0
- package/dist/components/Form/FormModal.d.ts +2 -1
- package/dist/components/Form/RefineFormContainer.d.ts +1 -1
- package/dist/components/Form/RefineFormContent.d.ts +1 -1
- package/dist/components/Form/YamlForm.d.ts +1 -1
- package/dist/components/Form/YamlFormContainer.d.ts +1 -1
- package/dist/components/Form/useFieldsConfig.d.ts +1 -1
- package/dist/components/Form/useRefineForm.d.ts +1 -1
- package/dist/hooks/useOpenForm.d.ts +2 -0
- package/dist/refine.cjs +48 -31
- package/dist/refine.js +48 -31
- package/dist/utils/form.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DeleteDialogProps } from '@cloudtower/eagle';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { ResourceConfig } from 'src/types';
|
|
3
4
|
import { ResourceModel } from '../../../models';
|
|
4
5
|
export type DropdownSize = 'normal' | 'large';
|
|
5
6
|
interface K8sDropdownProps {
|
|
@@ -7,6 +8,7 @@ interface K8sDropdownProps {
|
|
|
7
8
|
size?: DropdownSize;
|
|
8
9
|
customButton?: React.ReactNode;
|
|
9
10
|
resourceName?: string;
|
|
11
|
+
config?: Pick<ResourceConfig, 'name' | 'displayName' | 'kind' | 'initValue' | 'apiVersion' | 'basePath' | 'formConfig' | 'hideEdit'>;
|
|
10
12
|
displayName?: string;
|
|
11
13
|
deleteDialogProps?: Partial<DeleteDialogProps>;
|
|
12
14
|
hideEdit?: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WizardDialogProps } from '@cloudtower/eagle/dist/src/core/WizardDialog/type';
|
|
2
2
|
import { BaseRecord, CreateResponse, UpdateResponse } from '@refinedev/core';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { ResourceConfig } from 'src/types';
|
|
4
5
|
import { YamlFormProps } from './YamlForm';
|
|
5
6
|
export type SaveButtonProps = {
|
|
6
7
|
disabled: boolean;
|
|
@@ -15,8 +16,8 @@ export interface ConfirmModalProps {
|
|
|
15
16
|
onOk?: () => void;
|
|
16
17
|
}
|
|
17
18
|
export type FormModalProps = {
|
|
18
|
-
resource?: string;
|
|
19
19
|
id?: string;
|
|
20
|
+
config: Pick<ResourceConfig, 'name' | 'displayName' | 'kind' | 'initValue' | 'apiVersion' | 'basePath' | 'formConfig'>;
|
|
20
21
|
yamlFormProps?: YamlFormProps;
|
|
21
22
|
options?: {
|
|
22
23
|
initialValues?: Record<string, unknown>;
|
|
@@ -7,7 +7,7 @@ import { YamlFormProps } from './YamlForm';
|
|
|
7
7
|
interface RefineFormContainerProps {
|
|
8
8
|
id: string;
|
|
9
9
|
isYamlMode: boolean;
|
|
10
|
-
config: ResourceConfig
|
|
10
|
+
config: Pick<ResourceConfig, 'name' | 'displayName' | 'kind' | 'initValue' | 'basePath' | 'formConfig'>;
|
|
11
11
|
step: number;
|
|
12
12
|
formConfig: (RefineFormConfig & CommonFormConfig) | undefined;
|
|
13
13
|
customYamlFormProps?: YamlFormProps;
|
|
@@ -5,7 +5,7 @@ import { RefineFormFieldRenderProps } from 'src/components/Form/type';
|
|
|
5
5
|
import { ResourceModel } from 'src/models';
|
|
6
6
|
import { CommonFormConfig, RefineFormConfig, ResourceConfig } from 'src/types';
|
|
7
7
|
type RefineFormContentProps<Model extends ResourceModel> = {
|
|
8
|
-
config?: ResourceConfig<Model>;
|
|
8
|
+
config?: Pick<ResourceConfig<Model>, 'name' | 'displayName' | 'kind' | 'initValue' | 'basePath' | 'formConfig'>;
|
|
9
9
|
step?: number;
|
|
10
10
|
formConfig?: CommonFormConfig & RefineFormConfig;
|
|
11
11
|
formResult: UseFormReturnType;
|
|
@@ -14,7 +14,7 @@ export interface YamlFormProps<Model extends ResourceModel = ResourceModel> {
|
|
|
14
14
|
id?: string;
|
|
15
15
|
resource?: string;
|
|
16
16
|
action?: FormAction;
|
|
17
|
-
config: ResourceConfig<Model>;
|
|
17
|
+
config: Pick<ResourceConfig<Model>, 'displayName' | 'dataProviderName' | 'basePath' | 'kind' | 'parent'>;
|
|
18
18
|
initialValuesForCreate?: Record<string, unknown>;
|
|
19
19
|
initialValuesForEdit?: Record<string, unknown>;
|
|
20
20
|
schemaStrategy?: SchemaStrategy;
|
|
@@ -7,7 +7,7 @@ import { YamlFormConfig } from 'src/types';
|
|
|
7
7
|
import { YamlFormProps } from './YamlForm';
|
|
8
8
|
interface YamlFormContainerProps {
|
|
9
9
|
id: string;
|
|
10
|
-
config: ResourceConfig
|
|
10
|
+
config: Pick<ResourceConfig, 'name' | 'displayName' | 'kind' | 'initValue' | 'apiVersion' | 'basePath' | 'formConfig' | 'dataProviderName' | 'parent'>;
|
|
11
11
|
customYamlFormProps?: YamlFormProps;
|
|
12
12
|
formConfig?: YamlFormConfig & CommonFormConfig;
|
|
13
13
|
onSuccess?: (data: UpdateResponse<BaseRecord> | CreateResponse<BaseRecord>) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FieldValues } from 'react-hook-form';
|
|
2
2
|
import { ResourceModel } from 'src/models';
|
|
3
3
|
import { RefineFormConfig, ResourceConfig } from 'src/types';
|
|
4
|
-
declare function useFieldsConfig<Model extends ResourceModel>(config?: ResourceConfig<Model>, formConfig?: {
|
|
4
|
+
declare function useFieldsConfig<Model extends ResourceModel>(config?: Pick<ResourceConfig<Model>, 'name' | 'displayName' | 'kind' | 'initValue' | 'basePath' | 'formConfig'>, formConfig?: {
|
|
5
5
|
fields: RefineFormConfig['fields'];
|
|
6
6
|
}, resourceId?: string, step?: number, customOptions?: Record<string, unknown>, transformedInitValues?: FieldValues): (import("./type").RefineFormField | import("./type").RefineFormSection)[] | undefined;
|
|
7
7
|
export default useFieldsConfig;
|
|
@@ -7,7 +7,7 @@ interface UseRefineFormOptions {
|
|
|
7
7
|
export declare const useRefineForm: (props: {
|
|
8
8
|
formConfig?: RefineFormConfig & CommonFormConfig;
|
|
9
9
|
id?: string;
|
|
10
|
-
config: ResourceConfig
|
|
10
|
+
config: Pick<ResourceConfig, 'name' | 'displayName' | 'kind' | 'initValue' | 'formConfig'>;
|
|
11
11
|
refineProps?: UseFormProps['refineCoreProps'];
|
|
12
12
|
options?: UseRefineFormOptions;
|
|
13
13
|
}) => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CreateResponse, UpdateResponse, BaseRecord } from '@refinedev/core';
|
|
2
|
+
import { ResourceConfig } from 'src/types';
|
|
2
3
|
interface OpenFormOptions {
|
|
3
4
|
id?: string;
|
|
5
|
+
config?: Pick<ResourceConfig, 'name' | 'displayName' | 'kind' | 'initValue' | 'apiVersion' | 'basePath' | 'formConfig'>;
|
|
4
6
|
resourceName?: string;
|
|
5
7
|
initialValues?: Record<string, unknown>;
|
|
6
8
|
customOptions?: Record<string, unknown>;
|
package/dist/refine.cjs
CHANGED
|
@@ -10583,11 +10583,11 @@ function useOpenForm() {
|
|
|
10583
10583
|
const pushModal = eagle.usePushModal();
|
|
10584
10584
|
const go = core.useGo();
|
|
10585
10585
|
return function openForm(options) {
|
|
10586
|
-
var _a;
|
|
10587
|
-
const finalResourceName = (options == null ? void 0 : options.resourceName) || (resource == null ? void 0 : resource.name);
|
|
10588
|
-
if (finalResourceName) {
|
|
10589
|
-
const config = configs[finalResourceName];
|
|
10590
|
-
const formType = (
|
|
10586
|
+
var _a, _b;
|
|
10587
|
+
const finalResourceName = (options == null ? void 0 : options.resourceName) || ((_a = options == null ? void 0 : options.config) == null ? void 0 : _a.name) || (resource == null ? void 0 : resource.name);
|
|
10588
|
+
if (finalResourceName || (options == null ? void 0 : options.config)) {
|
|
10589
|
+
const config = (options == null ? void 0 : options.config) || configs[finalResourceName || ""];
|
|
10590
|
+
const formType = (_b = config.formConfig) == null ? void 0 : _b.formContainerType;
|
|
10591
10591
|
if (formType === void 0 || formType === FormContainerType.MODAL) {
|
|
10592
10592
|
pushModal({
|
|
10593
10593
|
component: () => {
|
|
@@ -10596,8 +10596,8 @@ function useOpenForm() {
|
|
|
10596
10596
|
return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
10597
10597
|
ModalComponent,
|
|
10598
10598
|
{
|
|
10599
|
-
resource: finalResourceName,
|
|
10600
10599
|
id: options == null ? void 0 : options.id,
|
|
10600
|
+
config,
|
|
10601
10601
|
yamlFormProps: {
|
|
10602
10602
|
config
|
|
10603
10603
|
},
|
|
@@ -10612,7 +10612,7 @@ function useOpenForm() {
|
|
|
10612
10612
|
edit2(options.id);
|
|
10613
10613
|
} else {
|
|
10614
10614
|
go({
|
|
10615
|
-
to: navigation.createUrl(finalResourceName),
|
|
10615
|
+
to: navigation.createUrl(finalResourceName || ""),
|
|
10616
10616
|
options: {
|
|
10617
10617
|
keepQuery: true
|
|
10618
10618
|
}
|
|
@@ -10838,6 +10838,7 @@ function K8sDropdown(props) {
|
|
|
10838
10838
|
record,
|
|
10839
10839
|
size = "normal",
|
|
10840
10840
|
resourceName: resourceNameFromProps,
|
|
10841
|
+
config: configFromProps,
|
|
10841
10842
|
customButton,
|
|
10842
10843
|
deleteDialogProps,
|
|
10843
10844
|
displayName,
|
|
@@ -10847,7 +10848,7 @@ function K8sDropdown(props) {
|
|
|
10847
10848
|
const useResourceResult = core.useResource();
|
|
10848
10849
|
const configs = React.useContext(ConfigsContext);
|
|
10849
10850
|
const resourceName = resourceNameFromProps || getResourceNameByKind(record.kind || "", configs);
|
|
10850
|
-
const config = configs[resourceName || ""];
|
|
10851
|
+
const config = configFromProps || configs[resourceName || ""];
|
|
10851
10852
|
const { t: t2, i18n: i18n2 } = common.useTranslation();
|
|
10852
10853
|
const { openDeleteConfirmModal } = useDeleteModal({
|
|
10853
10854
|
resourceName: resourceName || "",
|
|
@@ -10855,7 +10856,10 @@ function K8sDropdown(props) {
|
|
|
10855
10856
|
displayName,
|
|
10856
10857
|
meta: record.apiVersion ? {
|
|
10857
10858
|
kind: record.kind || "",
|
|
10858
|
-
resourceBasePath: (
|
|
10859
|
+
resourceBasePath: (
|
|
10860
|
+
// k8s 通用规则,apiVersion 包含 / 则使用 apis,否则使用 api
|
|
10861
|
+
(((_a = record.apiVersion) == null ? void 0 : _a.includes("/")) ? "apis" : "api") + `/${record.apiVersion}`
|
|
10862
|
+
)
|
|
10859
10863
|
} : void 0
|
|
10860
10864
|
});
|
|
10861
10865
|
const download2 = useDownloadYAML();
|
|
@@ -10880,10 +10884,16 @@ function K8sDropdown(props) {
|
|
|
10880
10884
|
eagle.Dropdown,
|
|
10881
10885
|
{
|
|
10882
10886
|
overlay: /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.Menu, { children: [
|
|
10883
|
-
isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false || hideEdit || (config == null ? void 0 : config.hideEdit) ? null : /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
+
isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false || hideEdit || (config == null ? void 0 : config.hideEdit) ? null : /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
10888
|
+
eagle.Menu.Item,
|
|
10889
|
+
{
|
|
10890
|
+
onClick: () => openForm({ id: record.id, resourceName, config }),
|
|
10891
|
+
children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Icon, { src: iconsReact.EditPen16PrimaryIcon, children: formType === FormType.FORM ? `${t2("dovetail.edit")}${transformResourceKindInSentence(
|
|
10892
|
+
displayName || (config == null ? void 0 : config.displayName) || record.kind || "",
|
|
10893
|
+
i18n2.language
|
|
10894
|
+
)}` : t2("dovetail.edit_yaml") })
|
|
10895
|
+
}
|
|
10896
|
+
),
|
|
10887
10897
|
/* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
10888
10898
|
eagle.Menu.Item,
|
|
10889
10899
|
{
|
|
@@ -14620,7 +14630,7 @@ function ListPage(props) {
|
|
|
14620
14630
|
})]
|
|
14621
14631
|
}) : void 0, /* @__PURE__ */ common.jsxRuntimeExports.jsxs("div", {
|
|
14622
14632
|
className: common.cx_default(ListContentStyle, contentClassName),
|
|
14623
|
-
style: !config.customFilterBar && config.nonNsResource ? {
|
|
14633
|
+
style: !customFilterBar && !config.customFilterBar && config.nonNsResource ? {
|
|
14624
14634
|
paddingTop: 0
|
|
14625
14635
|
} : {},
|
|
14626
14636
|
children: [customFilterBar || config.customFilterBar || !config.nonNsResource && /* @__PURE__ */ common.jsxRuntimeExports.jsx(NamespacesFilter, {
|
|
@@ -15745,14 +15755,14 @@ const useRefineForm = (props) => {
|
|
|
15745
15755
|
var _a;
|
|
15746
15756
|
const formValue = result.getValues();
|
|
15747
15757
|
return {
|
|
15748
|
-
message: i18n2.t(
|
|
15749
|
-
|
|
15750
|
-
|
|
15751
|
-
|
|
15752
|
-
|
|
15753
|
-
|
|
15754
|
-
}
|
|
15755
|
-
).trim(),
|
|
15758
|
+
message: i18n2.t(id ? "dovetail.edit_resource_success" : "dovetail.create_success_toast", {
|
|
15759
|
+
kind: transformResourceKindInSentence(
|
|
15760
|
+
config.displayName || config.kind,
|
|
15761
|
+
i18n2.language
|
|
15762
|
+
),
|
|
15763
|
+
name: (_a = formValue.metadata) == null ? void 0 : _a.name,
|
|
15764
|
+
interpolation: { escapeValue: false }
|
|
15765
|
+
}).trim(),
|
|
15756
15766
|
description: "Success",
|
|
15757
15767
|
type: "success"
|
|
15758
15768
|
};
|
|
@@ -15776,11 +15786,19 @@ const useRefineForm = (props) => {
|
|
|
15776
15786
|
if (response && !(response == null ? void 0 : response.bodyUsed)) {
|
|
15777
15787
|
(_b = response.json) == null ? void 0 : _b.call(response).then((body) => {
|
|
15778
15788
|
var _a2;
|
|
15779
|
-
setResponseErrorMsgs(
|
|
15789
|
+
setResponseErrorMsgs(
|
|
15790
|
+
[].concat(
|
|
15791
|
+
((_a2 = formConfig == null ? void 0 : formConfig.formatError) == null ? void 0 : _a2.call(formConfig, body)) || getCommonErrors(body, i18n2)
|
|
15792
|
+
)
|
|
15793
|
+
);
|
|
15780
15794
|
});
|
|
15781
15795
|
}
|
|
15782
15796
|
}, [formConfig, result, i18n2]);
|
|
15783
|
-
return {
|
|
15797
|
+
return {
|
|
15798
|
+
formResult: result,
|
|
15799
|
+
responseErrorMsgs,
|
|
15800
|
+
beforeSubmitErrors: result.beforeSubmitErrors
|
|
15801
|
+
};
|
|
15784
15802
|
};
|
|
15785
15803
|
const index_2ivb33 = "";
|
|
15786
15804
|
const Style = "s1bsn3us";
|
|
@@ -16513,7 +16531,11 @@ function YamlForm(props) {
|
|
|
16513
16531
|
transformInitValues,
|
|
16514
16532
|
transformApplyValues,
|
|
16515
16533
|
mutationMeta: {
|
|
16516
|
-
updateType: "put"
|
|
16534
|
+
updateType: "put",
|
|
16535
|
+
dataProviderName: config.dataProviderName,
|
|
16536
|
+
resourceBasePath: config.basePath,
|
|
16537
|
+
kind: config.kind,
|
|
16538
|
+
label: `${config.kind}s`
|
|
16517
16539
|
},
|
|
16518
16540
|
...useFormProps
|
|
16519
16541
|
});
|
|
@@ -16835,20 +16857,16 @@ function ConfirmModal({
|
|
|
16835
16857
|
function FormModal(props) {
|
|
16836
16858
|
var _a, _b, _c, _d;
|
|
16837
16859
|
const {
|
|
16838
|
-
resource: resourceFromProps,
|
|
16839
16860
|
id,
|
|
16840
16861
|
yamlFormProps: customYamlFormProps,
|
|
16841
16862
|
modalProps,
|
|
16842
16863
|
options,
|
|
16864
|
+
config,
|
|
16843
16865
|
onSuccess
|
|
16844
16866
|
} = props;
|
|
16845
16867
|
const {
|
|
16846
16868
|
i18n: i18n2
|
|
16847
16869
|
} = common.useTranslation();
|
|
16848
|
-
const {
|
|
16849
|
-
resource
|
|
16850
|
-
} = core.useResource();
|
|
16851
|
-
const configs = React.useContext(ConfigsContext);
|
|
16852
16870
|
const [saveButtonProps, setSaveButtonProps] = React.useState({});
|
|
16853
16871
|
const [isError, setIsError] = React.useState(false);
|
|
16854
16872
|
const [mode, setMode] = React.useState(FormMode.FORM);
|
|
@@ -16857,7 +16875,6 @@ function FormModal(props) {
|
|
|
16857
16875
|
const refineFormContainerRef = React.useRef(null);
|
|
16858
16876
|
const popModal = eagle.usePopModal();
|
|
16859
16877
|
const pushModal = eagle.usePushModal();
|
|
16860
|
-
const config = configs[resourceFromProps || (resource == null ? void 0 : resource.name) || ""];
|
|
16861
16878
|
const isDisabledChangeMode = config.formConfig && "isDisabledChangeMode" in config.formConfig && config.formConfig.isDisabledChangeMode;
|
|
16862
16879
|
const okText = i18n2.t(id ? "dovetail.save" : "dovetail.create");
|
|
16863
16880
|
const action = id ? "edit" : "create";
|
package/dist/refine.js
CHANGED
|
@@ -10564,11 +10564,11 @@ function useOpenForm() {
|
|
|
10564
10564
|
const pushModal = usePushModal();
|
|
10565
10565
|
const go = useGo();
|
|
10566
10566
|
return function openForm(options) {
|
|
10567
|
-
var _a;
|
|
10568
|
-
const finalResourceName = (options == null ? void 0 : options.resourceName) || (resource == null ? void 0 : resource.name);
|
|
10569
|
-
if (finalResourceName) {
|
|
10570
|
-
const config = configs[finalResourceName];
|
|
10571
|
-
const formType = (
|
|
10567
|
+
var _a, _b;
|
|
10568
|
+
const finalResourceName = (options == null ? void 0 : options.resourceName) || ((_a = options == null ? void 0 : options.config) == null ? void 0 : _a.name) || (resource == null ? void 0 : resource.name);
|
|
10569
|
+
if (finalResourceName || (options == null ? void 0 : options.config)) {
|
|
10570
|
+
const config = (options == null ? void 0 : options.config) || configs[finalResourceName || ""];
|
|
10571
|
+
const formType = (_b = config.formConfig) == null ? void 0 : _b.formContainerType;
|
|
10572
10572
|
if (formType === void 0 || formType === FormContainerType.MODAL) {
|
|
10573
10573
|
pushModal({
|
|
10574
10574
|
component: () => {
|
|
@@ -10577,8 +10577,8 @@ function useOpenForm() {
|
|
|
10577
10577
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
10578
10578
|
ModalComponent,
|
|
10579
10579
|
{
|
|
10580
|
-
resource: finalResourceName,
|
|
10581
10580
|
id: options == null ? void 0 : options.id,
|
|
10581
|
+
config,
|
|
10582
10582
|
yamlFormProps: {
|
|
10583
10583
|
config
|
|
10584
10584
|
},
|
|
@@ -10593,7 +10593,7 @@ function useOpenForm() {
|
|
|
10593
10593
|
edit2(options.id);
|
|
10594
10594
|
} else {
|
|
10595
10595
|
go({
|
|
10596
|
-
to: navigation.createUrl(finalResourceName),
|
|
10596
|
+
to: navigation.createUrl(finalResourceName || ""),
|
|
10597
10597
|
options: {
|
|
10598
10598
|
keepQuery: true
|
|
10599
10599
|
}
|
|
@@ -10819,6 +10819,7 @@ function K8sDropdown(props) {
|
|
|
10819
10819
|
record,
|
|
10820
10820
|
size = "normal",
|
|
10821
10821
|
resourceName: resourceNameFromProps,
|
|
10822
|
+
config: configFromProps,
|
|
10822
10823
|
customButton,
|
|
10823
10824
|
deleteDialogProps,
|
|
10824
10825
|
displayName,
|
|
@@ -10828,7 +10829,7 @@ function K8sDropdown(props) {
|
|
|
10828
10829
|
const useResourceResult = useResource();
|
|
10829
10830
|
const configs = useContext(ConfigsContext);
|
|
10830
10831
|
const resourceName = resourceNameFromProps || getResourceNameByKind(record.kind || "", configs);
|
|
10831
|
-
const config = configs[resourceName || ""];
|
|
10832
|
+
const config = configFromProps || configs[resourceName || ""];
|
|
10832
10833
|
const { t: t2, i18n: i18n2 } = useTranslation();
|
|
10833
10834
|
const { openDeleteConfirmModal } = useDeleteModal({
|
|
10834
10835
|
resourceName: resourceName || "",
|
|
@@ -10836,7 +10837,10 @@ function K8sDropdown(props) {
|
|
|
10836
10837
|
displayName,
|
|
10837
10838
|
meta: record.apiVersion ? {
|
|
10838
10839
|
kind: record.kind || "",
|
|
10839
|
-
resourceBasePath: (
|
|
10840
|
+
resourceBasePath: (
|
|
10841
|
+
// k8s 通用规则,apiVersion 包含 / 则使用 apis,否则使用 api
|
|
10842
|
+
(((_a = record.apiVersion) == null ? void 0 : _a.includes("/")) ? "apis" : "api") + `/${record.apiVersion}`
|
|
10843
|
+
)
|
|
10840
10844
|
} : void 0
|
|
10841
10845
|
});
|
|
10842
10846
|
const download2 = useDownloadYAML();
|
|
@@ -10861,10 +10865,16 @@ function K8sDropdown(props) {
|
|
|
10861
10865
|
Dropdown,
|
|
10862
10866
|
{
|
|
10863
10867
|
overlay: /* @__PURE__ */ jsxRuntimeExports.jsxs(Menu$1, { children: [
|
|
10864
|
-
isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false || hideEdit || (config == null ? void 0 : config.hideEdit) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
+
isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false || hideEdit || (config == null ? void 0 : config.hideEdit) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
10869
|
+
Menu$1.Item,
|
|
10870
|
+
{
|
|
10871
|
+
onClick: () => openForm({ id: record.id, resourceName, config }),
|
|
10872
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { src: EditPen16PrimaryIcon, children: formType === FormType.FORM ? `${t2("dovetail.edit")}${transformResourceKindInSentence(
|
|
10873
|
+
displayName || (config == null ? void 0 : config.displayName) || record.kind || "",
|
|
10874
|
+
i18n2.language
|
|
10875
|
+
)}` : t2("dovetail.edit_yaml") })
|
|
10876
|
+
}
|
|
10877
|
+
),
|
|
10868
10878
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
10869
10879
|
Menu$1.Item,
|
|
10870
10880
|
{
|
|
@@ -14601,7 +14611,7 @@ function ListPage(props) {
|
|
|
14601
14611
|
})]
|
|
14602
14612
|
}) : void 0, /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
|
|
14603
14613
|
className: cx_default(ListContentStyle, contentClassName),
|
|
14604
|
-
style: !config.customFilterBar && config.nonNsResource ? {
|
|
14614
|
+
style: !customFilterBar && !config.customFilterBar && config.nonNsResource ? {
|
|
14605
14615
|
paddingTop: 0
|
|
14606
14616
|
} : {},
|
|
14607
14617
|
children: [customFilterBar || config.customFilterBar || !config.nonNsResource && /* @__PURE__ */ jsxRuntimeExports.jsx(NamespacesFilter, {
|
|
@@ -15726,14 +15736,14 @@ const useRefineForm = (props) => {
|
|
|
15726
15736
|
var _a;
|
|
15727
15737
|
const formValue = result.getValues();
|
|
15728
15738
|
return {
|
|
15729
|
-
message: i18n2.t(
|
|
15730
|
-
|
|
15731
|
-
|
|
15732
|
-
|
|
15733
|
-
|
|
15734
|
-
|
|
15735
|
-
}
|
|
15736
|
-
).trim(),
|
|
15739
|
+
message: i18n2.t(id ? "dovetail.edit_resource_success" : "dovetail.create_success_toast", {
|
|
15740
|
+
kind: transformResourceKindInSentence(
|
|
15741
|
+
config.displayName || config.kind,
|
|
15742
|
+
i18n2.language
|
|
15743
|
+
),
|
|
15744
|
+
name: (_a = formValue.metadata) == null ? void 0 : _a.name,
|
|
15745
|
+
interpolation: { escapeValue: false }
|
|
15746
|
+
}).trim(),
|
|
15737
15747
|
description: "Success",
|
|
15738
15748
|
type: "success"
|
|
15739
15749
|
};
|
|
@@ -15757,11 +15767,19 @@ const useRefineForm = (props) => {
|
|
|
15757
15767
|
if (response && !(response == null ? void 0 : response.bodyUsed)) {
|
|
15758
15768
|
(_b = response.json) == null ? void 0 : _b.call(response).then((body) => {
|
|
15759
15769
|
var _a2;
|
|
15760
|
-
setResponseErrorMsgs(
|
|
15770
|
+
setResponseErrorMsgs(
|
|
15771
|
+
[].concat(
|
|
15772
|
+
((_a2 = formConfig == null ? void 0 : formConfig.formatError) == null ? void 0 : _a2.call(formConfig, body)) || getCommonErrors(body, i18n2)
|
|
15773
|
+
)
|
|
15774
|
+
);
|
|
15761
15775
|
});
|
|
15762
15776
|
}
|
|
15763
15777
|
}, [formConfig, result, i18n2]);
|
|
15764
|
-
return {
|
|
15778
|
+
return {
|
|
15779
|
+
formResult: result,
|
|
15780
|
+
responseErrorMsgs,
|
|
15781
|
+
beforeSubmitErrors: result.beforeSubmitErrors
|
|
15782
|
+
};
|
|
15765
15783
|
};
|
|
15766
15784
|
const index_2ivb33 = "";
|
|
15767
15785
|
const Style = "s1bsn3us";
|
|
@@ -16494,7 +16512,11 @@ function YamlForm(props) {
|
|
|
16494
16512
|
transformInitValues,
|
|
16495
16513
|
transformApplyValues,
|
|
16496
16514
|
mutationMeta: {
|
|
16497
|
-
updateType: "put"
|
|
16515
|
+
updateType: "put",
|
|
16516
|
+
dataProviderName: config.dataProviderName,
|
|
16517
|
+
resourceBasePath: config.basePath,
|
|
16518
|
+
kind: config.kind,
|
|
16519
|
+
label: `${config.kind}s`
|
|
16498
16520
|
},
|
|
16499
16521
|
...useFormProps
|
|
16500
16522
|
});
|
|
@@ -16816,20 +16838,16 @@ function ConfirmModal({
|
|
|
16816
16838
|
function FormModal(props) {
|
|
16817
16839
|
var _a, _b, _c, _d;
|
|
16818
16840
|
const {
|
|
16819
|
-
resource: resourceFromProps,
|
|
16820
16841
|
id,
|
|
16821
16842
|
yamlFormProps: customYamlFormProps,
|
|
16822
16843
|
modalProps,
|
|
16823
16844
|
options,
|
|
16845
|
+
config,
|
|
16824
16846
|
onSuccess
|
|
16825
16847
|
} = props;
|
|
16826
16848
|
const {
|
|
16827
16849
|
i18n: i18n2
|
|
16828
16850
|
} = useTranslation();
|
|
16829
|
-
const {
|
|
16830
|
-
resource
|
|
16831
|
-
} = useResource();
|
|
16832
|
-
const configs = useContext(ConfigsContext);
|
|
16833
16851
|
const [saveButtonProps, setSaveButtonProps] = useState({});
|
|
16834
16852
|
const [isError, setIsError] = useState(false);
|
|
16835
16853
|
const [mode, setMode] = useState(FormMode.FORM);
|
|
@@ -16838,7 +16856,6 @@ function FormModal(props) {
|
|
|
16838
16856
|
const refineFormContainerRef = useRef(null);
|
|
16839
16857
|
const popModal = usePopModal();
|
|
16840
16858
|
const pushModal = usePushModal();
|
|
16841
|
-
const config = configs[resourceFromProps || (resource == null ? void 0 : resource.name) || ""];
|
|
16842
16859
|
const isDisabledChangeMode = config.formConfig && "isDisabledChangeMode" in config.formConfig && config.formConfig.isDisabledChangeMode;
|
|
16843
16860
|
const okText = i18n2.t(id ? "dovetail.save" : "dovetail.create");
|
|
16844
16861
|
const action = id ? "edit" : "create";
|
package/dist/utils/form.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ResourceModel } from 'src/models';
|
|
2
2
|
import { ResourceConfig } from 'src/types';
|
|
3
|
-
export declare function getInitialValues<Model extends ResourceModel = ResourceModel>(config: ResourceConfig<Model>): Record<string, unknown>;
|
|
3
|
+
export declare function getInitialValues<Model extends ResourceModel = ResourceModel>(config: Pick<ResourceConfig<Model>, 'apiVersion' | 'kind' | 'initValue'>): Record<string, unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dovetail-v2/refine",
|
|
3
|
-
"version": "0.3.19-alpha.
|
|
3
|
+
"version": "0.3.19-alpha.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dayjs": "^1.11.10",
|
|
31
31
|
"i18next": "^23.2.3",
|
|
32
32
|
"js-yaml": "^4.1.0",
|
|
33
|
-
"k8s-api-provider": "^0.0.
|
|
33
|
+
"k8s-api-provider": "^0.0.35",
|
|
34
34
|
"ky": "^0.33.3",
|
|
35
35
|
"lodash-es": "^4.17.21",
|
|
36
36
|
"mitt": "^3.0.1",
|