@@ -92,7 +92,6 @@ export type GridContext = {
92
92
class DocumentTableView extends React . Component < DocumentTableViewProps > {
93
93
AGGrid : React . ReactElement ;
94
94
collection : string ;
95
- hadronDocs : Document [ ] ;
96
95
topLevel : boolean ;
97
96
// eslint-disable-next-line @typescript-eslint/ban-types
98
97
unsubscribeGridStore ?: Function ;
@@ -153,7 +152,6 @@ class DocumentTableView extends React.Component<DocumentTableViewProps> {
153
152
} ;
154
153
155
154
this . collection = mongodbns ( props . ns ) . collection ;
156
- this . hadronDocs = [ ] ;
157
155
this . topLevel = true ;
158
156
159
157
this . AGGrid = React . createElement ( AgGridReact , sharedGridProperties ) ;
@@ -171,10 +169,6 @@ class DocumentTableView extends React.Component<DocumentTableViewProps> {
171
169
this . gridApi ?. destroy ?.( ) ;
172
170
}
173
171
174
- UNSAFE_componentWillReceiveProps ( nextProps : DocumentTableViewProps ) {
175
- this . hadronDocs = nextProps . docs ;
176
- }
177
-
178
172
componentDidUpdate ( prevProps : DocumentTableViewProps ) {
179
173
this . handleBreadcrumbChange ( ) ;
180
174
@@ -204,7 +198,6 @@ class DocumentTableView extends React.Component<DocumentTableViewProps> {
204
198
this . gridApi = params . api ;
205
199
this . columnApi = params . columnApi ;
206
200
207
- this . hadronDocs = this . props . docs ;
208
201
this . handleBreadcrumbChange ( ) ;
209
202
}
210
203
@@ -330,13 +323,12 @@ class DocumentTableView extends React.Component<DocumentTableViewProps> {
330
323
rowNumber : rowNumber ,
331
324
} ;
332
325
333
- /* Update this.hadronDocs */
334
- for ( let i = 0 ; i < this . hadronDocs . length ; i ++ ) {
326
+ for ( let i = 0 ; i < this . props . docs . length ; i ++ ) {
335
327
if (
336
- this . hadronDocs [ i ] . getStringId ( ) ===
328
+ this . props . docs [ i ] . getStringId ( ) ===
337
329
newData . hadronDocument . getStringId ( )
338
330
) {
339
- this . hadronDocs [ i ] = newData . hadronDocument ;
331
+ this . props . docs [ i ] = newData . hadronDocument ;
340
332
break ;
341
333
}
342
334
}
@@ -561,9 +553,6 @@ class DocumentTableView extends React.Component<DocumentTableViewProps> {
561
553
rowNumber : lineNumber ,
562
554
} ;
563
555
564
- /* Update this.hadronDocs */
565
- this . hadronDocs . splice ( index , 0 , data . hadronDocument ) ;
566
-
567
556
if ( this . topLevel ) {
568
557
/* Update row numbers */
569
558
this . updateRowNumbers ( lineNumber , true ) ;
@@ -613,24 +602,20 @@ class DocumentTableView extends React.Component<DocumentTableViewProps> {
613
602
if ( params . path . length === 0 ) {
614
603
this . topLevel = true ;
615
604
616
- const headers = this . createColumnHeaders ( this . hadronDocs , [ ] , [ ] ) ;
605
+ const headers = this . createColumnHeaders ( [ ] , [ ] ) ;
617
606
618
607
( this . gridApi as any ) . gridOptionsWrapper . gridOptions . context . path = [ ] ;
619
608
this . gridApi . setColumnDefs ( headers ) ;
620
609
this . gridApi . setRowData (
621
- this . createRowData ( this . hadronDocs , this . props . start )
610
+ this . createRowData ( this . props . docs , this . props . start )
622
611
) ;
623
612
} else if (
624
613
params . types [ params . types . length - 1 ] === 'Object' ||
625
614
params . types [ params . types . length - 1 ] === 'Array'
626
615
) {
627
616
this . topLevel = false ;
628
617
629
- const headers = this . createColumnHeaders (
630
- this . hadronDocs ,
631
- params . path ,
632
- params . types
633
- ) ;
618
+ const headers = this . createColumnHeaders ( params . path , params . types ) ;
634
619
headers . push ( this . createObjectIdHeader ( ) ) ;
635
620
636
621
if ( headers . length <= 3 ) {
@@ -644,7 +629,7 @@ class DocumentTableView extends React.Component<DocumentTableViewProps> {
644
629
645
630
( this . gridApi as any ) . gridOptionsWrapper . gridOptions . context . path =
646
631
params . path ;
647
- this . gridApi . setRowData ( this . createRowData ( this . hadronDocs , 1 ) ) ;
632
+ this . gridApi . setRowData ( this . createRowData ( this . props . docs , 1 ) ) ;
648
633
this . gridApi . setColumnDefs ( headers ) ;
649
634
}
650
635
this . gridApi . refreshCells ( { force : true } ) ;
@@ -869,15 +854,13 @@ class DocumentTableView extends React.Component<DocumentTableViewProps> {
869
854
* Third, get the displayed type for the headers of each of the field columns.
870
855
* Last, add the document level actions column that is pinned to the right.
871
856
*
872
- * @param {Array } hadronDocs - The list of HadronDocuments.
873
857
* @param {Array } path - The list of path segments. Empty when top-level.
874
858
* @param {Array } types - The list of types. If element is not of the correct
875
859
* type, then don't render it.
876
860
*
877
861
* @returns {object } the ColHeaders, which is a list of colDefs.
878
862
*/
879
863
createColumnHeaders = (
880
- hadronDocs : Document [ ] ,
881
864
path : ( string | number ) [ ] ,
882
865
types : TableHeaderType [ ]
883
866
) : ColDef [ ] => {
@@ -902,9 +885,9 @@ class DocumentTableView extends React.Component<DocumentTableViewProps> {
902
885
} ;
903
886
904
887
/* Make column definitions + track type for header components */
905
- for ( let i = 0 ; i < hadronDocs . length ; i ++ ) {
888
+ for ( let i = 0 ; i < this . props . docs . length ; i ++ ) {
906
889
/* Get the top-level element/document in the view */
907
- let topLevel : Document | Element = hadronDocs [ i ] ;
890
+ let topLevel : Document | Element = this . props . docs [ i ] ;
908
891
909
892
if ( path . length > 0 ) {
910
893
topLevel = topLevel . getChild ( path ) ! ;
@@ -926,7 +909,7 @@ class DocumentTableView extends React.Component<DocumentTableViewProps> {
926
909
if ( ! ( key in headerTypes ) ) {
927
910
headerTypes [ key ] = { } ;
928
911
}
929
- headerTypes [ key ] [ String ( hadronDocs [ i ] . getStringId ( ) ) ] = type ;
912
+ headerTypes [ key ] [ String ( this . props . docs [ i ] . getStringId ( ) ) ] = type ;
930
913
}
931
914
}
932
915
0 commit comments