import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faFileAlt, faFileArchive, faFileImport, faFolder } from '@fortawesome/free-solid-svg-icons'; import { differenceInHours, format, formatDistanceToNow } from 'date-fns'; import type { ReactNode } from 'react'; import { memo } from 'react'; import isEqual from 'react-fast-compare'; import { NavLink } from 'react-router-dom'; import tw from 'twin.macro'; import { join } from 'pathe'; import type { FileObject } from '@/api/server/files/loadDirectory'; import FileDropdownMenu from '@/components/server/files/FileDropdownMenu'; import SelectFileCheckbox from '@/components/server/files/SelectFileCheckbox'; import { encodePathSegments } from '@/helpers'; import { bytesToString } from '@/lib/formatters'; import { usePermissions } from '@/plugins/usePermissions'; import { ServerContext } from '@/state/server'; import styles from './style.module.css'; function Clickable({ file, children }: { file: FileObject; children: ReactNode }) { const [canReadContents] = usePermissions(['file.read-content']); const id = ServerContext.useStoreState(state => state.server.data!.id); const directory = ServerContext.useStoreState(state => state.files.directory); return !canReadContents || (file.isFile && !file.isEditable()) ? (