From e6b2d53dd679f81d278cbeb32e3f66bdbea00f59 Mon Sep 17 00:00:00 2001 From: Aymeric <123820772+Aymerix01@users.noreply.github.com> Date: Wed, 26 Jul 2023 10:34:01 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Go=20to=20a=20folder=20when=20searc?= =?UTF-8?q?hed=20(#68)=20(#152)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✨ Go to a folder when searched (#68) --- .../search-popup/parts/drive-item-result.tsx | 44 ++++++++++--------- .../components/search-popup/search-popup.tsx | 4 +- .../components/search-popup/search-tabs.tsx | 2 +- .../components/search-popup/tabs/drive.tsx | 6 +-- .../features/drive/hooks/use-drive-preview.ts | 7 +++ 5 files changed, 37 insertions(+), 26 deletions(-) diff --git a/tdrive/frontend/src/app/components/search-popup/parts/drive-item-result.tsx b/tdrive/frontend/src/app/components/search-popup/parts/drive-item-result.tsx index 5c477444..7de76217 100644 --- a/tdrive/frontend/src/app/components/search-popup/parts/drive-item-result.tsx +++ b/tdrive/frontend/src/app/components/search-popup/parts/drive-item-result.tsx @@ -1,7 +1,7 @@ import { FolderIcon } from '@heroicons/react/solid'; import Highlighter from 'react-highlight-words'; import { useRecoilState, useRecoilValue } from 'recoil'; -import { onDriveItemDownloadClick, openDriveItem } from '../common'; +import { onDriveItemDownloadClick } from '../common'; import ResultContext from './result-context'; import { Button } from '@atoms/button/button'; import { DownloadIcon } from '@atoms/icons-agnostic'; @@ -15,7 +15,6 @@ import { } from '@atoms/icons-colored'; import * as Text from '@atoms/text'; import { useCompanyApplications } from '@features/applications/hooks/use-company-applications'; -import useRouterCompany from '@features/router/hooks/use-router-company'; import { DriveItem } from '@features/drive/types'; import FileUploadAPIClient from '@features/files/api/file-upload-api-client'; import { formatDate } from '@features/global/utils/format-date'; @@ -24,16 +23,15 @@ import useRouterWorkspace from '@features/router/hooks/use-router-workspace'; import { useSearchModal } from '@features/search/hooks/use-search'; import { SearchInputState } from '@features/search/state/search-input'; import { UserType } from '@features/users/types/user'; -import { useFileViewerModal } from '@features/viewer/hooks/use-viewer'; import { useDrivePreview } from '@features/drive/hooks/use-drive-preview'; import Media from '@molecules/media'; import { DriveCurrentFolderAtom } from '@views/client/body/drive/browser'; import { useHistory } from 'react-router-dom'; import RouterServices from '@features/router/services/router-service'; import { useCurrentUser } from 'app/features/users/hooks/use-current-user'; +import useRouterCompany from 'app/features/router/hooks/use-router-company'; - -export default (props: { driveItem: DriveItem & { user?: UserType } }) => { +export default (props: { driveItem: DriveItem & { user?: UserType }}) => { const history = useHistory(); const input = useRecoilValue(SearchInputState); const currentWorkspaceId = useRouterWorkspace(); @@ -49,10 +47,14 @@ export default (props: { driveItem: DriveItem & { user?: UserType } }) => { const extension = name?.split('.').pop(); const { setOpen } = useSearchModal(); - const { open: openViewer } = useFileViewerModal(); const { open } = useDrivePreview(); const company = useRouterCompany(); + function openDoc(file: DriveItem){ + open(file); + if (file.is_directory) setOpen(false); + } + return (