Skip to content

Commit

Permalink
feat(MoveFilesView): Adapt to FolderPicker api change
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Jun 7, 2024
1 parent 2effba3 commit cdadbd6
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/modules/views/Modal/MoveFilesView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import React from 'react'
import { Navigate, useLocation, useNavigate } from 'react-router-dom'

import { hasQueryBeenLoaded, useQuery } from 'cozy-client'
import flag from 'cozy-flags'

import { LoaderModal } from 'components/LoaderModal'
import useDisplayedFolder from 'hooks/useDisplayedFolder'
import MoveModal from 'modules/move/MoveModal'
import { buildParentsByIdsQuery } from 'modules/queries'

const MoveFilesView = () => {
const navigate = useNavigate()
const { state } = useLocation()
const { displayedFolder } = useDisplayedFolder()

const hasFileIds = state?.fileIds != undefined

Expand All @@ -23,12 +26,23 @@ const MoveFilesView = () => {
return <Navigate to=".." replace={true} />
}

if (hasQueryBeenLoaded(fileResult) && fileResult.data) {
if (hasQueryBeenLoaded(fileResult) && fileResult.data && displayedFolder) {
const onClose = () => {
navigate('..', { replace: true })
}

return <MoveModal entries={fileResult.data} onClose={onClose} />
const showNextcloudFolder =
flag('drive.show-nextcloud-move-dev') &&
!fileResult.data.some(file => file.type === 'directory')

return (
<MoveModal
currentFolder={displayedFolder}
entries={fileResult.data}
onClose={onClose}
showNextcloudFolder={showNextcloudFolder}
/>
)
}

return <LoaderModal />
Expand Down

0 comments on commit cdadbd6

Please sign in to comment.