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 { FileTree } from './FileTree' 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, renderAsLink = false, }: { renderAsLink?: boolean project?: IndexLoaderData['project'] file?: IndexLoaderData['file'] }) => { const { onProjectClose } = useLspContext() return (
{ onProjectClose(file || null, project?.path || null, false) // Clear the scene and end the session. engineCommandManager.endSession() }} to={paths.HOME} className="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 hover:before:brightness-110 before:rounded-b-sm" > {renderAsLink ? ( <> { onProjectClose(file || null, project?.path || null, false) // Clear the scene and end the session. engineCommandManager.endSession() }} to={paths.HOME} className="!no-underline" data-testid="project-sidebar-link" > {project?.name ? project.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 }) => ( <>

{project?.name ? project.name : APP_NAME}

{project?.metadata && project.metadata.created && (

Created{' '} {new Date(project.metadata.created).toLocaleDateString()}

)}
{isTauri() ? ( ) : (

In the browser version of Modeling App you can only have one part, and the code is stored in your browser's storage.

Please save any code you want to keep more permanently, as your browser's storage is not guaranteed to be permanent.

)}
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