-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use a route instead pushModal to open MoveModal
- Loading branch information
Showing
5 changed files
with
78 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react' | ||
import { Navigate, useLocation, useNavigate } from 'react-router-dom' | ||
|
||
import { hasQueryBeenLoaded, useQuery } from 'cozy-client' | ||
|
||
import MoveModal from 'drive/web/modules/move/MoveModal' | ||
import { buildParentsByIdsQuery } from 'drive/web/modules/queries' | ||
import { LoaderModal } from 'drive/components/LoaderModal' | ||
|
||
const MoveFilesView = () => { | ||
const navigate = useNavigate() | ||
const { state } = useLocation() | ||
|
||
const hasFileIds = state?.fileIds != undefined | ||
|
||
const fileQuery = buildParentsByIdsQuery(hasFileIds ? state.fileIds : []) | ||
const fileResult = useQuery(fileQuery.definition, { | ||
...fileQuery.options, | ||
enabled: hasFileIds | ||
}) | ||
|
||
if (!hasFileIds) { | ||
return <Navigate to=".." replace={true} /> | ||
} | ||
|
||
if (hasQueryBeenLoaded(fileResult) && fileResult.data) { | ||
const onClose = () => { | ||
navigate('..', { replace: true }) | ||
} | ||
|
||
return <MoveModal entries={fileResult.data} onClose={onClose} /> | ||
} | ||
|
||
return <LoaderModal /> | ||
} | ||
|
||
export { MoveFilesView } |