feat: Dokploy-style sidebar layout for site pages
Sidebar takes full viewport height with Pulse logo at top. No Header on site pages — UtilityBar in content area provides theme toggle, app launcher, notifications, and user menu. Non-site authenticated pages keep static Header. No footer on dashboard pages.
This commit is contained in:
@@ -8,6 +8,7 @@ import { useAuth } from '@/lib/auth/context'
|
||||
import { useOnlineStatus } from '@/lib/hooks/useOnlineStatus'
|
||||
import Link from 'next/link'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { usePathname } from 'next/navigation'
|
||||
import { logger } from '@/lib/utils/logger'
|
||||
import { getUserOrganizations, switchContext, type OrganizationMember } from '@/lib/api/organization'
|
||||
import { setSessionAction } from '@/app/actions/auth'
|
||||
@@ -15,11 +16,10 @@ import { LoadingOverlay } from '@ciphera-net/ui'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { SettingsModalProvider, useSettingsModal } from '@/lib/settings-modal-context'
|
||||
import SettingsModalWrapper from '@/components/settings/SettingsModalWrapper'
|
||||
import { SidebarProvider, useSidebar } from '@/lib/sidebar-context'
|
||||
import { SidebarProvider } from '@/lib/sidebar-context'
|
||||
|
||||
const ORG_SWITCH_KEY = 'pulse_switching_org'
|
||||
|
||||
// * Available Ciphera apps for the app switcher
|
||||
const CIPHERA_APPS: CipheraApp[] = [
|
||||
{
|
||||
id: 'pulse',
|
||||
@@ -27,7 +27,7 @@ const CIPHERA_APPS: CipheraApp[] = [
|
||||
description: 'Your current app — Privacy-first analytics',
|
||||
icon: 'https://ciphera.net/pulse_icon_no_margins.png',
|
||||
href: 'https://pulse.ciphera.net',
|
||||
isAvailable: false, // * Current app
|
||||
isAvailable: false,
|
||||
},
|
||||
{
|
||||
id: 'drop',
|
||||
@@ -47,22 +47,10 @@ const CIPHERA_APPS: CipheraApp[] = [
|
||||
},
|
||||
]
|
||||
|
||||
function MobileSidebarToggle() {
|
||||
const { openMobile } = useSidebar()
|
||||
return (
|
||||
<button
|
||||
onClick={openMobile}
|
||||
className="lg:hidden p-2 text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white transition-colors"
|
||||
aria-label="Open navigation"
|
||||
>
|
||||
<MenuIcon className="w-5 h-5" />
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
function LayoutInner({ children }: { children: React.ReactNode }) {
|
||||
const auth = useAuth()
|
||||
const router = useRouter()
|
||||
const pathname = usePathname()
|
||||
const isOnline = useOnlineStatus()
|
||||
const { openSettings } = useSettingsModal()
|
||||
const [orgs, setOrgs] = useState<OrganizationMember[]>([])
|
||||
@@ -71,7 +59,6 @@ function LayoutInner({ children }: { children: React.ReactNode }) {
|
||||
return sessionStorage.getItem(ORG_SWITCH_KEY) === 'true'
|
||||
})
|
||||
|
||||
// * Clear the switching flag once the page has settled after reload
|
||||
useEffect(() => {
|
||||
if (isSwitchingOrg) {
|
||||
sessionStorage.removeItem(ORG_SWITCH_KEY)
|
||||
@@ -80,7 +67,6 @@ function LayoutInner({ children }: { children: React.ReactNode }) {
|
||||
}
|
||||
}, [isSwitchingOrg])
|
||||
|
||||
// * Fetch organizations for the header organization switcher
|
||||
useEffect(() => {
|
||||
if (auth.user) {
|
||||
getUserOrganizations()
|
||||
@@ -90,7 +76,7 @@ function LayoutInner({ children }: { children: React.ReactNode }) {
|
||||
}, [auth.user])
|
||||
|
||||
const handleSwitchOrganization = async (orgId: string | null) => {
|
||||
if (!orgId) return // Pulse doesn't support personal organization context
|
||||
if (!orgId) return
|
||||
try {
|
||||
const { access_token } = await switchContext(orgId)
|
||||
await setSessionAction(access_token)
|
||||
@@ -101,69 +87,83 @@ function LayoutInner({ children }: { children: React.ReactNode }) {
|
||||
}
|
||||
}
|
||||
|
||||
const handleCreateOrganization = () => {
|
||||
router.push('/onboarding')
|
||||
}
|
||||
|
||||
const isAuthenticated = !!auth.user
|
||||
const showOfflineBar = Boolean(auth.user && !isOnline)
|
||||
// Site pages use DashboardShell with full sidebar — no Header needed
|
||||
const isSitePage = pathname.startsWith('/sites/') && pathname !== '/sites/new'
|
||||
|
||||
if (isSwitchingOrg) {
|
||||
return <LoadingOverlay logoSrc="/pulse_icon_no_margins.png" title="Pulse" portal={false} />
|
||||
}
|
||||
|
||||
const headerElement = (
|
||||
<Header
|
||||
auth={auth}
|
||||
LinkComponent={Link}
|
||||
logoSrc="/pulse_icon_no_margins.png"
|
||||
appName="Pulse"
|
||||
variant={isAuthenticated ? 'static' : 'floating'}
|
||||
orgs={orgs}
|
||||
activeOrgId={auth.user?.org_id}
|
||||
onSwitchOrganization={handleSwitchOrganization}
|
||||
onCreateOrganization={handleCreateOrganization}
|
||||
allowPersonalOrganization={false}
|
||||
showFaq={false}
|
||||
showSecurity={false}
|
||||
showPricing={true}
|
||||
topOffset={!isAuthenticated && showOfflineBar ? '2.5rem' : undefined}
|
||||
rightSideActions={auth.user ? <NotificationCenter /> : null}
|
||||
apps={CIPHERA_APPS}
|
||||
currentAppId="pulse"
|
||||
onOpenSettings={openSettings}
|
||||
leftActions={isAuthenticated ? <MobileSidebarToggle /> : undefined}
|
||||
customNavItems={
|
||||
<>
|
||||
{!auth.user && (
|
||||
<Link
|
||||
href="/features"
|
||||
className="px-4 py-2 text-sm font-medium text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white rounded-lg hover:bg-neutral-100/50 dark:hover:bg-neutral-800/50 transition-all duration-200"
|
||||
>
|
||||
Features
|
||||
</Link>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
/>
|
||||
)
|
||||
|
||||
if (isAuthenticated) {
|
||||
// Dashboard layout: header pinned, sidebar + content fill remaining viewport
|
||||
// Authenticated site pages: full Dokploy-style layout (sidebar + utility bar)
|
||||
// DashboardShell inside children handles everything
|
||||
if (isAuthenticated && isSitePage) {
|
||||
return (
|
||||
<div className="flex flex-col h-screen overflow-hidden">
|
||||
{auth.user && <OfflineBanner isOnline={isOnline} />}
|
||||
<div className="shrink-0">{headerElement}</div>
|
||||
<>
|
||||
{showOfflineBar && <OfflineBanner isOnline={isOnline} />}
|
||||
{children}
|
||||
<SettingsModalWrapper />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
// Authenticated non-site pages (sites list, onboarding, etc.): static header
|
||||
if (isAuthenticated) {
|
||||
return (
|
||||
<div className="flex flex-col min-h-screen">
|
||||
{showOfflineBar && <OfflineBanner isOnline={isOnline} />}
|
||||
<Header
|
||||
auth={auth}
|
||||
LinkComponent={Link}
|
||||
logoSrc="/pulse_icon_no_margins.png"
|
||||
appName="Pulse"
|
||||
variant="static"
|
||||
orgs={orgs}
|
||||
activeOrgId={auth.user?.org_id}
|
||||
onSwitchOrganization={handleSwitchOrganization}
|
||||
onCreateOrganization={() => router.push('/onboarding')}
|
||||
allowPersonalOrganization={false}
|
||||
showFaq={false}
|
||||
showSecurity={false}
|
||||
showPricing={false}
|
||||
rightSideActions={<NotificationCenter />}
|
||||
apps={CIPHERA_APPS}
|
||||
currentAppId="pulse"
|
||||
onOpenSettings={openSettings}
|
||||
/>
|
||||
<main className="flex-1 pb-8">
|
||||
{children}
|
||||
</main>
|
||||
<SettingsModalWrapper />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// Public/marketing layout: floating header, scrollable page, footer
|
||||
// Public/marketing: floating header + footer
|
||||
return (
|
||||
<div className="flex flex-col min-h-screen">
|
||||
{headerElement}
|
||||
<Header
|
||||
auth={auth}
|
||||
LinkComponent={Link}
|
||||
logoSrc="/pulse_icon_no_margins.png"
|
||||
appName="Pulse"
|
||||
variant="floating"
|
||||
showFaq={false}
|
||||
showSecurity={false}
|
||||
showPricing={true}
|
||||
topOffset={showOfflineBar ? '2.5rem' : undefined}
|
||||
apps={CIPHERA_APPS}
|
||||
currentAppId="pulse"
|
||||
customNavItems={
|
||||
<Link
|
||||
href="/features"
|
||||
className="px-4 py-2 text-sm font-medium text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white rounded-lg hover:bg-neutral-100/50 dark:hover:bg-neutral-800/50 transition-all duration-200"
|
||||
>
|
||||
Features
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
<main className="flex-1 pb-8 pt-24">
|
||||
{children}
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user