From 54703700261ad3b4477e94f2c797b797b6028937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladan=20Tomi=C4=87?= Date: Mon, 16 Oct 2023 11:45:32 +0200 Subject: [PATCH 1/3] fix: search --- src/api/pod.ts | 4 ++++ src/components/Views/DriveGridView/DriveGridView.tsx | 4 ++-- src/components/Views/DriveListView/DriveListView.tsx | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/api/pod.ts b/src/api/pod.ts index 195fe655..3e0cb8a9 100644 --- a/src/api/pod.ts +++ b/src/api/pod.ts @@ -29,6 +29,10 @@ export function getFdpPathByDirectory(directory: string): string { return '/'; } + if (directory.startsWith('/')) { + return directory; + } + return '/' + directory; } diff --git a/src/components/Views/DriveGridView/DriveGridView.tsx b/src/components/Views/DriveGridView/DriveGridView.tsx index e1dbd9e5..1c654286 100644 --- a/src/components/Views/DriveGridView/DriveGridView.tsx +++ b/src/components/Views/DriveGridView/DriveGridView.tsx @@ -21,7 +21,7 @@ const DriveGridView: FC = ({
{directories?.map((directory) => ( = ({ {files?.map((data) => ( = ({ {pageDirectories.map((directory) => ( = ({ {pageFiles.map((data) => ( Date: Mon, 16 Oct 2023 12:51:14 +0200 Subject: [PATCH 2/3] fix: search --- src/pages/drive/index.tsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/pages/drive/index.tsx b/src/pages/drive/index.tsx index e81efa75..9acaf389 100644 --- a/src/pages/drive/index.tsx +++ b/src/pages/drive/index.tsx @@ -282,22 +282,24 @@ const Drive: FC = () => { } if (Array.isArray(content?.files)) { - matchedFiles = matchedFiles - .concat(content.files.filter(({ name }) => name.includes(search))) - .map((file) => { - file.path = path; - return file; - }); + matchedFiles = matchedFiles.concat( + content.files + .filter(({ name }) => name.includes(search)) + .map((file) => ({ + ...file, + path, + })) + ); } if (Array.isArray(content?.directories)) { matchedDirectories = matchedDirectories.concat( content.directories .filter(({ name }) => name.includes(search)) - .map((directory) => { - directory.path = path; - return directory; - }) + .map((directory) => ({ + ...directory, + path, + })) ); if (depth < maxDepth) { From fe376b21ead088d75afae62687d2afc8258e1342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladan=20Tomi=C4=87?= Date: Mon, 16 Oct 2023 12:57:16 +0200 Subject: [PATCH 3/3] fix: search --- .../Modals/PreviewFileModal/PreviewFileModal.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/Modals/PreviewFileModal/PreviewFileModal.tsx b/src/components/Modals/PreviewFileModal/PreviewFileModal.tsx index 490749c0..5d1c56e2 100644 --- a/src/components/Modals/PreviewFileModal/PreviewFileModal.tsx +++ b/src/components/Modals/PreviewFileModal/PreviewFileModal.tsx @@ -34,7 +34,7 @@ import FilePreview, { isFilePreviewSupported, } from '@components/FilePreview/FilePreview'; import { FileItem } from '@fairdatasociety/fdp-storage'; -import { extractFileExtension } from '@utils/filename'; +import { extractFileExtension, rootPathToRelative } from '@utils/filename'; import { useLocales } from '@context/LocalesContext'; interface PreviewModalProps { @@ -62,6 +62,8 @@ const PreviewFileModal: FC = ({ const [showConfirmDeleteModal, setShowConfirmDeleteModal] = useState(false); const { intl } = useLocales(); + const directory = rootPathToRelative(previewFile.path || directoryName); + useEffect(() => { if (!isFilePreviewSupported(previewFile?.name)) { return; @@ -70,7 +72,7 @@ const PreviewFileModal: FC = ({ setLoading(true); downloadFile(fdpClientRef.current, { filename: previewFile?.name, - directory: previewFile.path || directoryName, + directory, podName: activePod, }) .then(async (response) => { @@ -92,7 +94,7 @@ const PreviewFileModal: FC = ({ downloadFile(fdpClientRef.current, { filename: previewFile?.name, - directory: directoryName, + directory, podName: activePod, }) .then((response) => { @@ -119,7 +121,7 @@ const PreviewFileModal: FC = ({ deleteFile(fdpClientRef.current, { file_name: previewFile?.name, podName: activePod, - path: formatDirectory(directoryName), + path: formatDirectory(directory), }) .then(() => { trackEvent({ @@ -158,7 +160,7 @@ const PreviewFileModal: FC = ({ file={previewFile} source={fileContent} pod={activePod} - directory={directoryName} + directory={directory} onError={() => setErrorMessage(intl.get('FILE_PREVIEW_ERROR'))} /> ) : null} @@ -254,7 +256,7 @@ const PreviewFileModal: FC = ({ closeModal={() => setShowShareFileModal(false)} fileName={previewFile?.name} podName={activePod} - path={formatDirectory(directoryName)} + path={formatDirectory(directory)} />