@dovetail-v2/refine 0.3.17 → 0.3.18-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.
@@ -1,3 +1,4 @@
1
+ import { DeleteDialogProps } from '@cloudtower/eagle';
1
2
  import React from 'react';
2
3
  import { ResourceModel } from '../../../models';
3
4
  export type DropdownSize = 'normal' | 'large';
@@ -5,6 +6,10 @@ interface K8sDropdownProps {
5
6
  record: ResourceModel;
6
7
  size?: DropdownSize;
7
8
  customButton?: React.ReactNode;
9
+ resourceName?: string;
10
+ displayName?: string;
11
+ deleteDialogProps?: Partial<DeleteDialogProps>;
12
+ hideEdit?: boolean;
8
13
  }
9
14
  export declare function K8sDropdown(props: React.PropsWithChildren<K8sDropdownProps>): JSX.Element;
10
15
  export default K8sDropdown;
@@ -6,6 +6,8 @@ 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;
9
11
  }
10
12
  export declare function ListPage<T extends ResourceModel>(props: ListPageProps<T>): JSX.Element;
11
13
  export {};
@@ -6,6 +6,7 @@ interface TableProps<Model extends ResourceModel> {
6
6
  tableProps: InternalTableProps<Model>;
7
7
  displayName: string;
8
8
  errorContentProps?: WidgetErrorContentProps;
9
+ isSearching?: boolean;
9
10
  }
10
11
  export declare function Table<Model extends ResourceModel>(props: TableProps<Model>): JSX.Element;
11
12
  export {};
@@ -1,12 +1,14 @@
1
1
  import { DeleteDialogProps } from '@cloudtower/eagle';
2
2
  type useDeleteDialogProps = {
3
3
  resourceName: string;
4
+ displayName?: string;
5
+ meta?: Record<string, string>;
4
6
  deleteDialogProps?: Partial<DeleteDialogProps>;
5
7
  };
6
8
  /**
7
9
  * 打开确认删除弹窗,如果失败会自动弹出回绝弹窗
8
10
  */
9
- export declare const useDeleteModal: ({ resourceName, deleteDialogProps, }: useDeleteDialogProps) => {
11
+ export declare const useDeleteModal: ({ resourceName, displayName, meta, deleteDialogProps, }: useDeleteDialogProps) => {
10
12
  openDeleteConfirmModal: (id: string) => void;
11
13
  closeDeleteConfirmModal: () => void;
12
14
  };
@@ -2,10 +2,12 @@ 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>;
5
7
  onError?: (resourceId: string, error?: HttpError) => void;
6
8
  deleteDialogProps?: Partial<DeleteDialogProps>;
7
9
  };
8
- export declare const useDeleteModalOnly: ({ resource: resourceFromProps, deleteDialogProps, onError, }: useDeleteModalOnlyProps) => {
10
+ export declare const useDeleteModalOnly: ({ resource: resourceFromProps, displayName: displayNameFromProps, deleteDialogProps, meta, onError, }: useDeleteModalOnlyProps) => {
9
11
  openDeleteConfirmModal: (id: string) => void;
10
12
  closeDeleteConfirmModal: () => void;
11
13
  };
@@ -1,4 +1,7 @@
1
- export declare const useFailedModal: (resource: string) => {
1
+ export declare const useFailedModal: (props: {
2
+ resource: string;
3
+ displayName?: string;
4
+ }) => {
2
5
  openFailedModal: (id: string, errorMsgs: string[]) => void;
3
6
  closeFailedModal: () => void;
4
7
  };
@@ -25,6 +25,7 @@ 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;
28
29
  tableQueryResult: import("@tanstack/query-core").QueryObserverResult<import("@refinedev/core").GetListResponse<Model>, import("@refinedev/core").HttpError>;
29
30
  sorter: import("@refinedev/core").CrudSorting;
30
31
  sorters: import("@refinedev/core").CrudSorting;
@@ -42,7 +43,6 @@ export declare const useEagleTable: <Model extends ResourceModel<import("k8s-api
42
43
  filters: import("@refinedev/core").CrudFilters;
43
44
  }) => string;
44
45
  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,18 +7433,21 @@ function transformResourceKindInSentence(str, language) {
7433
7433
  }
7434
7434
  const useDeleteModalOnly = ({
7435
7435
  resource: resourceFromProps,
7436
+ displayName: displayNameFromProps,
7436
7437
  deleteDialogProps,
7438
+ meta,
7437
7439
  onError
7438
7440
  }) => {
7439
7441
  const { resource } = core.useResource();
7440
7442
  const configs = React.useContext(ConfigsContext);
7441
7443
  const config = configs[resourceFromProps];
7442
7444
  const { mutateAsync } = core.useDelete();
7445
+ const [deleting, setDeleting] = React.useState(false);
7443
7446
  const pushModal = eagle.usePushModal();
7444
7447
  const popModal = eagle.usePopModal();
7445
7448
  const navigation = core.useNavigation();
7446
7449
  const { t: t2, i18n: i18n2 } = common.useTranslation();
7447
- const displayName = config.displayName || config.kind;
7450
+ const displayName = displayNameFromProps || (config == null ? void 0 : config.displayName) || (meta == null ? void 0 : meta.kind) || (config == null ? void 0 : config.kind);
7448
7451
  const resourceDisplayName = transformResourceKindInSentence(displayName, i18n2.language);
7449
7452
  function openDeleteConfirmModal(id) {
7450
7453
  pushModal({
@@ -7467,10 +7470,13 @@ const useDeleteModalOnly = ({
7467
7470
  ),
7468
7471
  secondaryDesc: t2("dovetail.delete_tip"),
7469
7472
  okText: t2("dovetail.delete"),
7473
+ confirmLoading: deleting,
7470
7474
  onOk: async (popModal2) => {
7471
7475
  try {
7476
+ setDeleting(true);
7472
7477
  await mutateAsync({
7473
7478
  resource: resourceFromProps,
7479
+ meta,
7474
7480
  id,
7475
7481
  successNotification() {
7476
7482
  return {
@@ -7494,6 +7500,7 @@ const useDeleteModalOnly = ({
7494
7500
  }
7495
7501
  popModal2();
7496
7502
  } finally {
7503
+ setDeleting(false);
7497
7504
  }
7498
7505
  },
7499
7506
  ...deleteDialogProps
@@ -7502,13 +7509,14 @@ const useDeleteModalOnly = ({
7502
7509
  }
7503
7510
  return { openDeleteConfirmModal, closeDeleteConfirmModal: popModal };
7504
7511
  };
7505
- const useFailedModal = (resource) => {
7512
+ const useFailedModal = (props) => {
7513
+ const { resource, displayName: displayNameFromProps } = props;
7506
7514
  const configs = React.useContext(ConfigsContext);
7507
7515
  const config = configs[resource];
7508
7516
  const { t: t2, i18n: i18n2 } = common.useTranslation();
7509
7517
  const pushModal = eagle.usePushModal();
7510
7518
  const popModal = eagle.usePopModal();
7511
- const displayName = config.displayName || config.kind;
7519
+ const displayName = displayNameFromProps || (config == null ? void 0 : config.displayName) || (config == null ? void 0 : config.kind);
7512
7520
  const resourceDisplayName = transformResourceKindInSentence(displayName, i18n2.language);
7513
7521
  function openFailedModal(id, errorMsgs) {
7514
7522
  pushModal({
@@ -7542,15 +7550,25 @@ const useFailedModal = (resource) => {
7542
7550
  };
7543
7551
  const useDeleteModal = ({
7544
7552
  resourceName,
7553
+ displayName,
7554
+ meta,
7545
7555
  deleteDialogProps
7546
7556
  }) => {
7547
7557
  const { i18n: i18n2 } = common.useTranslation();
7548
7558
  const configs = React.useContext(ConfigsContext);
7549
7559
  const config = configs[resourceName];
7550
- const { openFailedModal } = useFailedModal(resourceName);
7560
+ const { openFailedModal } = useFailedModal({
7561
+ resource: resourceName,
7562
+ displayName
7563
+ });
7551
7564
  const { openDeleteConfirmModal, closeDeleteConfirmModal } = useDeleteModalOnly({
7552
7565
  resource: resourceName,
7553
- deleteDialogProps: { secondaryDesc: config.deleteTip, ...deleteDialogProps },
7566
+ displayName,
7567
+ meta,
7568
+ deleteDialogProps: {
7569
+ secondaryDesc: (config == null ? void 0 : config.deleteTip) || i18n2.t("dovetail.delete_tip"),
7570
+ ...deleteDialogProps
7571
+ },
7554
7572
  onError: async (id, error) => {
7555
7573
  closeDeleteConfirmModal();
7556
7574
  openFailedModal(id, getCommonErrors(await (error == null ? void 0 : error.response.json()), i18n2));
@@ -10814,18 +10832,34 @@ function validateNodePort(nodePort, allNodePorts, i18n2) {
10814
10832
  return { isValid: true };
10815
10833
  }
10816
10834
  function K8sDropdown(props) {
10817
- var _a, _b;
10818
- const { record, size = "normal", customButton } = props;
10835
+ var _a, _b, _c;
10836
+ const {
10837
+ record,
10838
+ size = "normal",
10839
+ resourceName: resourceNameFromProps,
10840
+ customButton,
10841
+ deleteDialogProps,
10842
+ displayName,
10843
+ hideEdit
10844
+ } = props;
10819
10845
  const globalStore = useGlobalStore();
10820
10846
  const useResourceResult = core.useResource();
10821
10847
  const configs = React.useContext(ConfigsContext);
10822
- const resourceName = getResourceNameByKind(record.kind || "", configs);
10848
+ const resourceName = resourceNameFromProps || getResourceNameByKind(record.kind || "", configs);
10823
10849
  const config = configs[resourceName || ""];
10824
10850
  const { t: t2, i18n: i18n2 } = common.useTranslation();
10825
- const { openDeleteConfirmModal } = useDeleteModal({ resourceName: resourceName || "" });
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
10860
  const download2 = useDownloadYAML();
10827
10861
  const openForm = useOpenForm();
10828
- const isInShowPage = useResourceResult.action === "show" && ((_a = useResourceResult.resource) == null ? void 0 : _a.name) === config.name;
10862
+ const isInShowPage = useResourceResult.action === "show" && ((_b = useResourceResult.resource) == null ? void 0 : _b.name) === resourceName;
10829
10863
  const { data: canEditData } = core.useCan({
10830
10864
  resource: resourceName,
10831
10865
  action: AccessControlAuth.Edit,
@@ -10840,12 +10874,12 @@ function K8sDropdown(props) {
10840
10874
  namespace: record.namespace
10841
10875
  }
10842
10876
  });
10843
- const formType = ((_b = config.formConfig) == null ? void 0 : _b.formType) || FormType.FORM;
10877
+ const formType = (_c = config == null ? void 0 : config.formConfig) == null ? void 0 : _c.formType;
10844
10878
  return /* @__PURE__ */ common.jsxRuntimeExports.jsx(common.jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(
10845
10879
  eagle.Dropdown,
10846
10880
  {
10847
10881
  overlay: /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.Menu, { children: [
10848
- 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(
10882
+ isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false || hideEdit || (config == null ? void 0 : 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(
10849
10883
  (config == null ? void 0 : config.displayName) || record.kind || "",
10850
10884
  i18n2.language
10851
10885
  )}` : t2("dovetail.edit_yaml") }) }),
@@ -10910,12 +10944,7 @@ var ColumnKeys = /* @__PURE__ */ ((ColumnKeys2) => {
10910
10944
  function addDefaultRenderToColumns(columns) {
10911
10945
  return columns.map((col) => ({
10912
10946
  render(value2) {
10913
- return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
10914
- ValueDisplay,
10915
- {
10916
- value: value2
10917
- }
10918
- );
10947
+ return /* @__PURE__ */ common.jsxRuntimeExports.jsx(ValueDisplay, { value: value2 });
10919
10948
  },
10920
10949
  ...col
10921
10950
  }));
@@ -10951,18 +10980,23 @@ const useEagleTable = (params) => {
10951
10980
  },
10952
10981
  [setCurrentPage, table]
10953
10982
  );
10954
- const onSorterChange = React.useCallback((order, key2) => {
10955
- var _a2;
10956
- const ORDER_MAP = {
10957
- descend: "desc",
10958
- ascend: "asc"
10959
- };
10960
- const sorters = [{
10961
- field: (_a2 = columns.find((col) => col.key === key2)) == null ? void 0 : _a2.dataIndex,
10962
- order: order ? ORDER_MAP[order] : order
10963
- }];
10964
- table.setSorters(sorters);
10965
- }, [table, columns]);
10983
+ const onSorterChange = React.useCallback(
10984
+ (order, key2) => {
10985
+ var _a2;
10986
+ const ORDER_MAP = {
10987
+ descend: "desc",
10988
+ ascend: "asc"
10989
+ };
10990
+ const sorters = [
10991
+ {
10992
+ field: (_a2 = columns.find((col) => col.key === key2)) == null ? void 0 : _a2.dataIndex,
10993
+ order: order ? ORDER_MAP[order] : order
10994
+ }
10995
+ ];
10996
+ table.setSorters(sorters);
10997
+ },
10998
+ [table, columns]
10999
+ );
10966
11000
  const data2 = (_a = table.tableQueryResult.data) == null ? void 0 : _a.data;
10967
11001
  const total = ((_b = table.tableQueryResult.data) == null ? void 0 : _b.total) || 0;
10968
11002
  const finalDataSource = formatter ? data2 == null ? void 0 : data2.map(formatter) : data2;
@@ -10985,12 +11019,23 @@ const useEagleTable = (params) => {
10985
11019
  defaultSize: currentSize
10986
11020
  };
10987
11021
  React.useEffect(() => {
10988
- table.setSorters([{
10989
- field: "metadata.creationTimestamp",
10990
- order: "desc"
10991
- }]);
11022
+ table.setSorters([
11023
+ {
11024
+ field: "metadata.creationTimestamp",
11025
+ order: "desc"
11026
+ }
11027
+ ]);
10992
11028
  }, []);
10993
- return { tableProps: finalProps, selectedKeys, ...table };
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
11039
  };
10995
11040
  function CreateButton(props) {
10996
11041
  var _a;
@@ -12165,7 +12210,7 @@ function PVVolumeModeDisplay(props) {
12165
12210
  }
12166
12211
  function Table(props) {
12167
12212
  var _a;
12168
- const { tableProps, displayName, errorContentProps } = props;
12213
+ const { tableProps, displayName, errorContentProps, isSearching } = props;
12169
12214
  const { Table: TableComponent } = React.useContext(ComponentContext);
12170
12215
  const Table2 = TableComponent || Table$1;
12171
12216
  const { params } = core.useParsed();
@@ -12173,7 +12218,7 @@ function Table(props) {
12173
12218
  const resourceType = transformResourceKindInSentence(displayName, i18n2.language);
12174
12219
  if (!((_a = tableProps.data) == null ? void 0 : _a.length) && !tableProps.loading) {
12175
12220
  const nameKeyword = (params == null ? void 0 : params[NAME_KEYWORD_PARAM]) || "";
12176
- if (nameKeyword) {
12221
+ if (nameKeyword || isSearching) {
12177
12222
  const onClear = () => {
12178
12223
  var _a2;
12179
12224
  (_a2 = tableProps.onClearSearchKeyword) == null ? void 0 : _a2.call(tableProps);
@@ -14547,7 +14592,9 @@ function ListPage(props) {
14547
14592
  selectedKeys,
14548
14593
  tableProps,
14549
14594
  contentClassName,
14550
- belowToolBarContent
14595
+ belowToolBarContent,
14596
+ customNamespaceFilter,
14597
+ isSearching
14551
14598
  } = props;
14552
14599
  const {
14553
14600
  resource
@@ -14575,7 +14622,7 @@ function ListPage(props) {
14575
14622
  style: config.hideNamespacesFilter ? {
14576
14623
  paddingTop: 0
14577
14624
  } : {},
14578
- children: [!config.hideNamespacesFilter ? config.customNamespaceFilter || /* @__PURE__ */ common.jsxRuntimeExports.jsx(NamespacesFilter, {
14625
+ children: [!config.hideNamespacesFilter ? customNamespaceFilter || config.customNamespaceFilter || /* @__PURE__ */ common.jsxRuntimeExports.jsx(NamespacesFilter, {
14579
14626
  className: NamespaceFilterStyle
14580
14627
  }) : void 0, /* @__PURE__ */ common.jsxRuntimeExports.jsx("div", {
14581
14628
  className: TableStyle,
@@ -14586,7 +14633,8 @@ function ListPage(props) {
14586
14633
  y: "calc(100% - 48px)"
14587
14634
  }
14588
14635
  },
14589
- displayName: (config == null ? void 0 : config.displayName) || config.kind
14636
+ displayName: (config == null ? void 0 : config.displayName) || config.kind,
14637
+ isSearching
14590
14638
  })
14591
14639
  })]
14592
14640
  })]
package/dist/refine.js CHANGED
@@ -7414,18 +7414,21 @@ function transformResourceKindInSentence(str, language) {
7414
7414
  }
7415
7415
  const useDeleteModalOnly = ({
7416
7416
  resource: resourceFromProps,
7417
+ displayName: displayNameFromProps,
7417
7418
  deleteDialogProps,
7419
+ meta,
7418
7420
  onError
7419
7421
  }) => {
7420
7422
  const { resource } = useResource();
7421
7423
  const configs = useContext(ConfigsContext);
7422
7424
  const config = configs[resourceFromProps];
7423
7425
  const { mutateAsync } = useDelete();
7426
+ const [deleting, setDeleting] = useState(false);
7424
7427
  const pushModal = usePushModal();
7425
7428
  const popModal = usePopModal();
7426
7429
  const navigation = useNavigation();
7427
7430
  const { t: t2, i18n: i18n2 } = useTranslation();
7428
- const displayName = config.displayName || config.kind;
7431
+ const displayName = displayNameFromProps || (config == null ? void 0 : config.displayName) || (meta == null ? void 0 : meta.kind) || (config == null ? void 0 : config.kind);
7429
7432
  const resourceDisplayName = transformResourceKindInSentence(displayName, i18n2.language);
7430
7433
  function openDeleteConfirmModal(id) {
7431
7434
  pushModal({
@@ -7448,10 +7451,13 @@ const useDeleteModalOnly = ({
7448
7451
  ),
7449
7452
  secondaryDesc: t2("dovetail.delete_tip"),
7450
7453
  okText: t2("dovetail.delete"),
7454
+ confirmLoading: deleting,
7451
7455
  onOk: async (popModal2) => {
7452
7456
  try {
7457
+ setDeleting(true);
7453
7458
  await mutateAsync({
7454
7459
  resource: resourceFromProps,
7460
+ meta,
7455
7461
  id,
7456
7462
  successNotification() {
7457
7463
  return {
@@ -7475,6 +7481,7 @@ const useDeleteModalOnly = ({
7475
7481
  }
7476
7482
  popModal2();
7477
7483
  } finally {
7484
+ setDeleting(false);
7478
7485
  }
7479
7486
  },
7480
7487
  ...deleteDialogProps
@@ -7483,13 +7490,14 @@ const useDeleteModalOnly = ({
7483
7490
  }
7484
7491
  return { openDeleteConfirmModal, closeDeleteConfirmModal: popModal };
7485
7492
  };
7486
- const useFailedModal = (resource) => {
7493
+ const useFailedModal = (props) => {
7494
+ const { resource, displayName: displayNameFromProps } = props;
7487
7495
  const configs = useContext(ConfigsContext);
7488
7496
  const config = configs[resource];
7489
7497
  const { t: t2, i18n: i18n2 } = useTranslation();
7490
7498
  const pushModal = usePushModal();
7491
7499
  const popModal = usePopModal();
7492
- const displayName = config.displayName || config.kind;
7500
+ const displayName = displayNameFromProps || (config == null ? void 0 : config.displayName) || (config == null ? void 0 : config.kind);
7493
7501
  const resourceDisplayName = transformResourceKindInSentence(displayName, i18n2.language);
7494
7502
  function openFailedModal(id, errorMsgs) {
7495
7503
  pushModal({
@@ -7523,15 +7531,25 @@ const useFailedModal = (resource) => {
7523
7531
  };
7524
7532
  const useDeleteModal = ({
7525
7533
  resourceName,
7534
+ displayName,
7535
+ meta,
7526
7536
  deleteDialogProps
7527
7537
  }) => {
7528
7538
  const { i18n: i18n2 } = useTranslation();
7529
7539
  const configs = useContext(ConfigsContext);
7530
7540
  const config = configs[resourceName];
7531
- const { openFailedModal } = useFailedModal(resourceName);
7541
+ const { openFailedModal } = useFailedModal({
7542
+ resource: resourceName,
7543
+ displayName
7544
+ });
7532
7545
  const { openDeleteConfirmModal, closeDeleteConfirmModal } = useDeleteModalOnly({
7533
7546
  resource: resourceName,
7534
- deleteDialogProps: { secondaryDesc: config.deleteTip, ...deleteDialogProps },
7547
+ displayName,
7548
+ meta,
7549
+ deleteDialogProps: {
7550
+ secondaryDesc: (config == null ? void 0 : config.deleteTip) || i18n2.t("dovetail.delete_tip"),
7551
+ ...deleteDialogProps
7552
+ },
7535
7553
  onError: async (id, error) => {
7536
7554
  closeDeleteConfirmModal();
7537
7555
  openFailedModal(id, getCommonErrors(await (error == null ? void 0 : error.response.json()), i18n2));
@@ -10795,18 +10813,34 @@ function validateNodePort(nodePort, allNodePorts, i18n2) {
10795
10813
  return { isValid: true };
10796
10814
  }
10797
10815
  function K8sDropdown(props) {
10798
- var _a, _b;
10799
- const { record, size = "normal", customButton } = props;
10816
+ var _a, _b, _c;
10817
+ const {
10818
+ record,
10819
+ size = "normal",
10820
+ resourceName: resourceNameFromProps,
10821
+ customButton,
10822
+ deleteDialogProps,
10823
+ displayName,
10824
+ hideEdit
10825
+ } = props;
10800
10826
  const globalStore = useGlobalStore();
10801
10827
  const useResourceResult = useResource();
10802
10828
  const configs = useContext(ConfigsContext);
10803
- const resourceName = getResourceNameByKind(record.kind || "", configs);
10829
+ const resourceName = resourceNameFromProps || getResourceNameByKind(record.kind || "", configs);
10804
10830
  const config = configs[resourceName || ""];
10805
10831
  const { t: t2, i18n: i18n2 } = useTranslation();
10806
- const { openDeleteConfirmModal } = useDeleteModal({ resourceName: resourceName || "" });
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
10841
  const download2 = useDownloadYAML();
10808
10842
  const openForm = useOpenForm();
10809
- const isInShowPage = useResourceResult.action === "show" && ((_a = useResourceResult.resource) == null ? void 0 : _a.name) === config.name;
10843
+ const isInShowPage = useResourceResult.action === "show" && ((_b = useResourceResult.resource) == null ? void 0 : _b.name) === resourceName;
10810
10844
  const { data: canEditData } = useCan({
10811
10845
  resource: resourceName,
10812
10846
  action: AccessControlAuth.Edit,
@@ -10821,12 +10855,12 @@ function K8sDropdown(props) {
10821
10855
  namespace: record.namespace
10822
10856
  }
10823
10857
  });
10824
- const formType = ((_b = config.formConfig) == null ? void 0 : _b.formType) || FormType.FORM;
10858
+ const formType = (_c = config == null ? void 0 : config.formConfig) == null ? void 0 : _c.formType;
10825
10859
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
10826
10860
  Dropdown,
10827
10861
  {
10828
10862
  overlay: /* @__PURE__ */ jsxRuntimeExports.jsxs(Menu$1, { children: [
10829
- 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(
10863
+ isInShowPage || (canEditData == null ? void 0 : canEditData.can) === false || hideEdit || (config == null ? void 0 : 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(
10830
10864
  (config == null ? void 0 : config.displayName) || record.kind || "",
10831
10865
  i18n2.language
10832
10866
  )}` : t2("dovetail.edit_yaml") }) }),
@@ -10891,12 +10925,7 @@ var ColumnKeys = /* @__PURE__ */ ((ColumnKeys2) => {
10891
10925
  function addDefaultRenderToColumns(columns) {
10892
10926
  return columns.map((col) => ({
10893
10927
  render(value2) {
10894
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
10895
- ValueDisplay,
10896
- {
10897
- value: value2
10898
- }
10899
- );
10928
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(ValueDisplay, { value: value2 });
10900
10929
  },
10901
10930
  ...col
10902
10931
  }));
@@ -10932,18 +10961,23 @@ const useEagleTable = (params) => {
10932
10961
  },
10933
10962
  [setCurrentPage, table]
10934
10963
  );
10935
- const onSorterChange = useCallback((order, key2) => {
10936
- var _a2;
10937
- const ORDER_MAP = {
10938
- descend: "desc",
10939
- ascend: "asc"
10940
- };
10941
- const sorters = [{
10942
- field: (_a2 = columns.find((col) => col.key === key2)) == null ? void 0 : _a2.dataIndex,
10943
- order: order ? ORDER_MAP[order] : order
10944
- }];
10945
- table.setSorters(sorters);
10946
- }, [table, columns]);
10964
+ const onSorterChange = useCallback(
10965
+ (order, key2) => {
10966
+ var _a2;
10967
+ const ORDER_MAP = {
10968
+ descend: "desc",
10969
+ ascend: "asc"
10970
+ };
10971
+ const sorters = [
10972
+ {
10973
+ field: (_a2 = columns.find((col) => col.key === key2)) == null ? void 0 : _a2.dataIndex,
10974
+ order: order ? ORDER_MAP[order] : order
10975
+ }
10976
+ ];
10977
+ table.setSorters(sorters);
10978
+ },
10979
+ [table, columns]
10980
+ );
10947
10981
  const data2 = (_a = table.tableQueryResult.data) == null ? void 0 : _a.data;
10948
10982
  const total = ((_b = table.tableQueryResult.data) == null ? void 0 : _b.total) || 0;
10949
10983
  const finalDataSource = formatter ? data2 == null ? void 0 : data2.map(formatter) : data2;
@@ -10966,12 +11000,23 @@ const useEagleTable = (params) => {
10966
11000
  defaultSize: currentSize
10967
11001
  };
10968
11002
  useEffect(() => {
10969
- table.setSorters([{
10970
- field: "metadata.creationTimestamp",
10971
- order: "desc"
10972
- }]);
11003
+ table.setSorters([
11004
+ {
11005
+ field: "metadata.creationTimestamp",
11006
+ order: "desc"
11007
+ }
11008
+ ]);
10973
11009
  }, []);
10974
- return { tableProps: finalProps, selectedKeys, ...table };
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
11020
  };
10976
11021
  function CreateButton(props) {
10977
11022
  var _a;
@@ -12146,7 +12191,7 @@ function PVVolumeModeDisplay(props) {
12146
12191
  }
12147
12192
  function Table(props) {
12148
12193
  var _a;
12149
- const { tableProps, displayName, errorContentProps } = props;
12194
+ const { tableProps, displayName, errorContentProps, isSearching } = props;
12150
12195
  const { Table: TableComponent } = useContext(ComponentContext);
12151
12196
  const Table2 = TableComponent || Table$1;
12152
12197
  const { params } = useParsed();
@@ -12154,7 +12199,7 @@ function Table(props) {
12154
12199
  const resourceType = transformResourceKindInSentence(displayName, i18n2.language);
12155
12200
  if (!((_a = tableProps.data) == null ? void 0 : _a.length) && !tableProps.loading) {
12156
12201
  const nameKeyword = (params == null ? void 0 : params[NAME_KEYWORD_PARAM]) || "";
12157
- if (nameKeyword) {
12202
+ if (nameKeyword || isSearching) {
12158
12203
  const onClear = () => {
12159
12204
  var _a2;
12160
12205
  (_a2 = tableProps.onClearSearchKeyword) == null ? void 0 : _a2.call(tableProps);
@@ -14528,7 +14573,9 @@ function ListPage(props) {
14528
14573
  selectedKeys,
14529
14574
  tableProps,
14530
14575
  contentClassName,
14531
- belowToolBarContent
14576
+ belowToolBarContent,
14577
+ customNamespaceFilter,
14578
+ isSearching
14532
14579
  } = props;
14533
14580
  const {
14534
14581
  resource
@@ -14556,7 +14603,7 @@ function ListPage(props) {
14556
14603
  style: config.hideNamespacesFilter ? {
14557
14604
  paddingTop: 0
14558
14605
  } : {},
14559
- children: [!config.hideNamespacesFilter ? config.customNamespaceFilter || /* @__PURE__ */ jsxRuntimeExports.jsx(NamespacesFilter, {
14606
+ children: [!config.hideNamespacesFilter ? customNamespaceFilter || config.customNamespaceFilter || /* @__PURE__ */ jsxRuntimeExports.jsx(NamespacesFilter, {
14560
14607
  className: NamespaceFilterStyle
14561
14608
  }) : void 0, /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
14562
14609
  className: TableStyle,
@@ -14567,7 +14614,8 @@ function ListPage(props) {
14567
14614
  y: "calc(100% - 48px)"
14568
14615
  }
14569
14616
  },
14570
- displayName: (config == null ? void 0 : config.displayName) || config.kind
14617
+ displayName: (config == null ? void 0 : config.displayName) || config.kind,
14618
+ isSearching
14571
14619
  })
14572
14620
  })]
14573
14621
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dovetail-v2/refine",
3
- "version": "0.3.17",
3
+ "version": "0.3.18-alpha.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",