From cfcda49c8038a3bbbce38666d585dc61c17cf2e0 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 8 Apr 2024 16:39:55 +0100 Subject: [PATCH] Fix data export for legacy configs --- packages/client/src/utils/buttonActions.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js index 2fa68ce424..c481fa5828 100644 --- a/packages/client/src/utils/buttonActions.js +++ b/packages/client/src/utils/buttonActions.js @@ -331,20 +331,29 @@ const s3UploadHandler = async action => { } } +/** + * For new configs, "rows" is defined and enriched to be the array of rows to + * export. For old configs it will be undefined and we need to use the legacy + * row selection store in combination with the tableComponentId parameter. + */ const exportDataHandler = async action => { let { tableComponentId, rows, type, columns, delimiter, customHeaders } = action.parameters + let tableId // Handle legacy configs using the row selection store if (!rows?.length) { const selection = rowSelectionStore.actions.getSelection(tableComponentId) - if (selection?.rows?.length) { + if (selection?.selectedRows?.length) { rows = selection.selectedRows + tableId = selection.tableId } } - // Get table ID from first row - const tableId = rows?.[0]?.tableId + // Get table ID from first row if needed + if (!tableId) { + tableId = rows?.[0]?.tableId + } // Handle no rows selected if (!rows?.length) {