From e948b1b98051405f23f38244b3d6eeca85871fe0 Mon Sep 17 00:00:00 2001 From: Ram Prasad Agarwal Date: Fri, 10 Jan 2025 15:21:10 +0530 Subject: [PATCH] [ui-storagebrowser] Adds silent pooling for list directory while file uploading --- .../StorageDirectoryPage.scss | 4 +++ .../StorageDirectoryPage.tsx | 25 +++++++++++++++---- .../js/utils/constants/storageBrowser.ts | 1 + 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/desktop/core/src/desktop/js/apps/storageBrowser/StorageDirectoryPage/StorageDirectoryPage.scss b/desktop/core/src/desktop/js/apps/storageBrowser/StorageDirectoryPage/StorageDirectoryPage.scss index e963f9ed495..b8b5e2cfb79 100644 --- a/desktop/core/src/desktop/js/apps/storageBrowser/StorageDirectoryPage/StorageDirectoryPage.scss +++ b/desktop/core/src/desktop/js/apps/storageBrowser/StorageDirectoryPage/StorageDirectoryPage.scss @@ -71,6 +71,10 @@ $icon-margin: 5px; height: $cell-height; @include mixins.nowrap-ellipsis; } + + td.ant-table-cell:first-child { + text-overflow: initial; + } } .hue-storage-browser__table-cell-name { diff --git a/desktop/core/src/desktop/js/apps/storageBrowser/StorageDirectoryPage/StorageDirectoryPage.tsx b/desktop/core/src/desktop/js/apps/storageBrowser/StorageDirectoryPage/StorageDirectoryPage.tsx index 8f870c599a3..80187d69e09 100644 --- a/desktop/core/src/desktop/js/apps/storageBrowser/StorageDirectoryPage/StorageDirectoryPage.tsx +++ b/desktop/core/src/desktop/js/apps/storageBrowser/StorageDirectoryPage/StorageDirectoryPage.tsx @@ -43,7 +43,11 @@ import formatBytes from '../../../utils/formatBytes'; import './StorageDirectoryPage.scss'; import { formatTimestamp } from '../../../utils/dateTimeUtils'; import useLoadData from '../../../utils/hooks/useLoadData'; -import { DEFAULT_PAGE_SIZE, FileUploadStatus } from '../../../utils/constants/storageBrowser'; +import { + DEFAULT_PAGE_SIZE, + DEFAULT_POOLING_TIME, + FileUploadStatus +} from '../../../utils/constants/storageBrowser'; import CreateAndUploadAction from './CreateAndUploadAction/CreateAndUploadAction'; import DragAndDrop from '../../../reactComponents/DragAndDrop/DragAndDrop'; import UUID from '../../../utils/string/UUID'; @@ -77,6 +81,7 @@ const StorageDirectoryPage = ({ const [tableHeight, setTableHeight] = useState(100); const [selectedFiles, setSelectedFiles] = useState([]); const [filesToUpload, setFilesToUpload] = useState([]); + const [pooling, setPooling] = useState(false); const [pageSize, setPageSize] = useState(DEFAULT_PAGE_SIZE); const [pageNumber, setPageNumber] = useState(1); @@ -106,7 +111,8 @@ const StorageDirectoryPage = ({ fileStats.type !== BrowserViewType.dir, onSuccess: () => { setSelectedFiles([]); - } + }, + pollInterval: pooling ? DEFAULT_POOLING_TIME : undefined }); const tableData: StorageDirectoryTableData[] = useMemo(() => { @@ -234,6 +240,7 @@ const StorageDirectoryPage = ({ status: FileUploadStatus.Pending }; }); + setPooling(true); setFilesToUpload(prevFiles => [...prevFiles, ...newUploadItems]); }; @@ -302,7 +309,10 @@ const StorageDirectoryPage = ({ - + `${r.path}_${r.type}_${r.mtime}`} rowSelection={{ + hideSelectAll: !tableData.length, + columnWidth: 36, type: 'checkbox', ...rowSelection }} scroll={{ y: tableHeight }} - data-testid={`${testId}`} + data-testid={testId} locale={locale} {...restProps} /> @@ -337,7 +349,10 @@ const StorageDirectoryPage = ({ setFilesToUpload([])} - onComplete={reloadData} + onComplete={() => { + reloadData(); + setPooling(false); + }} /> )} diff --git a/desktop/core/src/desktop/js/utils/constants/storageBrowser.ts b/desktop/core/src/desktop/js/utils/constants/storageBrowser.ts index 66abc472fff..432042350ed 100644 --- a/desktop/core/src/desktop/js/utils/constants/storageBrowser.ts +++ b/desktop/core/src/desktop/js/utils/constants/storageBrowser.ts @@ -18,6 +18,7 @@ export const DEFAULT_PAGE_SIZE = 50; export const DEFAULT_CHUNK_SIZE = 5 * 1024 * 1024; // 5 MiB export const DEFAULT_CONCURRENT_MAX_CONNECTIONS = 3; export const DEFAULT_ENABLE_CHUNK_UPLOAD = false; +export const DEFAULT_POOLING_TIME = 10 * 1000; // 10 seconds export enum SupportedFileTypes { IMAGE = 'image',