@@ -2,7 +2,6 @@ import React, { useEffect, useState } from 'react';
22import { useSelector } from 'react-redux' ;
33import {
44 InfiniteScrollTable ,
5- Dropdown ,
65 Button ,
76 EmptyState ,
87 Select
@@ -17,7 +16,7 @@ import { getMigrationLogs } from '../../services/api/migration.service';
1716const ExecutionLogs = ( { projectId } : { projectId : string } ) => {
1817 const [ data , setData ] = useState < LogEntry [ ] > ( [ ] ) ;
1918 const [ loading , setLoading ] = useState ( true ) ;
20- const [ totalCounts , setTotalCounts ] = useState < number | 0 > ( 0 ) ;
19+ const [ totalCounts , setTotalCounts ] = useState < number > ( 0 ) ;
2120 const [ searchText , setSearchText ] = useState < string > ( '' ) ;
2221 const [ filterOption , setFilterOption ] = useState < FilterOption [ ] > ( [ ] ) ;
2322 const [ isCursorInside , setIsCursorInside ] = useState ( false ) ;
@@ -29,25 +28,42 @@ const ExecutionLogs = ({ projectId }: { projectId: string }) => {
2928 ( state : RootState ) => state ?. authentication ?. selectedOrganisation
3029 ) ;
3130
32- const stacks = useSelector ( ( state : RootState ) => state ?. migration ?. newMigrationData ?. testStacks ) ;
31+ const testStacks = useSelector (
32+ ( state : RootState ) => state ?. migration ?. newMigrationData ?. testStacks
33+ ) ;
34+ console . info ( testStacks . length )
35+ const mainStack = useSelector (
36+ ( state : RootState ) => state ?. migration ?. newMigrationData ?. stackDetails
37+ ) ;
38+ const migrationCompleted = useSelector (
39+ ( state : RootState ) =>
40+ state ?. migration ?. newMigrationData ?. migration_execution ?. migrationCompleted
41+ ) ;
3342
34- const stackIds = stacks ?. map ( ( stack : StackIds ) => ( {
43+ const stackIds = testStacks ?. map ( ( stack : StackIds ) => ( {
3544 label : stack ?. stackName ,
3645 value : stack ?. stackUid
3746 } ) ) ;
3847
39- const [ selectedStackId , setSelectedStackId ] = useState < string > (
40- stackIds [ stackIds . length - 1 ] ?. value ?? ''
41- ) ;
42- const [ selectedStackName , setSelectedStackName ] = useState < string > (
43- stackIds [ stackIds . length - 1 ] ?. label ?? ''
48+ if ( migrationCompleted ) {
49+ stackIds ?. push ( {
50+ label : mainStack ?. label ,
51+ value : mainStack ?. value
52+ } ) ;
53+ }
54+
55+ const [ selectedStack , setSelectedStack ] = useState < DropdownOption > (
56+ {
57+ label : stackIds [ stackIds . length - 1 ] ?. label ?? '' ,
58+ value : stackIds [ stackIds . length - 1 ] ?. value ?? ''
59+ }
4460 ) ;
4561
4662 useEffect ( ( ) => {
47- if ( selectedStackId ) {
63+ if ( selectedStack ) {
4864 fetchData ( { } ) ;
4965 }
50- } , [ selectedStackId ] ) ;
66+ } , [ selectedStack ] ) ;
5167
5268 const ColumnFilter = ( ) => {
5369 const closeModal = ( ) => {
@@ -224,7 +240,7 @@ const ExecutionLogs = ({ projectId }: { projectId: string }) => {
224240 } ) => {
225241 searchText = searchText === '' ? 'null' : searchText ;
226242
227- if ( ! selectedStackId ) {
243+ if ( ! selectedStack ) {
228244 setLoading ( false ) ;
229245 return ;
230246 }
@@ -234,7 +250,7 @@ const ExecutionLogs = ({ projectId }: { projectId: string }) => {
234250 const response = await getMigrationLogs (
235251 selectedOrganisation ?. value || '' ,
236252 projectId ,
237- selectedStackId ,
253+ selectedStack . value ,
238254 skip ,
239255 limit ,
240256 startIndex ,
@@ -265,7 +281,6 @@ const ExecutionLogs = ({ projectId }: { projectId: string }) => {
265281 < InfiniteScrollTable
266282 tableHeight = { 590 }
267283 itemSize = { 60 }
268- TABLE_HEAD_HEIGHT = { 0 }
269284 columns = { columns }
270285 data = { data }
271286 uniqueKey = { 'timestamp' }
@@ -275,7 +290,8 @@ const ExecutionLogs = ({ projectId }: { projectId: string }) => {
275290 rowPerPageOptions = { [ 10 , 30 , 50 , 100 ] }
276291 minBatchSizeToFetch = { 30 }
277292 v2Features = { {
278- pagination : true
293+ pagination : true ,
294+ isNewEmptyState : true
279295 } }
280296 isResizable = { true }
281297 isRowSelect = { false }
@@ -286,24 +302,18 @@ const ExecutionLogs = ({ projectId }: { projectId: string }) => {
286302 onSearchChangeEvent = { ( value : string ) => setSearchText ( value ) }
287303 withExportCta = { {
288304 component : (
289- < Select
290- width = "250px"
291- version = "v2"
292- value = { selectedStackName }
293- options = { stackIds }
294- placeholder = {
295- selectedStackName === ''
296- ? stackIds . length > 0
297- ? 'Select Stack Id'
298- : 'No stack created'
299- : selectedStackName
300- }
301- onChange = { ( s : DropdownOption ) => {
302- setSelectedStackId ( s . value ) ;
303- setSelectedStackName ( s . label ) ;
304- setSearchText ( '' ) ;
305- } }
306- />
305+ < Select
306+ className = 'dropdown-wrapper'
307+ width = "250px"
308+ version = "v2"
309+ value = { testStacks . length ? selectedStack : '' }
310+ options = { stackIds }
311+ placeholder = 'Select a stack'
312+ onChange = { ( s : DropdownOption ) => {
313+ setSelectedStack ( { label : s . label , value : s . value } )
314+ setSearchText ( '' ) ;
315+ } }
316+ />
307317 ) ,
308318 showExportCta : true
309319 } }
0 commit comments