import clsx from 'clsx'; import { toast } from 'react-toastify'; import { useAuth } from '@/backend/auth/useAuth'; import { useLibrary } from '@/backend/library/useLibrary'; 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 useWindowSize from '@/hooks/useWindowSize'; import { FolderNode } from '@/models/FolderTree'; import { HelpTopic } from '@/models/miscellaneous'; import { useFitHeight } from '@/stores/appLayout'; import { useLibrarySearchStore } from '@/stores/librarySearch'; import { PARAMETER, prefixes } from '@/utils/constants'; import { information } from '@/utils/labels'; interface ViewSideLocationProps { isVisible: boolean; onRenameLocation: () => void; } function ViewSideLocation({ isVisible, onRenameLocation }: ViewSideLocationProps) { const { user } = useAuth(); const { items } = useLibrary(); const windowSize = useWindowSize(); const location = useLibrarySearchStore(state => state.location); const setLocation = useLibrarySearchStore(state => state.setLocation); const toggleFolderMode = useLibrarySearchStore(state => state.toggleFolderMode); const subfolders = useLibrarySearchStore(state => state.subfolders); const toggleSubfolders = useLibrarySearchStore(state => state.toggleSubfolders); const canRename = (() => { if (location.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 == location || item.location.startsWith(`${location}/`)); return located.length !== 0; })(); const maxHeight = useFitHeight('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 { setLocation(target.getPath()); } } return (