File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ import { useParams } from 'react-router-dom'
5
5
import cx from 'classnames'
6
6
7
7
import {
8
- fetchInstanceAction ,
9
- getDatabaseConfigInfoAction ,
8
+ fetchInstanceAction , fetchInstancesAction ,
9
+ getDatabaseConfigInfoAction , instancesSelector ,
10
10
} from 'uiSrc/slices/instances'
11
11
import {
12
12
appContextSelector ,
@@ -53,13 +53,16 @@ const InstancePage = ({ routes = [] }: Props) => {
53
53
const dispatch = useDispatch ( )
54
54
const { instanceId : connectionInstanceId } = useParams < { instanceId : string } > ( )
55
55
const { isShowCli, isShowHelper } = useSelector ( cliSettingsSelector )
56
+ const { data : modulesData } = useSelector ( instancesSelector )
56
57
const { isShowMonitor } = useSelector ( monitorSelector )
57
58
const { contextInstanceId } = useSelector ( appContextSelector )
58
59
59
60
const isShowBottomGroup = isShowCli || isShowHelper || isShowMonitor
60
61
61
62
useEffect ( ( ) => {
62
- dispatch ( fetchInstanceAction ( connectionInstanceId ) )
63
+ dispatch ( fetchInstanceAction ( connectionInstanceId , ( ) => {
64
+ ! modulesData . length && dispatch ( fetchInstancesAction ( ) )
65
+ } ) )
63
66
dispatch ( getDatabaseConfigInfoAction ( connectionInstanceId ) )
64
67
65
68
if ( contextInstanceId !== connectionInstanceId ) {
Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ const instancesSlice = createSlice({
52
52
loadInstancesSuccess : ( state , { payload } : { payload : Instance [ ] } ) => {
53
53
state . data = checkRediStack ( payload )
54
54
state . loading = false
55
+ if ( state . connectedInstance . id ) {
56
+ const isRediStack = state . data . find ( ( db ) => db . id === state . connectedInstance . id ) ?. isRediStack
57
+ state . connectedInstance . isRediStack = isRediStack || false
58
+ }
55
59
} ,
56
60
loadInstancesFailure : ( state , { payload } ) => {
57
61
state . loading = false
@@ -135,7 +139,9 @@ const instancesSlice = createSlice({
135
139
136
140
// set connected instance
137
141
setConnectedInstance : ( state , { payload } : { payload : Instance } ) => {
138
- state . connectedInstance = checkRediStack ( [ payload ] ) [ 0 ]
142
+ const isRediStack = state . data ?. find ( ( db ) => db . id === state . connectedInstance . id ) ?. isRediStack
143
+ state . connectedInstance = payload
144
+ state . connectedInstance . isRediStack = isRediStack || false
139
145
} ,
140
146
141
147
// reset connected instance
@@ -332,6 +338,7 @@ export function checkConnectToInstanceAction(
332
338
) {
333
339
return async ( dispatch : AppDispatch ) => {
334
340
dispatch ( setDefaultInstance ( ) )
341
+ dispatch ( resetConnectedInstance ( ) )
335
342
try {
336
343
const { status } = await apiService . get ( `${ ApiEndpoints . INSTANCE } /${ id } /connect` )
337
344
You can’t perform that action at this time.
0 commit comments