@dovetail-v2/refine 0.3.18-alpha.0 → 0.3.18
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 +0 -5
- package/dist/components/InternalBaseTable/index.d.ts +2 -2
- package/dist/components/ListPage/index.d.ts +0 -2
- package/dist/components/Table/index.d.ts +0 -1
- package/dist/hooks/useDeleteModal/useDeleteModal.d.ts +1 -3
- package/dist/hooks/useDeleteModal/useDeleteModalOnly.d.ts +1 -3
- package/dist/hooks/useDeleteModal/useFailedModal.d.ts +1 -4
- package/dist/hooks/useEagleTable/useEagleTable.d.ts +1 -1
- package/dist/refine.cjs +47 -94
- package/dist/refine.js +47 -94
- package/dist/types/resource.d.ts +4 -4
- package/package.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DeleteDialogProps } from '@cloudtower/eagle';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { ResourceModel } from '../../../models';
|
|
4
3
|
export type DropdownSize = 'normal' | 'large';
|
|
@@ -6,10 +5,6 @@ interface K8sDropdownProps {
|
|
|
6
5
|
record: ResourceModel;
|
|
7
6
|
size?: DropdownSize;
|
|
8
7
|
customButton?: React.ReactNode;
|
|
9
|
-
resourceName?: string;
|
|
10
|
-
displayName?: string;
|
|
11
|
-
deleteDialogProps?: Partial<DeleteDialogProps>;
|
|
12
|
-
hideEdit?: boolean;
|
|
13
8
|
}
|
|
14
9
|
export declare function K8sDropdown(props: React.PropsWithChildren<K8sDropdownProps>): JSX.Element;
|
|
15
10
|
export default K8sDropdown;
|
|
@@ -36,8 +36,8 @@ export type InternalTableProps<Data extends {
|
|
|
36
36
|
}>;
|
|
37
37
|
empty?: string;
|
|
38
38
|
showMenuColumn?: boolean;
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
nonNsResource?: boolean;
|
|
40
|
+
customFilterBar?: React.ReactNode;
|
|
41
41
|
onClearSearchKeyword?: () => void;
|
|
42
42
|
};
|
|
43
43
|
declare function Table<Data extends {
|
|
@@ -6,8 +6,6 @@ interface ListPageProps<T extends ResourceModel> {
|
|
|
6
6
|
tableProps: InternalTableProps<T>;
|
|
7
7
|
contentClassName?: string;
|
|
8
8
|
belowToolBarContent?: React.ReactNode;
|
|
9
|
-
customNamespaceFilter?: React.ReactNode;
|
|
10
|
-
isSearching?: boolean;
|
|
11
9
|
}
|
|
12
10
|
export declare function ListPage<T extends ResourceModel>(props: ListPageProps<T>): JSX.Element;
|
|
13
11
|
export {};
|
|
@@ -6,7 +6,6 @@ interface TableProps<Model extends ResourceModel> {
|
|
|
6
6
|
tableProps: InternalTableProps<Model>;
|
|
7
7
|
displayName: string;
|
|
8
8
|
errorContentProps?: WidgetErrorContentProps;
|
|
9
|
-
isSearching?: boolean;
|
|
10
9
|
}
|
|
11
10
|
export declare function Table<Model extends ResourceModel>(props: TableProps<Model>): JSX.Element;
|
|
12
11
|
export {};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { DeleteDialogProps } from '@cloudtower/eagle';
|
|
2
2
|
type useDeleteDialogProps = {
|
|
3
3
|
resourceName: string;
|
|
4
|
-
displayName?: string;
|
|
5
|
-
meta?: Record<string, string>;
|
|
6
4
|
deleteDialogProps?: Partial<DeleteDialogProps>;
|
|
7
5
|
};
|
|
8
6
|
/**
|
|
9
7
|
* 打开确认删除弹窗,如果失败会自动弹出回绝弹窗
|
|
10
8
|
*/
|
|
11
|
-
export declare const useDeleteModal: ({ resourceName,
|
|
9
|
+
export declare const useDeleteModal: ({ resourceName, deleteDialogProps, }: useDeleteDialogProps) => {
|
|
12
10
|
openDeleteConfirmModal: (id: string) => void;
|
|
13
11
|
closeDeleteConfirmModal: () => void;
|
|
14
12
|
};
|
|
@@ -2,12 +2,10 @@ import { DeleteDialogProps } from '@cloudtower/eagle';
|
|
|
2
2
|
import { HttpError } from '@refinedev/core';
|
|
3
3
|
type useDeleteModalOnlyProps = {
|
|
4
4
|
resource: string;
|
|
5
|
-
displayName?: string;
|
|
6
|
-
meta?: Record<string, string>;
|
|
7
5
|
onError?: (resourceId: string, error?: HttpError) => void;
|
|
8
6
|
deleteDialogProps?: Partial<DeleteDialogProps>;
|
|
9
7
|
};
|
|
10
|
-
export declare const useDeleteModalOnly: ({ resource: resourceFromProps,
|
|
8
|
+
export declare const useDeleteModalOnly: ({ resource: resourceFromProps, deleteDialogProps, onError, }: useDeleteModalOnlyProps) => {
|
|
11
9
|
openDeleteConfirmModal: (id: string) => void;
|
|
12
10
|
closeDeleteConfirmModal: () => void;
|
|
13
11
|
};
|
|
@@ -25,7 +25,6 @@ export declare function addDefaultRenderToColumns<Data, Col extends RequiredColu
|
|
|
25
25
|
render(value: unknown): JSX.Element;
|
|
26
26
|
} & Col)[];
|
|
27
27
|
export declare const useEagleTable: <Model extends ResourceModel<import("k8s-api-provider").Unstructured>>(params: Params<Model>) => {
|
|
28
|
-
setCurrent: (current: number) => void;
|
|
29
28
|
tableQueryResult: import("@tanstack/query-core").QueryObserverResult<import("@refinedev/core").GetListResponse<Model>, import("@refinedev/core").HttpError>;
|
|
30
29
|
sorter: import("@refinedev/core").CrudSorting;
|
|
31
30
|
sorters: import("@refinedev/core").CrudSorting;
|
|
@@ -43,6 +42,7 @@ export declare const useEagleTable: <Model extends ResourceModel<import("k8s-api
|
|
|
43
42
|
filters: import("@refinedev/core").CrudFilters;
|
|
44
43
|
}) => string;
|
|
45
44
|
current: number;
|
|
45
|
+
setCurrent: (value: React.SetStateAction<number>) => void;
|
|
46
46
|
pageSize: number;
|
|
47
47
|
setPageSize: (value: React.SetStateAction<number>) => void;
|
|
48
48
|
pageCount: number;
|
package/dist/refine.cjs
CHANGED
|
@@ -7433,21 +7433,18 @@ function transformResourceKindInSentence(str, language) {
|
|
|
7433
7433
|
}
|
|
7434
7434
|
const useDeleteModalOnly = ({
|
|
7435
7435
|
resource: resourceFromProps,
|
|
7436
|
-
displayName: displayNameFromProps,
|
|
7437
7436
|
deleteDialogProps,
|
|
7438
|
-
meta,
|
|
7439
7437
|
onError
|
|
7440
7438
|
}) => {
|
|
7441
7439
|
const { resource } = core.useResource();
|
|
7442
7440
|
const configs = React.useContext(ConfigsContext);
|
|
7443
7441
|
const config = configs[resourceFromProps];
|
|
7444
7442
|
const { mutateAsync } = core.useDelete();
|
|
7445
|
-
const [deleting, setDeleting] = React.useState(false);
|
|
7446
7443
|
const pushModal = eagle.usePushModal();
|
|
7447
7444
|
const popModal = eagle.usePopModal();
|
|
7448
7445
|
const navigation = core.useNavigation();
|
|
7449
7446
|
const { t: t2, i18n: i18n2 } = common.useTranslation();
|
|
7450
|
-
const displayName =
|
|
7447
|
+
const displayName = config.displayName || config.kind;
|
|
7451
7448
|
const resourceDisplayName = transformResourceKindInSentence(displayName, i18n2.language);
|
|
7452
7449
|
function openDeleteConfirmModal(id) {
|
|
7453
7450
|
pushModal({
|
|
@@ -7470,13 +7467,10 @@ const useDeleteModalOnly = ({
|
|
|
7470
7467
|
),
|
|
7471
7468
|
secondaryDesc: t2("dovetail.delete_tip"),
|
|
7472
7469
|
okText: t2("dovetail.delete"),
|
|
7473
|
-
confirmLoading: deleting,
|
|
7474
7470
|
onOk: async (popModal2) => {
|
|
7475
7471
|
try {
|
|
7476
|
-
setDeleting(true);
|
|
7477
7472
|
await mutateAsync({
|
|
7478
7473
|
resource: resourceFromProps,
|
|
7479
|
-
meta,
|
|
7480
7474
|
id,
|
|
7481
7475
|
successNotification() {
|
|
7482
7476
|
return {
|
|
@@ -7500,7 +7494,6 @@ const useDeleteModalOnly = ({
|
|
|
7500
7494
|
}
|
|
7501
7495
|
popModal2();
|
|
7502
7496
|
} finally {
|
|
7503
|
-
setDeleting(false);
|
|
7504
7497
|
}
|
|
7505
7498
|
},
|
|
7506
7499
|
...deleteDialogProps
|
|
@@ -7509,14 +7502,13 @@ const useDeleteModalOnly = ({
|
|
|
7509
7502
|
}
|
|
7510
7503
|
return { openDeleteConfirmModal, closeDeleteConfirmModal: popModal };
|
|
7511
7504
|
};
|
|
7512
|
-
const useFailedModal = (
|
|
7513
|
-
const { resource, displayName: displayNameFromProps } = props;
|
|
7505
|
+
const useFailedModal = (resource) => {
|
|
7514
7506
|
const configs = React.useContext(ConfigsContext);
|
|
7515
7507
|
const config = configs[resource];
|
|
7516
7508
|
const { t: t2, i18n: i18n2 } = common.useTranslation();
|
|
7517
7509
|
const pushModal = eagle.usePushModal();
|
|
7518
7510
|
const popModal = eagle.usePopModal();
|
|
7519
|
-
const displayName =
|
|
7511
|
+
const displayName = config.displayName || config.kind;
|
|
7520
7512
|
const resourceDisplayName = transformResourceKindInSentence(displayName, i18n2.language);
|
|
7521
7513
|
function openFailedModal(id, errorMsgs) {
|
|
7522
7514
|
pushModal({
|
|
@@ -7550,25 +7542,15 @@ const useFailedModal = (props) => {
|
|
|
7550
7542
|
};
|
|
7551
7543
|
const useDeleteModal = ({
|
|
7552
7544
|
resourceName,
|
|
7553
|
-
displayName,
|
|
7554
|
-
meta,
|
|
7555
7545
|
deleteDialogProps
|
|
7556
7546
|
}) => {
|
|
7557
7547
|
const { i18n: i18n2 } = common.useTranslation();
|
|
7558
7548
|
const configs = React.useContext(ConfigsContext);
|
|
7559
7549
|
const config = configs[resourceName];
|
|
7560
|
-
const { openFailedModal } = useFailedModal(
|
|
7561
|
-
resource: resourceName,
|
|
7562
|
-
displayName
|
|
7563
|
-
});
|
|
7550
|
+
const { openFailedModal } = useFailedModal(resourceName);
|
|
7564
7551
|
const { openDeleteConfirmModal, closeDeleteConfirmModal } = useDeleteModalOnly({
|
|
7565
7552
|
resource: resourceName,
|
|
7566
|
-
|
|
7567
|
-
meta,
|
|
7568
|
-
deleteDialogProps: {
|
|
7569
|
-
secondaryDesc: (config == null ? void 0 : config.deleteTip) || i18n2.t("dovetail.delete_tip"),
|
|
7570
|
-
...deleteDialogProps
|
|
7571
|
-
},
|
|
7553
|
+
deleteDialogProps: { secondaryDesc: config.deleteTip, ...deleteDialogProps },
|
|
7572
7554
|
onError: async (id, error) => {
|
|
7573
7555
|
closeDeleteConfirmModal();
|
|
7574
7556
|
openFailedModal(id, getCommonErrors(await (error == null ? void 0 : error.response.json()), i18n2));
|
|
@@ -10203,7 +10185,7 @@ const ServiceOutClusterAccessComponent = ({
|
|
|
10203
10185
|
case ServiceTypeEnum.NodePort:
|
|
10204
10186
|
if (!breakLine) {
|
|
10205
10187
|
content = (_a = spec.ports) == null ? void 0 : _a.filter((v) => !!v).map((p) => [/* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Link, {
|
|
10206
|
-
href:
|
|
10188
|
+
href: `http://${clusterVip}:${p.nodePort}`,
|
|
10207
10189
|
target: "_blank",
|
|
10208
10190
|
className: common.cx_default(LinkStyle$2, eagle.Typo.Label.l4_regular_title),
|
|
10209
10191
|
children: `${clusterVip}:${p.nodePort}`
|
|
@@ -10222,7 +10204,7 @@ const ServiceOutClusterAccessComponent = ({
|
|
|
10222
10204
|
}
|
|
10223
10205
|
content = (_b = spec.ports) == null ? void 0 : _b.filter((v) => !!v).map((p) => /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.OverflowTooltip, {
|
|
10224
10206
|
content: /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.Link, {
|
|
10225
|
-
href:
|
|
10207
|
+
href: `http://${clusterVip}:${p.nodePort}`,
|
|
10226
10208
|
target: "_blank",
|
|
10227
10209
|
className: common.cx_default(eagle.Typo.Label.l4_regular_title, BreakLineStyle, LinkStyle$2),
|
|
10228
10210
|
children: [clusterVip, ":", p.nodePort]
|
|
@@ -10258,7 +10240,8 @@ const ServiceOutClusterAccessComponent = ({
|
|
|
10258
10240
|
}
|
|
10259
10241
|
return /* @__PURE__ */ common.jsxRuntimeExports.jsx("div", {
|
|
10260
10242
|
style: {
|
|
10261
|
-
whiteSpace: "pre-wrap"
|
|
10243
|
+
whiteSpace: "pre-wrap",
|
|
10244
|
+
color: "#0080ff"
|
|
10262
10245
|
},
|
|
10263
10246
|
children: content || "-"
|
|
10264
10247
|
});
|
|
@@ -10832,34 +10815,18 @@ function validateNodePort(nodePort, allNodePorts, i18n2) {
|
|
|
10832
10815
|
return { isValid: true };
|
|
10833
10816
|
}
|
|
10834
10817
|
function K8sDropdown(props) {
|
|
10835
|
-
var _a, _b
|
|
10836
|
-
const {
|
|
10837
|
-
record,
|
|
10838
|
-
size = "normal",
|
|
10839
|
-
resourceName: resourceNameFromProps,
|
|
10840
|
-
customButton,
|
|
10841
|
-
deleteDialogProps,
|
|
10842
|
-
displayName,
|
|
10843
|
-
hideEdit
|
|
10844
|
-
} = props;
|
|
10818
|
+
var _a, _b;
|
|
10819
|
+
const { record, size = "normal", customButton } = props;
|
|
10845
10820
|
const globalStore = useGlobalStore();
|
|
10846
10821
|
const useResourceResult = core.useResource();
|
|
10847
10822
|
const configs = React.useContext(ConfigsContext);
|
|
10848
|
-
const resourceName =
|
|
10823
|
+
const resourceName = getResourceNameByKind(record.kind || "", configs);
|
|
10849
10824
|
const config = configs[resourceName || ""];
|
|
10850
10825
|
const { t: t2, i18n: i18n2 } = common.useTranslation();
|
|
10851
|
-
const { openDeleteConfirmModal } = useDeleteModal({
|
|
10852
|
-
resourceName: resourceName || "",
|
|
10853
|
-
deleteDialogProps,
|
|
10854
|
-
displayName,
|
|
10855
|
-
meta: record.apiVersion ? {
|
|
10856
|
-
kind: record.kind || "",
|
|
10857
|
-
resourceBasePath: (((_a = record.apiVersion) == null ? void 0 : _a.includes("/")) ? "apis" : "api") + `/${record.apiVersion}`
|
|
10858
|
-
} : void 0
|
|
10859
|
-
});
|
|
10826
|
+
const { openDeleteConfirmModal } = useDeleteModal({ resourceName: resourceName || "" });
|
|
10860
10827
|
const download2 = useDownloadYAML();
|
|
10861
10828
|
const openForm = useOpenForm();
|
|
10862
|
-
const isInShowPage = useResourceResult.action === "show" && ((
|
|
10829
|
+
const isInShowPage = useResourceResult.action === "show" && ((_a = useResourceResult.resource) == null ? void 0 : _a.name) === config.name;
|
|
10863
10830
|
const { data: canEditData } = core.useCan({
|
|
10864
10831
|
resource: resourceName,
|
|
10865
10832
|
action: AccessControlAuth.Edit,
|
|
@@ -10874,12 +10841,12 @@ function K8sDropdown(props) {
|
|
|
10874
10841
|
namespace: record.namespace
|
|
10875
10842
|
}
|
|
10876
10843
|
});
|
|
10877
|
-
const formType = (
|
|
10844
|
+
const formType = ((_b = config.formConfig) == null ? void 0 : _b.formType) || FormType.FORM;
|
|
10878
10845
|
return /* @__PURE__ */ common.jsxRuntimeExports.jsx(common.jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
10879
10846
|
eagle.Dropdown,
|
|
10880
10847
|
{
|
|
10881
10848
|
overlay: /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.Menu, { children: [
|
|
10882
|
-
isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false ||
|
|
10849
|
+
isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false || config.hideEdit ? null : /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Menu.Item, { onClick: () => openForm({ id: record.id, resourceName }), children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.Icon, { src: iconsReact.EditPen16PrimaryIcon, children: formType === FormType.FORM ? `${t2("dovetail.edit")}${transformResourceKindInSentence(
|
|
10883
10850
|
(config == null ? void 0 : config.displayName) || record.kind || "",
|
|
10884
10851
|
i18n2.language
|
|
10885
10852
|
)}` : t2("dovetail.edit_yaml") }) }),
|
|
@@ -10944,7 +10911,12 @@ var ColumnKeys = /* @__PURE__ */ ((ColumnKeys2) => {
|
|
|
10944
10911
|
function addDefaultRenderToColumns(columns) {
|
|
10945
10912
|
return columns.map((col) => ({
|
|
10946
10913
|
render(value2) {
|
|
10947
|
-
return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
10914
|
+
return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
10915
|
+
ValueDisplay,
|
|
10916
|
+
{
|
|
10917
|
+
value: value2
|
|
10918
|
+
}
|
|
10919
|
+
);
|
|
10948
10920
|
},
|
|
10949
10921
|
...col
|
|
10950
10922
|
}));
|
|
@@ -10980,23 +10952,18 @@ const useEagleTable = (params) => {
|
|
|
10980
10952
|
},
|
|
10981
10953
|
[setCurrentPage, table]
|
|
10982
10954
|
);
|
|
10983
|
-
const onSorterChange = React.useCallback(
|
|
10984
|
-
|
|
10985
|
-
|
|
10986
|
-
|
|
10987
|
-
|
|
10988
|
-
|
|
10989
|
-
|
|
10990
|
-
|
|
10991
|
-
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
];
|
|
10996
|
-
table.setSorters(sorters);
|
|
10997
|
-
},
|
|
10998
|
-
[table, columns]
|
|
10999
|
-
);
|
|
10955
|
+
const onSorterChange = React.useCallback((order, key2) => {
|
|
10956
|
+
var _a2;
|
|
10957
|
+
const ORDER_MAP = {
|
|
10958
|
+
descend: "desc",
|
|
10959
|
+
ascend: "asc"
|
|
10960
|
+
};
|
|
10961
|
+
const sorters = [{
|
|
10962
|
+
field: (_a2 = columns.find((col) => col.key === key2)) == null ? void 0 : _a2.dataIndex,
|
|
10963
|
+
order: order ? ORDER_MAP[order] : order
|
|
10964
|
+
}];
|
|
10965
|
+
table.setSorters(sorters);
|
|
10966
|
+
}, [table, columns]);
|
|
11000
10967
|
const data2 = (_a = table.tableQueryResult.data) == null ? void 0 : _a.data;
|
|
11001
10968
|
const total = ((_b = table.tableQueryResult.data) == null ? void 0 : _b.total) || 0;
|
|
11002
10969
|
const finalDataSource = formatter ? data2 == null ? void 0 : data2.map(formatter) : data2;
|
|
@@ -11019,23 +10986,12 @@ const useEagleTable = (params) => {
|
|
|
11019
10986
|
defaultSize: currentSize
|
|
11020
10987
|
};
|
|
11021
10988
|
React.useEffect(() => {
|
|
11022
|
-
table.setSorters([
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
}
|
|
11027
|
-
]);
|
|
10989
|
+
table.setSorters([{
|
|
10990
|
+
field: "metadata.creationTimestamp",
|
|
10991
|
+
order: "desc"
|
|
10992
|
+
}]);
|
|
11028
10993
|
}, []);
|
|
11029
|
-
return {
|
|
11030
|
-
tableProps: finalProps,
|
|
11031
|
-
selectedKeys,
|
|
11032
|
-
...table,
|
|
11033
|
-
setCurrent: (current) => {
|
|
11034
|
-
var _a2;
|
|
11035
|
-
setCurrentPage(current);
|
|
11036
|
-
(_a2 = table.setCurrent) == null ? void 0 : _a2.call(table, current);
|
|
11037
|
-
}
|
|
11038
|
-
};
|
|
10994
|
+
return { tableProps: finalProps, selectedKeys, ...table };
|
|
11039
10995
|
};
|
|
11040
10996
|
function CreateButton(props) {
|
|
11041
10997
|
var _a;
|
|
@@ -12210,7 +12166,7 @@ function PVVolumeModeDisplay(props) {
|
|
|
12210
12166
|
}
|
|
12211
12167
|
function Table(props) {
|
|
12212
12168
|
var _a;
|
|
12213
|
-
const { tableProps, displayName, errorContentProps
|
|
12169
|
+
const { tableProps, displayName, errorContentProps } = props;
|
|
12214
12170
|
const { Table: TableComponent } = React.useContext(ComponentContext);
|
|
12215
12171
|
const Table2 = TableComponent || Table$1;
|
|
12216
12172
|
const { params } = core.useParsed();
|
|
@@ -12218,7 +12174,7 @@ function Table(props) {
|
|
|
12218
12174
|
const resourceType = transformResourceKindInSentence(displayName, i18n2.language);
|
|
12219
12175
|
if (!((_a = tableProps.data) == null ? void 0 : _a.length) && !tableProps.loading) {
|
|
12220
12176
|
const nameKeyword = (params == null ? void 0 : params[NAME_KEYWORD_PARAM]) || "";
|
|
12221
|
-
if (nameKeyword
|
|
12177
|
+
if (nameKeyword) {
|
|
12222
12178
|
const onClear = () => {
|
|
12223
12179
|
var _a2;
|
|
12224
12180
|
(_a2 = tableProps.onClearSearchKeyword) == null ? void 0 : _a2.call(tableProps);
|
|
@@ -14411,7 +14367,7 @@ const useNamespacesFilter = () => {
|
|
|
14411
14367
|
resource
|
|
14412
14368
|
} = core.useResource();
|
|
14413
14369
|
const configs = React.useContext(ConfigsContext);
|
|
14414
|
-
if ((resource == null ? void 0 : resource.name) && configs[resource == null ? void 0 : resource.name].
|
|
14370
|
+
if ((resource == null ? void 0 : resource.name) && configs[resource == null ? void 0 : resource.name].nonNsResource) {
|
|
14415
14371
|
return {
|
|
14416
14372
|
value: []
|
|
14417
14373
|
};
|
|
@@ -14592,9 +14548,7 @@ function ListPage(props) {
|
|
|
14592
14548
|
selectedKeys,
|
|
14593
14549
|
tableProps,
|
|
14594
14550
|
contentClassName,
|
|
14595
|
-
belowToolBarContent
|
|
14596
|
-
customNamespaceFilter,
|
|
14597
|
-
isSearching
|
|
14551
|
+
belowToolBarContent
|
|
14598
14552
|
} = props;
|
|
14599
14553
|
const {
|
|
14600
14554
|
resource
|
|
@@ -14619,12 +14573,12 @@ function ListPage(props) {
|
|
|
14619
14573
|
})]
|
|
14620
14574
|
}) : void 0, /* @__PURE__ */ common.jsxRuntimeExports.jsxs("div", {
|
|
14621
14575
|
className: common.cx_default(ListContentStyle, contentClassName),
|
|
14622
|
-
style: config.
|
|
14576
|
+
style: !config.customFilterBar && config.nonNsResource ? {
|
|
14623
14577
|
paddingTop: 0
|
|
14624
14578
|
} : {},
|
|
14625
|
-
children: [
|
|
14579
|
+
children: [config.customFilterBar || !config.nonNsResource && /* @__PURE__ */ common.jsxRuntimeExports.jsx(NamespacesFilter, {
|
|
14626
14580
|
className: NamespaceFilterStyle
|
|
14627
|
-
})
|
|
14581
|
+
}), /* @__PURE__ */ common.jsxRuntimeExports.jsx("div", {
|
|
14628
14582
|
className: TableStyle,
|
|
14629
14583
|
children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(Table, {
|
|
14630
14584
|
tableProps: {
|
|
@@ -14633,8 +14587,7 @@ function ListPage(props) {
|
|
|
14633
14587
|
y: "calc(100% - 48px)"
|
|
14634
14588
|
}
|
|
14635
14589
|
},
|
|
14636
|
-
displayName: (config == null ? void 0 : config.displayName) || config.kind
|
|
14637
|
-
isSearching
|
|
14590
|
+
displayName: (config == null ? void 0 : config.displayName) || config.kind
|
|
14638
14591
|
})
|
|
14639
14592
|
})]
|
|
14640
14593
|
})]
|
package/dist/refine.js
CHANGED
|
@@ -7414,21 +7414,18 @@ function transformResourceKindInSentence(str, language) {
|
|
|
7414
7414
|
}
|
|
7415
7415
|
const useDeleteModalOnly = ({
|
|
7416
7416
|
resource: resourceFromProps,
|
|
7417
|
-
displayName: displayNameFromProps,
|
|
7418
7417
|
deleteDialogProps,
|
|
7419
|
-
meta,
|
|
7420
7418
|
onError
|
|
7421
7419
|
}) => {
|
|
7422
7420
|
const { resource } = useResource();
|
|
7423
7421
|
const configs = useContext(ConfigsContext);
|
|
7424
7422
|
const config = configs[resourceFromProps];
|
|
7425
7423
|
const { mutateAsync } = useDelete();
|
|
7426
|
-
const [deleting, setDeleting] = useState(false);
|
|
7427
7424
|
const pushModal = usePushModal();
|
|
7428
7425
|
const popModal = usePopModal();
|
|
7429
7426
|
const navigation = useNavigation();
|
|
7430
7427
|
const { t: t2, i18n: i18n2 } = useTranslation();
|
|
7431
|
-
const displayName =
|
|
7428
|
+
const displayName = config.displayName || config.kind;
|
|
7432
7429
|
const resourceDisplayName = transformResourceKindInSentence(displayName, i18n2.language);
|
|
7433
7430
|
function openDeleteConfirmModal(id) {
|
|
7434
7431
|
pushModal({
|
|
@@ -7451,13 +7448,10 @@ const useDeleteModalOnly = ({
|
|
|
7451
7448
|
),
|
|
7452
7449
|
secondaryDesc: t2("dovetail.delete_tip"),
|
|
7453
7450
|
okText: t2("dovetail.delete"),
|
|
7454
|
-
confirmLoading: deleting,
|
|
7455
7451
|
onOk: async (popModal2) => {
|
|
7456
7452
|
try {
|
|
7457
|
-
setDeleting(true);
|
|
7458
7453
|
await mutateAsync({
|
|
7459
7454
|
resource: resourceFromProps,
|
|
7460
|
-
meta,
|
|
7461
7455
|
id,
|
|
7462
7456
|
successNotification() {
|
|
7463
7457
|
return {
|
|
@@ -7481,7 +7475,6 @@ const useDeleteModalOnly = ({
|
|
|
7481
7475
|
}
|
|
7482
7476
|
popModal2();
|
|
7483
7477
|
} finally {
|
|
7484
|
-
setDeleting(false);
|
|
7485
7478
|
}
|
|
7486
7479
|
},
|
|
7487
7480
|
...deleteDialogProps
|
|
@@ -7490,14 +7483,13 @@ const useDeleteModalOnly = ({
|
|
|
7490
7483
|
}
|
|
7491
7484
|
return { openDeleteConfirmModal, closeDeleteConfirmModal: popModal };
|
|
7492
7485
|
};
|
|
7493
|
-
const useFailedModal = (
|
|
7494
|
-
const { resource, displayName: displayNameFromProps } = props;
|
|
7486
|
+
const useFailedModal = (resource) => {
|
|
7495
7487
|
const configs = useContext(ConfigsContext);
|
|
7496
7488
|
const config = configs[resource];
|
|
7497
7489
|
const { t: t2, i18n: i18n2 } = useTranslation();
|
|
7498
7490
|
const pushModal = usePushModal();
|
|
7499
7491
|
const popModal = usePopModal();
|
|
7500
|
-
const displayName =
|
|
7492
|
+
const displayName = config.displayName || config.kind;
|
|
7501
7493
|
const resourceDisplayName = transformResourceKindInSentence(displayName, i18n2.language);
|
|
7502
7494
|
function openFailedModal(id, errorMsgs) {
|
|
7503
7495
|
pushModal({
|
|
@@ -7531,25 +7523,15 @@ const useFailedModal = (props) => {
|
|
|
7531
7523
|
};
|
|
7532
7524
|
const useDeleteModal = ({
|
|
7533
7525
|
resourceName,
|
|
7534
|
-
displayName,
|
|
7535
|
-
meta,
|
|
7536
7526
|
deleteDialogProps
|
|
7537
7527
|
}) => {
|
|
7538
7528
|
const { i18n: i18n2 } = useTranslation();
|
|
7539
7529
|
const configs = useContext(ConfigsContext);
|
|
7540
7530
|
const config = configs[resourceName];
|
|
7541
|
-
const { openFailedModal } = useFailedModal(
|
|
7542
|
-
resource: resourceName,
|
|
7543
|
-
displayName
|
|
7544
|
-
});
|
|
7531
|
+
const { openFailedModal } = useFailedModal(resourceName);
|
|
7545
7532
|
const { openDeleteConfirmModal, closeDeleteConfirmModal } = useDeleteModalOnly({
|
|
7546
7533
|
resource: resourceName,
|
|
7547
|
-
|
|
7548
|
-
meta,
|
|
7549
|
-
deleteDialogProps: {
|
|
7550
|
-
secondaryDesc: (config == null ? void 0 : config.deleteTip) || i18n2.t("dovetail.delete_tip"),
|
|
7551
|
-
...deleteDialogProps
|
|
7552
|
-
},
|
|
7534
|
+
deleteDialogProps: { secondaryDesc: config.deleteTip, ...deleteDialogProps },
|
|
7553
7535
|
onError: async (id, error) => {
|
|
7554
7536
|
closeDeleteConfirmModal();
|
|
7555
7537
|
openFailedModal(id, getCommonErrors(await (error == null ? void 0 : error.response.json()), i18n2));
|
|
@@ -10184,7 +10166,7 @@ const ServiceOutClusterAccessComponent = ({
|
|
|
10184
10166
|
case ServiceTypeEnum.NodePort:
|
|
10185
10167
|
if (!breakLine) {
|
|
10186
10168
|
content = (_a = spec.ports) == null ? void 0 : _a.filter((v) => !!v).map((p) => [/* @__PURE__ */ jsxRuntimeExports.jsx(Link$1, {
|
|
10187
|
-
href:
|
|
10169
|
+
href: `http://${clusterVip}:${p.nodePort}`,
|
|
10188
10170
|
target: "_blank",
|
|
10189
10171
|
className: cx_default(LinkStyle$2, Typo.Label.l4_regular_title),
|
|
10190
10172
|
children: `${clusterVip}:${p.nodePort}`
|
|
@@ -10203,7 +10185,7 @@ const ServiceOutClusterAccessComponent = ({
|
|
|
10203
10185
|
}
|
|
10204
10186
|
content = (_b = spec.ports) == null ? void 0 : _b.filter((v) => !!v).map((p) => /* @__PURE__ */ jsxRuntimeExports.jsx(OverflowTooltip, {
|
|
10205
10187
|
content: /* @__PURE__ */ jsxRuntimeExports.jsxs(Link$1, {
|
|
10206
|
-
href:
|
|
10188
|
+
href: `http://${clusterVip}:${p.nodePort}`,
|
|
10207
10189
|
target: "_blank",
|
|
10208
10190
|
className: cx_default(Typo.Label.l4_regular_title, BreakLineStyle, LinkStyle$2),
|
|
10209
10191
|
children: [clusterVip, ":", p.nodePort]
|
|
@@ -10239,7 +10221,8 @@ const ServiceOutClusterAccessComponent = ({
|
|
|
10239
10221
|
}
|
|
10240
10222
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
|
|
10241
10223
|
style: {
|
|
10242
|
-
whiteSpace: "pre-wrap"
|
|
10224
|
+
whiteSpace: "pre-wrap",
|
|
10225
|
+
color: "#0080ff"
|
|
10243
10226
|
},
|
|
10244
10227
|
children: content || "-"
|
|
10245
10228
|
});
|
|
@@ -10813,34 +10796,18 @@ function validateNodePort(nodePort, allNodePorts, i18n2) {
|
|
|
10813
10796
|
return { isValid: true };
|
|
10814
10797
|
}
|
|
10815
10798
|
function K8sDropdown(props) {
|
|
10816
|
-
var _a, _b
|
|
10817
|
-
const {
|
|
10818
|
-
record,
|
|
10819
|
-
size = "normal",
|
|
10820
|
-
resourceName: resourceNameFromProps,
|
|
10821
|
-
customButton,
|
|
10822
|
-
deleteDialogProps,
|
|
10823
|
-
displayName,
|
|
10824
|
-
hideEdit
|
|
10825
|
-
} = props;
|
|
10799
|
+
var _a, _b;
|
|
10800
|
+
const { record, size = "normal", customButton } = props;
|
|
10826
10801
|
const globalStore = useGlobalStore();
|
|
10827
10802
|
const useResourceResult = useResource();
|
|
10828
10803
|
const configs = useContext(ConfigsContext);
|
|
10829
|
-
const resourceName =
|
|
10804
|
+
const resourceName = getResourceNameByKind(record.kind || "", configs);
|
|
10830
10805
|
const config = configs[resourceName || ""];
|
|
10831
10806
|
const { t: t2, i18n: i18n2 } = useTranslation();
|
|
10832
|
-
const { openDeleteConfirmModal } = useDeleteModal({
|
|
10833
|
-
resourceName: resourceName || "",
|
|
10834
|
-
deleteDialogProps,
|
|
10835
|
-
displayName,
|
|
10836
|
-
meta: record.apiVersion ? {
|
|
10837
|
-
kind: record.kind || "",
|
|
10838
|
-
resourceBasePath: (((_a = record.apiVersion) == null ? void 0 : _a.includes("/")) ? "apis" : "api") + `/${record.apiVersion}`
|
|
10839
|
-
} : void 0
|
|
10840
|
-
});
|
|
10807
|
+
const { openDeleteConfirmModal } = useDeleteModal({ resourceName: resourceName || "" });
|
|
10841
10808
|
const download2 = useDownloadYAML();
|
|
10842
10809
|
const openForm = useOpenForm();
|
|
10843
|
-
const isInShowPage = useResourceResult.action === "show" && ((
|
|
10810
|
+
const isInShowPage = useResourceResult.action === "show" && ((_a = useResourceResult.resource) == null ? void 0 : _a.name) === config.name;
|
|
10844
10811
|
const { data: canEditData } = useCan({
|
|
10845
10812
|
resource: resourceName,
|
|
10846
10813
|
action: AccessControlAuth.Edit,
|
|
@@ -10855,12 +10822,12 @@ function K8sDropdown(props) {
|
|
|
10855
10822
|
namespace: record.namespace
|
|
10856
10823
|
}
|
|
10857
10824
|
});
|
|
10858
|
-
const formType = (
|
|
10825
|
+
const formType = ((_b = config.formConfig) == null ? void 0 : _b.formType) || FormType.FORM;
|
|
10859
10826
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
10860
10827
|
Dropdown,
|
|
10861
10828
|
{
|
|
10862
10829
|
overlay: /* @__PURE__ */ jsxRuntimeExports.jsxs(Menu$1, { children: [
|
|
10863
|
-
isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false ||
|
|
10830
|
+
isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false || config.hideEdit ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(Menu$1.Item, { onClick: () => openForm({ id: record.id, resourceName }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { src: EditPen16PrimaryIcon, children: formType === FormType.FORM ? `${t2("dovetail.edit")}${transformResourceKindInSentence(
|
|
10864
10831
|
(config == null ? void 0 : config.displayName) || record.kind || "",
|
|
10865
10832
|
i18n2.language
|
|
10866
10833
|
)}` : t2("dovetail.edit_yaml") }) }),
|
|
@@ -10925,7 +10892,12 @@ var ColumnKeys = /* @__PURE__ */ ((ColumnKeys2) => {
|
|
|
10925
10892
|
function addDefaultRenderToColumns(columns) {
|
|
10926
10893
|
return columns.map((col) => ({
|
|
10927
10894
|
render(value2) {
|
|
10928
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
10895
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
10896
|
+
ValueDisplay,
|
|
10897
|
+
{
|
|
10898
|
+
value: value2
|
|
10899
|
+
}
|
|
10900
|
+
);
|
|
10929
10901
|
},
|
|
10930
10902
|
...col
|
|
10931
10903
|
}));
|
|
@@ -10961,23 +10933,18 @@ const useEagleTable = (params) => {
|
|
|
10961
10933
|
},
|
|
10962
10934
|
[setCurrentPage, table]
|
|
10963
10935
|
);
|
|
10964
|
-
const onSorterChange = useCallback(
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
];
|
|
10977
|
-
table.setSorters(sorters);
|
|
10978
|
-
},
|
|
10979
|
-
[table, columns]
|
|
10980
|
-
);
|
|
10936
|
+
const onSorterChange = useCallback((order, key2) => {
|
|
10937
|
+
var _a2;
|
|
10938
|
+
const ORDER_MAP = {
|
|
10939
|
+
descend: "desc",
|
|
10940
|
+
ascend: "asc"
|
|
10941
|
+
};
|
|
10942
|
+
const sorters = [{
|
|
10943
|
+
field: (_a2 = columns.find((col) => col.key === key2)) == null ? void 0 : _a2.dataIndex,
|
|
10944
|
+
order: order ? ORDER_MAP[order] : order
|
|
10945
|
+
}];
|
|
10946
|
+
table.setSorters(sorters);
|
|
10947
|
+
}, [table, columns]);
|
|
10981
10948
|
const data2 = (_a = table.tableQueryResult.data) == null ? void 0 : _a.data;
|
|
10982
10949
|
const total = ((_b = table.tableQueryResult.data) == null ? void 0 : _b.total) || 0;
|
|
10983
10950
|
const finalDataSource = formatter ? data2 == null ? void 0 : data2.map(formatter) : data2;
|
|
@@ -11000,23 +10967,12 @@ const useEagleTable = (params) => {
|
|
|
11000
10967
|
defaultSize: currentSize
|
|
11001
10968
|
};
|
|
11002
10969
|
useEffect(() => {
|
|
11003
|
-
table.setSorters([
|
|
11004
|
-
|
|
11005
|
-
|
|
11006
|
-
|
|
11007
|
-
}
|
|
11008
|
-
]);
|
|
10970
|
+
table.setSorters([{
|
|
10971
|
+
field: "metadata.creationTimestamp",
|
|
10972
|
+
order: "desc"
|
|
10973
|
+
}]);
|
|
11009
10974
|
}, []);
|
|
11010
|
-
return {
|
|
11011
|
-
tableProps: finalProps,
|
|
11012
|
-
selectedKeys,
|
|
11013
|
-
...table,
|
|
11014
|
-
setCurrent: (current) => {
|
|
11015
|
-
var _a2;
|
|
11016
|
-
setCurrentPage(current);
|
|
11017
|
-
(_a2 = table.setCurrent) == null ? void 0 : _a2.call(table, current);
|
|
11018
|
-
}
|
|
11019
|
-
};
|
|
10975
|
+
return { tableProps: finalProps, selectedKeys, ...table };
|
|
11020
10976
|
};
|
|
11021
10977
|
function CreateButton(props) {
|
|
11022
10978
|
var _a;
|
|
@@ -12191,7 +12147,7 @@ function PVVolumeModeDisplay(props) {
|
|
|
12191
12147
|
}
|
|
12192
12148
|
function Table(props) {
|
|
12193
12149
|
var _a;
|
|
12194
|
-
const { tableProps, displayName, errorContentProps
|
|
12150
|
+
const { tableProps, displayName, errorContentProps } = props;
|
|
12195
12151
|
const { Table: TableComponent } = useContext(ComponentContext);
|
|
12196
12152
|
const Table2 = TableComponent || Table$1;
|
|
12197
12153
|
const { params } = useParsed();
|
|
@@ -12199,7 +12155,7 @@ function Table(props) {
|
|
|
12199
12155
|
const resourceType = transformResourceKindInSentence(displayName, i18n2.language);
|
|
12200
12156
|
if (!((_a = tableProps.data) == null ? void 0 : _a.length) && !tableProps.loading) {
|
|
12201
12157
|
const nameKeyword = (params == null ? void 0 : params[NAME_KEYWORD_PARAM]) || "";
|
|
12202
|
-
if (nameKeyword
|
|
12158
|
+
if (nameKeyword) {
|
|
12203
12159
|
const onClear = () => {
|
|
12204
12160
|
var _a2;
|
|
12205
12161
|
(_a2 = tableProps.onClearSearchKeyword) == null ? void 0 : _a2.call(tableProps);
|
|
@@ -14392,7 +14348,7 @@ const useNamespacesFilter = () => {
|
|
|
14392
14348
|
resource
|
|
14393
14349
|
} = useResource();
|
|
14394
14350
|
const configs = useContext(ConfigsContext);
|
|
14395
|
-
if ((resource == null ? void 0 : resource.name) && configs[resource == null ? void 0 : resource.name].
|
|
14351
|
+
if ((resource == null ? void 0 : resource.name) && configs[resource == null ? void 0 : resource.name].nonNsResource) {
|
|
14396
14352
|
return {
|
|
14397
14353
|
value: []
|
|
14398
14354
|
};
|
|
@@ -14573,9 +14529,7 @@ function ListPage(props) {
|
|
|
14573
14529
|
selectedKeys,
|
|
14574
14530
|
tableProps,
|
|
14575
14531
|
contentClassName,
|
|
14576
|
-
belowToolBarContent
|
|
14577
|
-
customNamespaceFilter,
|
|
14578
|
-
isSearching
|
|
14532
|
+
belowToolBarContent
|
|
14579
14533
|
} = props;
|
|
14580
14534
|
const {
|
|
14581
14535
|
resource
|
|
@@ -14600,12 +14554,12 @@ function ListPage(props) {
|
|
|
14600
14554
|
})]
|
|
14601
14555
|
}) : void 0, /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
|
|
14602
14556
|
className: cx_default(ListContentStyle, contentClassName),
|
|
14603
|
-
style: config.
|
|
14557
|
+
style: !config.customFilterBar && config.nonNsResource ? {
|
|
14604
14558
|
paddingTop: 0
|
|
14605
14559
|
} : {},
|
|
14606
|
-
children: [
|
|
14560
|
+
children: [config.customFilterBar || !config.nonNsResource && /* @__PURE__ */ jsxRuntimeExports.jsx(NamespacesFilter, {
|
|
14607
14561
|
className: NamespaceFilterStyle
|
|
14608
|
-
})
|
|
14562
|
+
}), /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
|
|
14609
14563
|
className: TableStyle,
|
|
14610
14564
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Table, {
|
|
14611
14565
|
tableProps: {
|
|
@@ -14614,8 +14568,7 @@ function ListPage(props) {
|
|
|
14614
14568
|
y: "calc(100% - 48px)"
|
|
14615
14569
|
}
|
|
14616
14570
|
},
|
|
14617
|
-
displayName: (config == null ? void 0 : config.displayName) || config.kind
|
|
14618
|
-
isSearching
|
|
14571
|
+
displayName: (config == null ? void 0 : config.displayName) || config.kind
|
|
14619
14572
|
})
|
|
14620
14573
|
})]
|
|
14621
14574
|
})]
|
package/dist/types/resource.d.ts
CHANGED
|
@@ -171,10 +171,10 @@ export type ResourceConfig<Model extends ResourceModel = ResourceModel> = {
|
|
|
171
171
|
displayName?: string;
|
|
172
172
|
/** 是否隐藏列表页的工具栏。会连标题和描述一起去掉 */
|
|
173
173
|
hideListToolBar?: boolean;
|
|
174
|
-
/**
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
|
|
174
|
+
/** 非命名空间资源,不展示默认的 NsFilter,并且禁用根据 ns 筛选的逻辑 */
|
|
175
|
+
nonNsResource?: boolean;
|
|
176
|
+
/** 自定义过滤栏 */
|
|
177
|
+
customFilterBar?: React.ReactNode;
|
|
178
178
|
/** 是否隐藏编辑功能。会隐藏 Dropdown 和详情中的编辑按钮 */
|
|
179
179
|
hideEdit?: boolean;
|
|
180
180
|
/** 是否隐藏创建功能 */
|