import { usePathname } from 'next/navigation' import { ComponentProps, ReactNode } from 'react' import { useParams } from 'common' import { useTabsStateSnapshot } from 'state/tabs' import { cn } from 'ui' import { ProjectLayoutWithAuth } from '../ProjectLayout/ProjectLayout' import { CollapseButton } from '../Tabs/CollapseButton' import { EditorTabs } from '../Tabs/Tabs' import { useEditorType } from './EditorsLayout.hooks' export interface ExplorerLayoutProps extends ComponentProps { children: ReactNode title?: string product?: string productMenuClassName?: string } export const EditorBaseLayout = ({ children, title, product, productMenuClassName, productMenu, }: ExplorerLayoutProps) => { const { ref } = useParams() const pathname = usePathname() const editor = useEditorType() const tabs = useTabsStateSnapshot() const hasNoOpenTabs = editor === 'table' ? tabs.openTabs.filter((x) => !x.startsWith('sql')).length === 0 : false const hideTabs = pathname === `/project/${ref}/editor` || pathname === `/project/${ref}/sql` || hasNoOpenTabs return (
{hideTabs ? : }
{children}
) }