File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import {
25
25
PopoverTrigger ,
26
26
} from "@/components/ui/popover" ;
27
27
import downloadCsv from "/src/helpers/donwloadCsv.js" ;
28
+ import transformRows from "/src/helpers/transformRows.js" ;
28
29
import { suggestions } from "@/providers/AutoCompleteMonaco" ;
29
30
30
31
export default function QueryTabContent ( { tab } ) {
@@ -237,7 +238,7 @@ export default function QueryTabContent({ tab }) {
237
238
) : (
238
239
< AgGridReact
239
240
alwaysShowVerticalScroll = { true }
240
- rowData = { tab . tab_results }
241
+ rowData = { transformRows ( tab . tab_results ) }
241
242
enableCellTextSelection = { true }
242
243
columnDefs = {
243
244
tab . tab_results && tab . tab_results . length > 0
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { AgGridReact } from "ag-grid-react"; // React Data Grid Component
5
5
import "ag-grid-community/styles/ag-grid.css" ; // Mandatory CSS required by the grid
6
6
import "ag-grid-community/styles/ag-theme-alpine.css" ; // Optional theme CSS
7
7
import downloadCsv from "/src/helpers/donwloadCsv.js" ;
8
+ import transformRows from "/src/helpers/transformRows.js" ;
8
9
9
10
import {
10
11
Popover ,
@@ -251,7 +252,7 @@ export default function TableTabContent({ tab }) {
251
252
< AgGridReact
252
253
enableCellTextSelection = { true }
253
254
alwaysShowVerticalScroll = { true }
254
- rowData = { currentPreview }
255
+ rowData = { transformRows ( currentPreview ) }
255
256
columnDefs = { Object . keys ( currentPreview [ 0 ] ) ?. map ( ( key ) => ( {
256
257
headerName : key ,
257
258
field : key ,
Original file line number Diff line number Diff line change
1
+ const transformRows = ( previewData ) => {
2
+ if ( ! previewData ) {
3
+ return previewData ;
4
+ }
5
+
6
+ let data = previewData . map ( ( row ) => {
7
+ let newRow = { } ;
8
+ Object . keys ( row ) . forEach ( ( key ) => {
9
+ let value = row [ key ] ;
10
+ // type checks
11
+ if (
12
+ typeof value === "object" &&
13
+ ! Array . isArray ( value ) &&
14
+ value !== null
15
+ ) {
16
+ newRow [ key ] = JSON . stringify ( value ) ;
17
+ } else if ( Array . isArray ( value ) ) {
18
+ // consider recursively checking the children
19
+ let value = row [ key ] ;
20
+ newRow [ key ] = value . map ( ( el ) => {
21
+ if ( typeof el === "object" && ! Array . isArray ( el ) && el !== null ) {
22
+ return JSON . stringify ( el ) ;
23
+ } else {
24
+ return el ;
25
+ }
26
+ } ) ;
27
+ } else {
28
+ newRow [ key ] = row [ key ] ;
29
+ }
30
+ } ) ;
31
+ return newRow ;
32
+ } ) ;
33
+ return data ;
34
+ } ;
35
+
36
+ export default transformRows ;
You can’t perform that action at this time.
0 commit comments