import { Popover, Transition } from '@headlessui/react' import { ActionButton } from './ActionButton' import { type IndexLoaderData } from 'lib/types' import { paths } from 'lib/paths' import { isTauri } from '../lib/isTauri' import { Link } from 'react-router-dom' import { Fragment } from 'react' import { sep } from '@tauri-apps/api/path' import { Logo } from './Logo' import { APP_NAME } from 'lib/constants' import { useCommandsContext } from 'hooks/useCommandsContext' import { CustomIcon } from './CustomIcon' import { useLspContext } from './LspProvider' import { engineCommandManager } from 'lib/singletons' const ProjectSidebarMenu = ({ project, file, enableMenu = false, }: { enableMenu?: boolean project?: IndexLoaderData['project'] file?: IndexLoaderData['file'] }) => { return (
{enableMenu ? ( ) : ( {project?.name ? project.name : APP_NAME} )}
) } function AppLogoLink({ project, file, }: { project?: IndexLoaderData['project'] file?: IndexLoaderData['file'] }) { const { onProjectClose } = useLspContext() const wrapperClassName = "relative h-full grid place-content-center group p-1.5 before:block before:content-[''] before:absolute before:inset-0 before:bottom-2.5 before:z-[-1] before:bg-primary before:rounded-b-sm" const logoClassName = 'w-auto h-4 text-chalkboard-10' return isTauri() ? ( { onProjectClose(file || null, project?.path || null, false) // Clear the scene and end the session. engineCommandManager.endSession() }} to={paths.HOME} className={wrapperClassName + ' hover:before:brightness-110'} > {APP_NAME} ) : (
{APP_NAME}
) } function ProjectMenuPopover({ project, file, }: { project?: IndexLoaderData['project'] file?: IndexLoaderData['file'] }) { const { commandBarState, commandBarSend } = useCommandsContext() const { onProjectClose } = useLspContext() const exportCommandInfo = { name: 'Export', ownerMachine: 'modeling' } const findCommand = (obj: { name: string; ownerMachine: string }) => Boolean( commandBarState.context.commands.find( (c) => c.name === obj.name && c.ownerMachine === obj.ownerMachine ) ) return (
{isTauri() && file?.name ? file.name.slice(file.name.lastIndexOf(sep()) + 1) : APP_NAME} {isTauri() && project?.name && ( {project.name} )}
{({ close }) => ( <>
commandBarSend({ type: 'Find and select command', data: exportCommandInfo, }) } > Export Part {isTauri() && ( { onProjectClose(file || null, project?.path || null, true) // Clear the scene and end the session. engineCommandManager.endSession() }} iconStart={{ icon: 'arrowLeft', className: 'p-1', }} className="border-transparent dark:border-transparent" > Go to Home )}
)}
) } export default ProjectSidebarMenu