From af1c9cb19d39f30227895512716fe0a98c78a403 Mon Sep 17 00:00:00 2001 From: Kavin Venkatachalam Date: Fri, 4 Apr 2025 13:35:34 +0530 Subject: [PATCH] fix: Download button issue on server side pagination --- .../_components/Footer/_components/ControlButtons.jsx | 6 ++++-- .../Widgets/NewTable/_stores/slices/initSlice.js | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/AppBuilder/Widgets/NewTable/_components/Footer/_components/ControlButtons.jsx b/frontend/src/AppBuilder/Widgets/NewTable/_components/Footer/_components/ControlButtons.jsx index 500d3ee991..d91b84da40 100644 --- a/frontend/src/AppBuilder/Widgets/NewTable/_components/Footer/_components/ControlButtons.jsx +++ b/frontend/src/AppBuilder/Widgets/NewTable/_components/Footer/_components/ControlButtons.jsx @@ -17,6 +17,7 @@ export const ControlButtons = memo( shallow ); const clientSidePagination = useTableStore((state) => state.getTableProperties(id)?.clientSidePagination, shallow); + const hasDownloadEvent = useTableStore((state) => state.getHasDownloadEvent(id), shallow); const renderButton = (icon, onClick, tooltipId, tooltipContent) => { return ( @@ -142,7 +143,8 @@ export const ControlButtons = memo( ); const renderDownloadButton = () => { - if (!clientSidePagination) { + // if server side pagination is enabled and download event is associated with the table, then directly fire download event without displaying popover + if (hasDownloadEvent && !clientSidePagination) { const onClick = () => { fireEvent('onTableDataDownload'); }; @@ -173,7 +175,7 @@ export const ControlButtons = memo( > )} - {renderDownloadButton()} + {showDownloadButton && renderDownloadButton()} {!hideColumnSelectorButton && renderOverlay(id, 'eye1', hideColumnsPopover, 'tooltip-for-manage-columns', 'Manage columns')} diff --git a/frontend/src/AppBuilder/Widgets/NewTable/_stores/slices/initSlice.js b/frontend/src/AppBuilder/Widgets/NewTable/_stores/slices/initSlice.js index d4c2a8c234..f6b8b8cb09 100644 --- a/frontend/src/AppBuilder/Widgets/NewTable/_stores/slices/initSlice.js +++ b/frontend/src/AppBuilder/Widgets/NewTable/_stores/slices/initSlice.js @@ -19,6 +19,7 @@ export const createInitSlice = (set, get) => ({ }, events: { hasHoveredEvent: false, + hasDownloadEvent: false, tableComponentEvents: [], tableColumnEvents: [], tableActionEvents: [], @@ -151,6 +152,9 @@ export const createInitSlice = (set, get) => ({ state.components[id].events.hasHoveredEvent = tableComponentEvents.some( (event) => event.event.eventId === 'onRowHovered' ); + state.components[id].events.hasDownloadEvent = tableComponentEvents.some( + (event) => event.event.eventId === 'onTableDataDownload' + ); state.components[id].events.tableColumnEvents = tableEvents.filter((event) => event.target === 'table_column'); state.components[id].events.tableActionEvents = tableEvents.filter((event) => event.target === 'table_action'); }, @@ -272,4 +276,7 @@ export const createInitSlice = (set, get) => ({ getHasHoveredEvent: (id) => { return get().components[id]?.events?.hasHoveredEvent || false; }, + getHasDownloadEvent: (id) => { + return get().components[id]?.events?.hasDownloadEvent || false; + }, });