import clsx from 'clsx'; import { toast } from 'react-toastify'; import { SubfoldersIcon } from '@/components/DomainIcons'; import { IconFolderEdit, IconFolderTree } from '@/components/Icons'; import BadgeHelp from '@/components/info/BadgeHelp'; import { CProps } from '@/components/props'; import SelectLocation from '@/components/select/SelectLocation'; import MiniButton from '@/components/ui/MiniButton'; import { useAuth } from '@/context/AuthContext'; import { useConceptOptions } from '@/context/ConceptOptionsContext'; import { useLibrary } from '@/context/LibraryContext'; import useWindowSize from '@/hooks/useWindowSize'; import { FolderNode, FolderTree } from '@/models/FolderTree'; import { HelpTopic } from '@/models/miscellaneous'; import { PARAMETER, prefixes } from '@/utils/constants'; import { information } from '@/utils/labels'; interface ViewSideLocationProps { folderTree: FolderTree; isVisible: boolean; subfolders: boolean; activeLocation: string; onChangeActiveLocation: (newValue: string) => void; toggleFolderMode: () => void; toggleSubfolders: () => void; onRenameLocation: () => void; } function ViewSideLocation({ folderTree, activeLocation, subfolders, isVisible, onChangeActiveLocation, toggleFolderMode, toggleSubfolders, onRenameLocation }: ViewSideLocationProps) { const { user } = useAuth(); const { items } = useLibrary(); const { calculateHeight } = useConceptOptions(); const windowSize = useWindowSize(); const canRename = (() => { if (activeLocation.length <= 3 || !user) { return false; } if (user.is_staff) { return true; } const owned = items.filter(item => item.owner == user.id); const located = owned.filter( item => item.location == activeLocation || item.location.startsWith(`${activeLocation}/`) ); return located.length !== 0; })(); const maxHeight = calculateHeight('4.5rem'); function handleClickFolder(event: CProps.EventMouse, target: FolderNode) { event.preventDefault(); event.stopPropagation(); if (event.ctrlKey || event.metaKey) { navigator.clipboard .writeText(target.getPath()) .then(() => toast.success(information.pathReady)) .catch(console.error); } else { onChangeActiveLocation(target.getPath()); } } return (
{canRename ? ( } titleHtml='Редактирование пути
Перемещаются только Ваши схемы
в указанной папке (и подпапках)' onClick={onRenameLocation} /> ) : null} {!!activeLocation ? ( } onClick={toggleSubfolders} /> ) : null} } title='Переключение в режим Поиск' onClick={toggleFolderMode} />
); } export default ViewSideLocation;