Skip to content

Commit 1fa4727

Browse files
committed
#RI-6313 - change refresh instances on success import, refresh import form after close
1 parent 6ded30c commit 1fa4727

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

redisinsight/ui/src/pages/home/HomePage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
fetchEditedInstanceAction,
2121
fetchInstancesAction,
2222
instancesSelector,
23+
resetImportInstances,
2324
setEditedInstance
2425
} from 'uiSrc/slices/instances/instances'
2526
import { localStorageService } from 'uiSrc/services'
@@ -158,6 +159,7 @@ const HomePage = () => {
158159
const handleClose = () => {
159160
dispatch(resetDataRedisCluster())
160161
dispatch(resetDataSentinel())
162+
dispatch(resetImportInstances())
161163

162164
setOpenDialog(null)
163165
dispatch(setEditedInstance(null))

redisinsight/ui/src/pages/home/components/import-database/ImportDatabase.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ const ImportDatabase = (props: Props) => {
4444

4545
useEffect(() => {
4646
setDomReady(true)
47-
48-
return () => {
49-
dispatch(resetImportInstances())
50-
}
5147
}, [])
5248

5349
const onFileChange = (files: FileList | null) => {
@@ -57,9 +53,6 @@ const ImportDatabase = (props: Props) => {
5753
}
5854

5955
const handleOnClose = () => {
60-
if (data?.success?.length || data?.partial?.length) {
61-
dispatch(fetchInstancesAction())
62-
}
6356
onClose()
6457
dispatch(resetImportInstances())
6558

@@ -80,7 +73,14 @@ const ImportDatabase = (props: Props) => {
8073
const formData = new FormData()
8174
formData.append('file', files[0])
8275

83-
dispatch(uploadInstancesFile(formData))
76+
dispatch(uploadInstancesFile(
77+
formData,
78+
(data) => {
79+
if (data?.success?.length || data?.partial?.length) {
80+
dispatch(fetchInstancesAction())
81+
}
82+
}
83+
))
8484

8585
sendEventTelemetry({
8686
event: TelemetryEvent.CONFIG_DATABASES_REDIS_IMPORT_SUBMITTED

redisinsight/ui/src/slices/instances/instances.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ export function resetInstanceUpdateAction() {
798798
// Asynchronous thunk action
799799
export function uploadInstancesFile(
800800
file: FormData,
801-
onSuccessAction?: () => void,
801+
onSuccessAction?: (data: any) => void,
802802
onFailAction?: () => void
803803
) {
804804
return async (dispatch: AppDispatch) => {
@@ -818,7 +818,7 @@ export function uploadInstancesFile(
818818

819819
if (isStatusSuccessful(status)) {
820820
dispatch(importInstancesFromFileSuccess(data))
821-
onSuccessAction?.()
821+
onSuccessAction?.(data)
822822
}
823823
} catch (_err) {
824824
const error = _err as AxiosError

0 commit comments

Comments
 (0)