@@ -14,26 +14,36 @@ import {
1414 SquaresFour ,
1515} from "@phosphor-icons/react" ;
1616import Link from "next/link" ;
17- import { useParams , useRouter } from "next/navigation" ;
17+ import { useParams , usePathname , useRouter } from "next/navigation" ;
1818import { useMemo , useState } from "react" ;
1919import NavigationProfile from "./nav-profile" ;
20+ import { useSession } from "./session-provider" ;
2021import { useWorkspaces } from "./workspace-provider" ;
2122
2223export function NavigationBar ( ) {
2324 const { currentWorkspace } = useWorkspaces ( ) ;
2425 const { workspaceId } = useParams < { workspaceId : string } > ( ) ;
26+ const pathname = usePathname ( ) ;
27+ const { session } = useSession ( ) ;
2528
2629 return (
2730 < div className = "dark:bg-background relative sticky top-0 z-20 flex h-14 items-center justify-center gap-2 bg-neutral-50 px-2" >
2831 < div className = "text-primary absolute left-0 flex h-14 items-center pl-2" >
29- < Link href = { `/w/${ workspaceId } ` } >
32+ < Link
33+ href = {
34+ pathname !== "/w/local-workspace"
35+ ? `/w/${ workspaceId } `
36+ : "/w/local-workspace"
37+ }
38+ >
3039 < OuterbaseIcon className = "h-8 w-8" />
3140 </ Link >
3241
3342 < Popover >
3443 < PopoverTrigger asChild >
3544 < Button variant = "ghost" >
36- { currentWorkspace ?. name } < CaretUpDown className = "ml-2" />
45+ { currentWorkspace ?. name ?? "Local" }
46+ < CaretUpDown className = "ml-2" />
3747 </ Button >
3848 </ PopoverTrigger >
3949 < PopoverContent className = "h-[400px] w-[500px] p-0" align = "start" >
@@ -42,42 +52,51 @@ export function NavigationBar() {
4252 </ Popover >
4353 </ div >
4454
45- < div className = "flex gap-4 text-base" >
46- < Link
47- href = { `/w/${ workspaceId } ` }
48- className = "flex cursor-pointer items-center gap-1"
49- >
50- < GlobeHemisphereEast weight = "fill" className = "size-5" /> Home
51- </ Link >
52- < Link
53- href = { `/w/${ workspaceId } /settings` }
54- className = "flex cursor-pointer items-center gap-1"
55- >
56- < Gear className = "size-5" />
57- Settings
58- </ Link >
59- < Link
60- href = { `/w/${ workspaceId } /billing` }
61- className = "flex cursor-pointer items-center gap-1"
62- >
63- < Gear className = "size-5" />
64- Billing
65- </ Link >
66- </ div >
55+ { workspaceId && workspaceId !== "local-workspace" && (
56+ < div className = "flex gap-4 text-base" >
57+ < Link
58+ href = { `/w/${ workspaceId } ` }
59+ className = "flex cursor-pointer items-center gap-1"
60+ >
61+ < GlobeHemisphereEast weight = "fill" className = "size-5" /> Home
62+ </ Link >
63+ < Link
64+ href = { `/w/${ workspaceId } /settings` }
65+ className = "flex cursor-pointer items-center gap-1"
66+ >
67+ < Gear className = "size-5" />
68+ Settings
69+ </ Link >
70+ < Link
71+ href = { `/w/${ workspaceId } /billing` }
72+ className = "flex cursor-pointer items-center gap-1"
73+ >
74+ < Gear className = "size-5" />
75+ Billing
76+ </ Link >
77+ </ div >
78+ ) }
6779
6880 < div className = "absolute right-0 flex gap-2 pr-2" >
6981 < div className = "bg-secondary text-secondary-foreground flex h-9 items-center justify-center rounded-lg border px-4 text-base font-semibold" >
7082 Feedback
7183 </ div >
7284
7385 < NavigationProfile />
86+
87+ { ! session && (
88+ < Button href = "/signin" size = "lg" as = "link" >
89+ Sign In
90+ </ Button >
91+ ) }
7492 </ div >
7593 </ div >
7694 ) ;
7795}
7896
7997function WorkspaceSelector ( ) {
8098 const router = useRouter ( ) ;
99+ const { session } = useSession ( ) ;
81100 const { workspaces, currentWorkspace } = useWorkspaces ( ) ;
82101 const { workspaceId } = useParams < { workspaceId : string } > ( ) ;
83102 const [ selectedWorkspaceId , setSelectedWorkspaceId ] = useState ( workspaceId ) ;
@@ -128,7 +147,7 @@ function WorkspaceSelector() {
128147 className = "p-4 font-normal"
129148 size = "sm"
130149 as = "link"
131- href = "/new-workspace"
150+ href = { session ? "/new-workspace" : "/signin" }
132151 >
133152 < SquaresFour size = { 16 } /> New Workspace
134153 </ Button >
0 commit comments