@dovetail-v2/refine 0.3.18 → 0.3.19-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
+ customFilterBar?: 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));
@@ -10815,18 +10833,34 @@ function validateNodePort(nodePort, allNodePorts, i18n2) {
10815
10833
  return { isValid: true };
10816
10834
  }
10817
10835
  function K8sDropdown(props) {
10818
- var _a, _b;
10819
- const { record, size = "normal", customButton } = props;
10836
+ var _a, _b, _c;
10837
+ const {
10838
+ record,
10839
+ size = "normal",
10840
+ resourceName: resourceNameFromProps,
10841
+ customButton,
10842
+ deleteDialogProps,
10843
+ displayName,
10844
+ hideEdit
10845
+ } = props;
10820
10846
  const globalStore = useGlobalStore();
10821
10847
  const useResourceResult = core.useResource();
10822
10848
  const configs = React.useContext(ConfigsContext);
10823
- const resourceName = getResourceNameByKind(record.kind || "", configs);
10849
+ const resourceName = resourceNameFromProps || getResourceNameByKind(record.kind || "", configs);
10824
10850
  const config = configs[resourceName || ""];
10825
10851
  const { t: t2, i18n: i18n2 } = common.useTranslation();
10826
- const { openDeleteConfirmModal } = useDeleteModal({ resourceName: resourceName || "" });
10852
+ const { openDeleteConfirmModal } = useDeleteModal({
10853
+ resourceName: resourceName || "",
10854
+ deleteDialogProps,
10855
+ displayName,
10856
+ meta: record.apiVersion ? {
10857
+ kind: record.kind || "",
10858
+ resourceBasePath: (((_a = record.apiVersion) == null ? void 0 : _a.includes("/")) ? "apis" : "api") + `/${record.apiVersion}`
10859
+ } : void 0
10860
+ });
10827
10861
  const download2 = useDownloadYAML();
10828
10862
  const openForm = useOpenForm();
10829
- const isInShowPage = useResourceResult.action === "show" && ((_a = useResourceResult.resource) == null ? void 0 : _a.name) === config.name;
10863
+ const isInShowPage = useResourceResult.action === "show" && ((_b = useResourceResult.resource) == null ? void 0 : _b.name) === resourceName;
10830
10864
  const { data: canEditData } = core.useCan({
10831
10865
  resource: resourceName,
10832
10866
  action: AccessControlAuth.Edit,
@@ -10841,12 +10875,12 @@ function K8sDropdown(props) {
10841
10875
  namespace: record.namespace
10842
10876
  }
10843
10877
  });
10844
- const formType = ((_b = config.formConfig) == null ? void 0 : _b.formType) || FormType.FORM;
10878
+ const formType = (_c = config == null ? void 0 : config.formConfig) == null ? void 0 : _c.formType;
10845
10879
  return /* @__PURE__ */ common.jsxRuntimeExports.jsx(common.jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ common.jsxRuntimeExports.jsx(
10846
10880
  eagle.Dropdown,
10847
10881
  {
10848
10882
  overlay: /* @__PURE__ */ common.jsxRuntimeExports.jsxs(eagle.Menu, { children: [
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
+ 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(
10850
10884
  (config == null ? void 0 : config.displayName) || record.kind || "",
10851
10885
  i18n2.language
10852
10886
  )}` : t2("dovetail.edit_yaml") }) }),
@@ -10911,12 +10945,7 @@ var ColumnKeys = /* @__PURE__ */ ((ColumnKeys2) => {
10911
10945
  function addDefaultRenderToColumns(columns) {
10912
10946
  return columns.map((col) => ({
10913
10947
  render(value2) {
10914
- return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
10915
- ValueDisplay,
10916
- {
10917
- value: value2
10918
- }
10919
- );
10948
+ return /* @__PURE__ */ common.jsxRuntimeExports.jsx(ValueDisplay, { value: value2 });
10920
10949
  },
10921
10950
  ...col
10922
10951
  }));
@@ -10952,18 +10981,23 @@ const useEagleTable = (params) => {
10952
10981
  },
10953
10982
  [setCurrentPage, table]
10954
10983
  );
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]);
10984
+ const onSorterChange = React.useCallback(
10985
+ (order, key2) => {
10986
+ var _a2;
10987
+ const ORDER_MAP = {
10988
+ descend: "desc",
10989
+ ascend: "asc"
10990
+ };
10991
+ const sorters = [
10992
+ {
10993
+ field: (_a2 = columns.find((col) => col.key === key2)) == null ? void 0 : _a2.dataIndex,
10994
+ order: order ? ORDER_MAP[order] : order
10995
+ }
10996
+ ];
10997
+ table.setSorters(sorters);
10998
+ },
10999
+ [table, columns]
11000
+ );
10967
11001
  const data2 = (_a = table.tableQueryResult.data) == null ? void 0 : _a.data;
10968
11002
  const total = ((_b = table.tableQueryResult.data) == null ? void 0 : _b.total) || 0;
10969
11003
  const finalDataSource = formatter ? data2 == null ? void 0 : data2.map(formatter) : data2;
@@ -10986,12 +11020,23 @@ const useEagleTable = (params) => {
10986
11020
  defaultSize: currentSize
10987
11021
  };
10988
11022
  React.useEffect(() => {
10989
- table.setSorters([{
10990
- field: "metadata.creationTimestamp",
10991
- order: "desc"
10992
- }]);
11023
+ table.setSorters([
11024
+ {
11025
+ field: "metadata.creationTimestamp",
11026
+ order: "desc"
11027
+ }
11028
+ ]);
10993
11029
  }, []);
10994
- return { tableProps: finalProps, selectedKeys, ...table };
11030
+ return {
11031
+ tableProps: finalProps,
11032
+ selectedKeys,
11033
+ ...table,
11034
+ setCurrent: (current) => {
11035
+ var _a2;
11036
+ setCurrentPage(current);
11037
+ (_a2 = table.setCurrent) == null ? void 0 : _a2.call(table, current);
11038
+ }
11039
+ };
10995
11040
  };
10996
11041
  function CreateButton(props) {
10997
11042
  var _a;
@@ -12166,7 +12211,7 @@ function PVVolumeModeDisplay(props) {
12166
12211
  }
12167
12212
  function Table(props) {
12168
12213
  var _a;
12169
- const { tableProps, displayName, errorContentProps } = props;
12214
+ const { tableProps, displayName, errorContentProps, isSearching } = props;
12170
12215
  const { Table: TableComponent } = React.useContext(ComponentContext);
12171
12216
  const Table2 = TableComponent || Table$1;
12172
12217
  const { params } = core.useParsed();
@@ -12174,7 +12219,7 @@ function Table(props) {
12174
12219
  const resourceType = transformResourceKindInSentence(displayName, i18n2.language);
12175
12220
  if (!((_a = tableProps.data) == null ? void 0 : _a.length) && !tableProps.loading) {
12176
12221
  const nameKeyword = (params == null ? void 0 : params[NAME_KEYWORD_PARAM]) || "";
12177
- if (nameKeyword) {
12222
+ if (nameKeyword || isSearching) {
12178
12223
  const onClear = () => {
12179
12224
  var _a2;
12180
12225
  (_a2 = tableProps.onClearSearchKeyword) == null ? void 0 : _a2.call(tableProps);
@@ -14548,7 +14593,9 @@ function ListPage(props) {
14548
14593
  selectedKeys,
14549
14594
  tableProps,
14550
14595
  contentClassName,
14551
- belowToolBarContent
14596
+ belowToolBarContent,
14597
+ customFilterBar,
14598
+ isSearching
14552
14599
  } = props;
14553
14600
  const {
14554
14601
  resource
@@ -14576,7 +14623,7 @@ function ListPage(props) {
14576
14623
  style: !config.customFilterBar && config.nonNsResource ? {
14577
14624
  paddingTop: 0
14578
14625
  } : {},
14579
- children: [config.customFilterBar || !config.nonNsResource && /* @__PURE__ */ common.jsxRuntimeExports.jsx(NamespacesFilter, {
14626
+ children: [customFilterBar || config.customFilterBar || !config.nonNsResource && /* @__PURE__ */ common.jsxRuntimeExports.jsx(NamespacesFilter, {
14580
14627
  className: NamespaceFilterStyle
14581
14628
  }), /* @__PURE__ */ common.jsxRuntimeExports.jsx("div", {
14582
14629
  className: TableStyle,
@@ -14587,7 +14634,8 @@ function ListPage(props) {
14587
14634
  y: "calc(100% - 48px)"
14588
14635
  }
14589
14636
  },
14590
- displayName: (config == null ? void 0 : config.displayName) || config.kind
14637
+ displayName: (config == null ? void 0 : config.displayName) || config.kind,
14638
+ isSearching
14591
14639
  })
14592
14640
  })]
14593
14641
  })]
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));
@@ -10796,18 +10814,34 @@ function validateNodePort(nodePort, allNodePorts, i18n2) {
10796
10814
  return { isValid: true };
10797
10815
  }
10798
10816
  function K8sDropdown(props) {
10799
- var _a, _b;
10800
- const { record, size = "normal", customButton } = props;
10817
+ var _a, _b, _c;
10818
+ const {
10819
+ record,
10820
+ size = "normal",
10821
+ resourceName: resourceNameFromProps,
10822
+ customButton,
10823
+ deleteDialogProps,
10824
+ displayName,
10825
+ hideEdit
10826
+ } = props;
10801
10827
  const globalStore = useGlobalStore();
10802
10828
  const useResourceResult = useResource();
10803
10829
  const configs = useContext(ConfigsContext);
10804
- const resourceName = getResourceNameByKind(record.kind || "", configs);
10830
+ const resourceName = resourceNameFromProps || getResourceNameByKind(record.kind || "", configs);
10805
10831
  const config = configs[resourceName || ""];
10806
10832
  const { t: t2, i18n: i18n2 } = useTranslation();
10807
- const { openDeleteConfirmModal } = useDeleteModal({ resourceName: resourceName || "" });
10833
+ const { openDeleteConfirmModal } = useDeleteModal({
10834
+ resourceName: resourceName || "",
10835
+ deleteDialogProps,
10836
+ displayName,
10837
+ meta: record.apiVersion ? {
10838
+ kind: record.kind || "",
10839
+ resourceBasePath: (((_a = record.apiVersion) == null ? void 0 : _a.includes("/")) ? "apis" : "api") + `/${record.apiVersion}`
10840
+ } : void 0
10841
+ });
10808
10842
  const download2 = useDownloadYAML();
10809
10843
  const openForm = useOpenForm();
10810
- const isInShowPage = useResourceResult.action === "show" && ((_a = useResourceResult.resource) == null ? void 0 : _a.name) === config.name;
10844
+ const isInShowPage = useResourceResult.action === "show" && ((_b = useResourceResult.resource) == null ? void 0 : _b.name) === resourceName;
10811
10845
  const { data: canEditData } = useCan({
10812
10846
  resource: resourceName,
10813
10847
  action: AccessControlAuth.Edit,
@@ -10822,12 +10856,12 @@ function K8sDropdown(props) {
10822
10856
  namespace: record.namespace
10823
10857
  }
10824
10858
  });
10825
- const formType = ((_b = config.formConfig) == null ? void 0 : _b.formType) || FormType.FORM;
10859
+ const formType = (_c = config == null ? void 0 : config.formConfig) == null ? void 0 : _c.formType;
10826
10860
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
10827
10861
  Dropdown,
10828
10862
  {
10829
10863
  overlay: /* @__PURE__ */ jsxRuntimeExports.jsxs(Menu$1, { children: [
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
+ 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(
10831
10865
  (config == null ? void 0 : config.displayName) || record.kind || "",
10832
10866
  i18n2.language
10833
10867
  )}` : t2("dovetail.edit_yaml") }) }),
@@ -10892,12 +10926,7 @@ var ColumnKeys = /* @__PURE__ */ ((ColumnKeys2) => {
10892
10926
  function addDefaultRenderToColumns(columns) {
10893
10927
  return columns.map((col) => ({
10894
10928
  render(value2) {
10895
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
10896
- ValueDisplay,
10897
- {
10898
- value: value2
10899
- }
10900
- );
10929
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(ValueDisplay, { value: value2 });
10901
10930
  },
10902
10931
  ...col
10903
10932
  }));
@@ -10933,18 +10962,23 @@ const useEagleTable = (params) => {
10933
10962
  },
10934
10963
  [setCurrentPage, table]
10935
10964
  );
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]);
10965
+ const onSorterChange = useCallback(
10966
+ (order, key2) => {
10967
+ var _a2;
10968
+ const ORDER_MAP = {
10969
+ descend: "desc",
10970
+ ascend: "asc"
10971
+ };
10972
+ const sorters = [
10973
+ {
10974
+ field: (_a2 = columns.find((col) => col.key === key2)) == null ? void 0 : _a2.dataIndex,
10975
+ order: order ? ORDER_MAP[order] : order
10976
+ }
10977
+ ];
10978
+ table.setSorters(sorters);
10979
+ },
10980
+ [table, columns]
10981
+ );
10948
10982
  const data2 = (_a = table.tableQueryResult.data) == null ? void 0 : _a.data;
10949
10983
  const total = ((_b = table.tableQueryResult.data) == null ? void 0 : _b.total) || 0;
10950
10984
  const finalDataSource = formatter ? data2 == null ? void 0 : data2.map(formatter) : data2;
@@ -10967,12 +11001,23 @@ const useEagleTable = (params) => {
10967
11001
  defaultSize: currentSize
10968
11002
  };
10969
11003
  useEffect(() => {
10970
- table.setSorters([{
10971
- field: "metadata.creationTimestamp",
10972
- order: "desc"
10973
- }]);
11004
+ table.setSorters([
11005
+ {
11006
+ field: "metadata.creationTimestamp",
11007
+ order: "desc"
11008
+ }
11009
+ ]);
10974
11010
  }, []);
10975
- return { tableProps: finalProps, selectedKeys, ...table };
11011
+ return {
11012
+ tableProps: finalProps,
11013
+ selectedKeys,
11014
+ ...table,
11015
+ setCurrent: (current) => {
11016
+ var _a2;
11017
+ setCurrentPage(current);
11018
+ (_a2 = table.setCurrent) == null ? void 0 : _a2.call(table, current);
11019
+ }
11020
+ };
10976
11021
  };
10977
11022
  function CreateButton(props) {
10978
11023
  var _a;
@@ -12147,7 +12192,7 @@ function PVVolumeModeDisplay(props) {
12147
12192
  }
12148
12193
  function Table(props) {
12149
12194
  var _a;
12150
- const { tableProps, displayName, errorContentProps } = props;
12195
+ const { tableProps, displayName, errorContentProps, isSearching } = props;
12151
12196
  const { Table: TableComponent } = useContext(ComponentContext);
12152
12197
  const Table2 = TableComponent || Table$1;
12153
12198
  const { params } = useParsed();
@@ -12155,7 +12200,7 @@ function Table(props) {
12155
12200
  const resourceType = transformResourceKindInSentence(displayName, i18n2.language);
12156
12201
  if (!((_a = tableProps.data) == null ? void 0 : _a.length) && !tableProps.loading) {
12157
12202
  const nameKeyword = (params == null ? void 0 : params[NAME_KEYWORD_PARAM]) || "";
12158
- if (nameKeyword) {
12203
+ if (nameKeyword || isSearching) {
12159
12204
  const onClear = () => {
12160
12205
  var _a2;
12161
12206
  (_a2 = tableProps.onClearSearchKeyword) == null ? void 0 : _a2.call(tableProps);
@@ -14529,7 +14574,9 @@ function ListPage(props) {
14529
14574
  selectedKeys,
14530
14575
  tableProps,
14531
14576
  contentClassName,
14532
- belowToolBarContent
14577
+ belowToolBarContent,
14578
+ customFilterBar,
14579
+ isSearching
14533
14580
  } = props;
14534
14581
  const {
14535
14582
  resource
@@ -14557,7 +14604,7 @@ function ListPage(props) {
14557
14604
  style: !config.customFilterBar && config.nonNsResource ? {
14558
14605
  paddingTop: 0
14559
14606
  } : {},
14560
- children: [config.customFilterBar || !config.nonNsResource && /* @__PURE__ */ jsxRuntimeExports.jsx(NamespacesFilter, {
14607
+ children: [customFilterBar || config.customFilterBar || !config.nonNsResource && /* @__PURE__ */ jsxRuntimeExports.jsx(NamespacesFilter, {
14561
14608
  className: NamespaceFilterStyle
14562
14609
  }), /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
14563
14610
  className: TableStyle,
@@ -14568,7 +14615,8 @@ function ListPage(props) {
14568
14615
  y: "calc(100% - 48px)"
14569
14616
  }
14570
14617
  },
14571
- displayName: (config == null ? void 0 : config.displayName) || config.kind
14618
+ displayName: (config == null ? void 0 : config.displayName) || config.kind,
14619
+ isSearching
14572
14620
  })
14573
14621
  })]
14574
14622
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dovetail-v2/refine",
3
- "version": "0.3.18",
3
+ "version": "0.3.19-alpha.1",
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.28",
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",