Browse Source

[ui-storagebrowser] fixes console warning and types (#3929)

Ram Prasad Agarwal 11 months ago
parent
commit
2f19d31831

+ 5 - 5
desktop/core/src/desktop/js/apps/storageBrowser/FileChooserModal/FileChooserModal.tsx

@@ -27,7 +27,7 @@ import { i18nReact } from '../../../utils/i18nReact';
 import useDebounce from '../../../utils/useDebounce';
 import useDebounce from '../../../utils/useDebounce';
 import useLoadData from '../../../utils/hooks/useLoadData';
 import useLoadData from '../../../utils/hooks/useLoadData';
 
 
-import { ListDirectory } from '../../../reactComponents/FileChooser/types';
+import { BrowserViewType, ListDirectory } from '../../../reactComponents/FileChooser/types';
 import { LIST_DIRECTORY_API_URL } from '../../../reactComponents/FileChooser/api';
 import { LIST_DIRECTORY_API_URL } from '../../../reactComponents/FileChooser/api';
 import PathBrowser from '../../../reactComponents/PathBrowser/PathBrowser';
 import PathBrowser from '../../../reactComponents/PathBrowser/PathBrowser';
 
 
@@ -105,7 +105,7 @@ const FileChooserModal = ({
         column.render = (_, record: FileChooserTableData) => (
         column.render = (_, record: FileChooserTableData) => (
           <Tooltip title={record.name} mouseEnterDelay={1.5}>
           <Tooltip title={record.name} mouseEnterDelay={1.5}>
             <span className="hue-filechooser-modal__table-cell-icon">
             <span className="hue-filechooser-modal__table-cell-icon">
-              {record.type === 'dir' ? <FolderIcon /> : <FileIcon />}
+              {record.type === BrowserViewType.dir ? <FolderIcon /> : <FileIcon />}
             </span>
             </span>
             <span className="hue-filechooser-modal__table-cell-name">{record.name}</span>
             <span className="hue-filechooser-modal__table-cell-name">{record.name}</span>
           </Tooltip>
           </Tooltip>
@@ -119,7 +119,7 @@ const FileChooserModal = ({
   const onRowClicked = (record: FileChooserTableData) => {
   const onRowClicked = (record: FileChooserTableData) => {
     return {
     return {
       onClick: () => {
       onClick: () => {
-        if (record.type === 'dir') {
+        if (record.type === BrowserViewType.dir) {
           setDestPath(record.path);
           setDestPath(record.path);
         }
         }
       }
       }
@@ -168,10 +168,10 @@ const FileChooserModal = ({
             dataSource={tableData}
             dataSource={tableData}
             pagination={false}
             pagination={false}
             columns={getColumns(tableData[0] ?? {})}
             columns={getColumns(tableData[0] ?? {})}
-            rowKey={(record, index) => record.path + index}
+            rowKey={r => `${r.path}__${r.type}__${r.name}`}
             scroll={{ y: '250px' }}
             scroll={{ y: '250px' }}
             rowClassName={record =>
             rowClassName={record =>
-              record.type === 'file'
+              record.type === BrowserViewType.file
                 ? classNames('hue-filechooser-modal__table-row', 'disabled-row')
                 ? classNames('hue-filechooser-modal__table-row', 'disabled-row')
                 : 'hue-filechooser-modal__table-row'
                 : 'hue-filechooser-modal__table-row'
             }
             }

+ 1 - 1
desktop/core/src/desktop/js/config/types.ts

@@ -62,7 +62,7 @@ export enum AppType {
 
 
 interface StorageBrowserConfig {
 interface StorageBrowserConfig {
   concurrent_max_connection: number;
   concurrent_max_connection: number;
-  enable_chunked_file_uploader: boolean;
+  enable_chunked_file_upload: boolean;
   enable_file_download_button: boolean;
   enable_file_download_button: boolean;
   enable_new_storage_browser: boolean;
   enable_new_storage_browser: boolean;
   file_upload_chunk_size: number;
   file_upload_chunk_size: number;

+ 2 - 1
desktop/core/src/desktop/js/reactComponents/FileUploadQueue/FileUploadQueue.tsx

@@ -53,7 +53,8 @@ const sortOrder = [
 const FileUploadQueue: React.FC<FileUploadQueueProps> = ({ filesQueue, onClose, onComplete }) => {
 const FileUploadQueue: React.FC<FileUploadQueueProps> = ({ filesQueue, onClose, onComplete }) => {
   const config = getLastKnownConfig();
   const config = getLastKnownConfig();
   const isChunkUpload =
   const isChunkUpload =
-    config?.storage_browser.enable_chunked_file_uploader ?? DEFAULT_ENABLE_CHUNK_UPLOAD;
+    config?.storage_browser.enable_chunked_file_upload ?? DEFAULT_ENABLE_CHUNK_UPLOAD;
+
   const { t } = i18nReact.useTranslation();
   const { t } = i18nReact.useTranslation();
   const [isExpanded, setIsExpanded] = useState(true);
   const [isExpanded, setIsExpanded] = useState(true);