@@ -24,11 +24,11 @@ import Table from '@/components/Table';
2424class ComparisonSelect extends React . Component {
2525 constructor ( props ) {
2626 super ( props ) ;
27- const { iterations, selectedIterationKeys } = props ;
27+ const { iterations } = props ;
2828
2929 this . state = {
3030 resultIterations : iterations ,
31- selectedRowKeys : selectedIterationKeys ,
31+ selectedRows : [ ] ,
3232 } ;
3333 }
3434
@@ -48,7 +48,6 @@ class ComparisonSelect extends React.Component {
4848
4949 if ( nextProps . iterations !== iterations ) {
5050 this . setState ( { resultIterations : nextProps . iterations } ) ;
51- this . setState ( { selectedRowKeys : nextProps . selectedIterationKeys } ) ;
5251 }
5352 }
5453
@@ -61,16 +60,10 @@ class ComparisonSelect extends React.Component {
6160 } ;
6261
6362 onCompareIterations = ( ) => {
64- const { selectedRowKeys, resultIterations } = this . state ;
65-
66- if ( selectedRowKeys . flat ( 1 ) . length > 0 ) {
67- const selectedRowData = [ ] ;
68- selectedRowKeys . forEach ( rowKey => {
69- selectedRowKeys [ rowKey ] . forEach ( row => {
70- selectedRowData . push ( resultIterations [ rowKey ] . iterations [ selectedRowKeys [ rowKey ] [ row ] ] ) ;
71- } ) ;
72- } ) ;
73- this . compareIterations ( selectedRowData ) ;
63+ const { selectedRows, resultIterations } = this . state ;
64+
65+ if ( selectedRows . length > 0 ) {
66+ this . compareIterations ( selectedRows ) ;
7467 } else {
7568 let selectedIterations = [ ] ;
7669 resultIterations . forEach ( result => {
@@ -80,15 +73,8 @@ class ComparisonSelect extends React.Component {
8073 }
8174 } ;
8275
83- onSelectChange = record => {
84- const { selectedRowKeys } = this . state ;
85-
86- if ( selectedRowKeys [ record . table ] . includes ( record . key ) ) {
87- selectedRowKeys [ record . table ] . splice ( selectedRowKeys [ record . table ] . indexOf ( record . key ) , 1 ) ;
88- } else {
89- selectedRowKeys [ record . table ] . push ( record . key ) ;
90- }
91- this . setState ( { selectedRowKeys } ) ;
76+ onSelectChange = selectedRows => {
77+ this . setState ( { selectedRows } ) ;
9278 } ;
9379
9480 onFilterTable = ( selectedParams , selectedPorts ) => {
@@ -114,7 +100,7 @@ class ComparisonSelect extends React.Component {
114100 } ;
115101
116102 render ( ) {
117- const { resultIterations, selectedRowKeys } = this . state ;
103+ const { resultIterations } = this . state ;
118104 const { iterationParams, iterationPorts, selectedControllers, loading } = this . props ;
119105 return (
120106 < PageHeaderLayout
@@ -134,10 +120,10 @@ class ComparisonSelect extends React.Component {
134120 filters = { iterationParams }
135121 ports = { iterationPorts }
136122 />
137- { resultIterations . map ( ( iteration , index ) => {
123+ { resultIterations . map ( iteration => {
138124 const rowSelection = {
139- selectedRowKeys : selectedRowKeys [ index ] ,
140- onSelect : record => this . onSelectChange ( record ) ,
125+ onSelect : ( record , selected , selectedRows ) => this . onSelectChange ( selectedRows ) ,
126+ onSelectAll : ( selected , selectedRows ) => this . onSelectAll ( selectedRows ) ,
141127 } ;
142128 return (
143129 < div key = { iteration . resultName } style = { { marginTop : 32 } } >
@@ -152,6 +138,7 @@ class ComparisonSelect extends React.Component {
152138 rowSelection = { rowSelection }
153139 columns = { iteration . columns }
154140 dataSource = { iteration . iterations }
141+ hideDefaultSelections
155142 bordered
156143 />
157144 </ div >
0 commit comments