@@ -17,9 +17,8 @@ import { cn } from "@plane/utils";
1717import { SidebarNavItem } from "@/components/sidebar/sidebar-navigation" ;
1818// hooks
1919import { useAppTheme } from "@/hooks/store/use-app-theme" ;
20- import { useWorkspace } from "@/hooks/store/use-workspace" ;
2120import { useUser , useUserPermissions } from "@/hooks/store/user" ;
22- // plane web imports
21+ import { useWorkspaceNavigationPreferences } from "@/hooks/use-navigation-preferences" ;
2322// local imports
2423import { UpgradeBadge } from "../upgrade-badge" ;
2524import { getSidebarNavigationItemIcon } from "./helper" ;
@@ -50,33 +49,16 @@ export const ExtendedSidebarItem = observer(function ExtendedSidebarItem(props:
5049 const pathname = usePathname ( ) ;
5150 const { workspaceSlug } = useParams ( ) ;
5251 // store hooks
53- const { getNavigationPreferences, updateSidebarPreference } = useWorkspace ( ) ;
5452 const { toggleExtendedSidebar } = useAppTheme ( ) ;
5553 const { data } = useUser ( ) ;
5654 const { allowPermissions } = useUserPermissions ( ) ;
55+ const { preferences : workspacePreferences , toggleWorkspaceItem } = useWorkspaceNavigationPreferences ( ) ;
5756
5857 // derived values
59- const sidebarPreference = getNavigationPreferences ( workspaceSlug . toString ( ) ) ;
60- const isPinned = sidebarPreference ?. [ item . key ] ?. is_pinned ;
58+ const isPinned = workspacePreferences . items [ item . key ] ?. is_pinned ?? false ;
6159
6260 const handleLinkClick = ( ) => toggleExtendedSidebar ( true ) ;
6361
64- const itemHref =
65- item . key === "your_work"
66- ? `/${ workspaceSlug . toString ( ) } ${ item . href } ${ data ?. id } `
67- : `/${ workspaceSlug . toString ( ) } ${ item . href } ` ;
68- const isActive = itemHref === pathname ;
69-
70- const pinNavigationItem = ( workspaceSlug : string , key : string ) => {
71- updateSidebarPreference ( workspaceSlug , key , { is_pinned : true } ) ;
72- } ;
73-
74- const unPinNavigationItem = ( workspaceSlug : string , key : string ) => {
75- updateSidebarPreference ( workspaceSlug , key , { is_pinned : false } ) ;
76- } ;
77-
78- const icon = getSidebarNavigationItemIcon ( item . key ) ;
79-
8062 useEffect ( ( ) => {
8163 const element = navigationIemRef . current ;
8264 const dragHandleElement = dragHandleRef . current ;
@@ -146,14 +128,32 @@ export const ExtendedSidebarItem = observer(function ExtendedSidebarItem(props:
146128 ) ;
147129 } , [ isLastChild , handleOnNavigationItemDrop , disableDrag , disableDrop , item . key ] ) ;
148130
131+ const itemHref =
132+ item . key === "your_work"
133+ ? `/${ workspaceSlug . toString ( ) } ${ item . href } ${ data ?. id } `
134+ : `/${ workspaceSlug . toString ( ) } ${ item . href } ` ;
135+ const isActive = itemHref === pathname ;
136+
137+ const pinNavigationItem = ( key : string ) => {
138+ toggleWorkspaceItem ( key , true ) ;
139+ } ;
140+
141+ const unPinNavigationItem = ( key : string ) => {
142+ toggleWorkspaceItem ( key , false ) ;
143+ } ;
144+
145+ const icon = getSidebarNavigationItemIcon ( item . key ) ;
146+
149147 if ( ! allowPermissions ( item . access as any , EUserPermissionsLevel . WORKSPACE , workspaceSlug . toString ( ) ) ) {
150148 return null ;
151149 }
152150
153151 return (
154152 < div
155153 id = { `sidebar-${ item . key } ` }
156- className = { cn ( "relative" , { "bg-custom-sidebar-background-80 opacity-60" : isDragging } ) }
154+ className = { cn ( "relative" , {
155+ "bg-custom-sidebar-background-80 opacity-60" : isDragging ,
156+ } ) }
157157 ref = { navigationIemRef }
158158 >
159159 < DropIndicator classNames = "absolute top-0" isVisible = { instruction === "DRAG_OVER" } />
@@ -167,15 +167,16 @@ export const ExtendedSidebarItem = observer(function ExtendedSidebarItem(props:
167167 < Tooltip
168168 // isMobile={isMobile}
169169 tooltipContent = { t ( "drag_to_rearrange" ) }
170- position = "top-end "
170+ position = "top-start "
171171 disabled = { isDragging }
172172 >
173173 < button
174174 type = "button"
175175 className = { cn (
176- "flex items-center justify-center absolute top-1/2 -left-3 -translate-y-1/2 rounded text-custom-sidebar-text-400 cursor-grab" ,
176+ "flex items-center justify-center absolute top-1/2 -left-3 -translate-y-1/2 rounded text-custom-sidebar-text-400 cursor-grab group-hover/project-item:opacity-100 opacity-0 " ,
177177 {
178178 "cursor-grabbing" : isDragging ,
179+ "opacity-100" : isDragging ,
179180 }
180181 ) }
181182 ref = { dragHandleRef }
@@ -201,14 +202,14 @@ export const ExtendedSidebarItem = observer(function ExtendedSidebarItem(props:
201202 < Tooltip tooltipContent = "Unpin" >
202203 < PinOff
203204 className = "size-3.5 flex-shrink-0 hover:text-custom-text-300 outline-none text-custom-text-400"
204- onClick = { ( ) => unPinNavigationItem ( workspaceSlug . toString ( ) , item . key ) }
205+ onClick = { ( ) => unPinNavigationItem ( item . key ) }
205206 />
206207 </ Tooltip >
207208 ) : (
208209 < Tooltip tooltipContent = "Pin" >
209210 < Pin
210211 className = "size-3.5 flex-shrink-0 hover:text-custom-text-300 outline-none text-custom-text-400"
211- onClick = { ( ) => pinNavigationItem ( workspaceSlug . toString ( ) , item . key ) }
212+ onClick = { ( ) => pinNavigationItem ( item . key ) }
212213 />
213214 </ Tooltip >
214215 ) }
0 commit comments