import type { IWebdavNode } from '@rocket.chat/core-typings'; import { Box, Icon } from '@rocket.chat/fuselage'; import { GenericTable, GenericTableBody, GenericTableCell, GenericTableHeader, GenericTableHeaderCell, GenericTableLoadingRow, GenericTableRow, } from '@rocket.chat/ui-client'; import { useTranslation } from 'react-i18next'; import type { WebdavSortOptions } from './WebdavFilePickerModal'; import { getNodeFileSize } from './lib/getNodeFileSize'; import { getNodeIconType } from './lib/getNodeIconType'; import GenericNoResults from '../../../../components/GenericNoResults'; import { timeAgo } from '../../../../lib/utils/timeAgo'; export type WebdavFilePickerTableProps = { webdavNodes: IWebdavNode[]; sortBy: string; sortDirection: 'asc' | 'desc'; onSort: (sortBy: WebdavSortOptions, sortDirection?: 'asc' | 'desc') => void; onNodeClick: (webdavNode: IWebdavNode) => void; isLoading: boolean; }; const WebdavFilePickerTable = ({ webdavNodes, sortBy, sortDirection, onSort, onNodeClick, isLoading }: WebdavFilePickerTableProps) => { const { t } = useTranslation(); return ( {(isLoading || webdavNodes?.length > 0) && ( {t('Name')} {t('Size')} {t('Data_modified')} {isLoading && Array(5) .fill('') .map((_, index) => )} {!isLoading && webdavNodes?.map((webdavNode, index) => { const { icon } = getNodeIconType(webdavNode.basename, webdavNode.type, webdavNode.mime); return ( onNodeClick(webdavNode)} tabIndex={index} role='link' action> {webdavNode.basename} {getNodeFileSize(webdavNode.type, webdavNode?.size)} {timeAgo(new Date())} ); })} )} {!isLoading && webdavNodes?.length === 0 && } ); }; export default WebdavFilePickerTable;