Skip to content

Commit 33be8b7

Browse files
committed
Close modal after finising or canceling migration
1 parent 9b2525d commit 33be8b7

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/components/PreferencesModal/MigrationTab.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { useStorageRouter } from '../../lib/storageRouter'
1818
import Icon from '../../shared/components/atoms/Icon'
1919
import styled from '../../shared/lib/styled'
2020
import Button from '../../shared/components/atoms/Button'
21+
import { useToast } from '../../shared/lib/stores/toast'
2122

2223
interface MigrationPageProps {
2324
storage: NoteStorage
@@ -55,14 +56,15 @@ const MigrationTab = ({ storage }: MigrationPageProps) => {
5556
} = useGeneralStatus()
5657
const { get, start, end } = useMigrations()
5758
const { navigateToNote } = useStorageRouter()
59+
const { pushMessage } = useToast()
5860

5961
const runningJob = get(storage.id)
6062

6163
const [migrationState, setMigrationState] = useState<MigrationState>(
6264
initState(boostHubTeams, runningJob)
6365
)
6466
const [workspaceErr, setWorkspaceErr] = useState<Error | null>(null)
65-
const { openTab, setClosed } = usePreferences()
67+
const { setClosed } = usePreferences()
6668

6769
useEffect(() => {
6870
if (runningJob != null) {
@@ -99,12 +101,18 @@ const MigrationTab = ({ storage }: MigrationPageProps) => {
99101
const cancel = useCallback(() => {
100102
end(storage.id)
101103
setMigrationState(transitionCancel(boostHubTeams))
102-
}, [boostHubTeams, end, storage.id])
104+
setClosed(true)
105+
}, [boostHubTeams, end, storage.id, setClosed])
103106

104107
const finish = useCallback(() => {
105108
end(storage.id)
106-
openTab('storage')
107-
}, [end, openTab, storage])
109+
setClosed(true)
110+
pushMessage({
111+
type: 'success',
112+
title: 'The migration has been finished',
113+
description: 'Please check migrated data in the destination cloud space',
114+
})
115+
}, [end, storage.id, setClosed, pushMessage])
108116

109117
if (migrationState.step === 'login') {
110118
return (
@@ -159,7 +167,7 @@ const MigrationTab = ({ storage }: MigrationPageProps) => {
159167
</Flexbox>
160168
</FormGroup>
161169
<Flexbox justifyContent='flex-end'>
162-
<Button variant={'transparent'} onClick={() => openTab('storage')}>
170+
<Button variant={'transparent'} onClick={() => setClosed(true)}>
163171
Cancel
164172
</Button>
165173
<Button

0 commit comments

Comments
 (0)