import clsx from 'clsx'; import { toast } from 'react-toastify'; import { MiniButton } from '@/components/Control'; import { SubfoldersIcon } from '@/components/DomainIcons'; import { IconFolderEdit, IconFolderTree } from '@/components/Icons'; import { CProps } from '@/components/props'; import { useAuthSuspense } from '@/features/auth'; import { BadgeHelp, HelpTopic } from '@/features/help'; import { FolderNode } from '@/features/library/models/FolderTree'; import useWindowSize from '@/hooks/useWindowSize'; import { useFitHeight } from '@/stores/appLayout'; import { PARAMETER, prefixes } from '@/utils/constants'; import { infoMsg } from '@/utils/labels'; import { useLibrary } from '../../backend/useLibrary'; import SelectLocation from '../../components/SelectLocation'; import { useLibrarySearchStore } from '../../stores/librarySearch'; interface ViewSideLocationProps { isVisible: boolean; onRenameLocation: () => void; } function ViewSideLocation({ isVisible, onRenameLocation }: ViewSideLocationProps) { const { user, isAnonymous } = useAuthSuspense(); 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 || isAnonymous) { 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(infoMsg.pathReady)) .catch(console.error); } else { setLocation(target.getPath()); } } return (