1- import { usePathname } from "next/navigation" ;
21import {
32 Box ,
43 Button ,
@@ -25,10 +24,11 @@ import React, {
2524} from "react" ;
2625import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter" ;
2726import { extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge" ;
27+ import Image from "next/image" ;
2828import DrawerItemGroup from "./DrawerItemGroup" ;
29- import { DiracLogo } from "./DiracLogo" ;
3029import AppDialog from "./ApplicationDialog" ;
3130import { ApplicationsContext } from "@/contexts/ApplicationsProvider" ;
31+ import { useMUITheme } from "@/hooks/theme" ;
3232
3333interface DashboardDrawerProps {
3434 variant : "permanent" | "temporary" ;
@@ -45,15 +45,12 @@ interface DashboardDrawerProps {
4545 * @returns {JSX.Element } The rendered DashboardDrawer component.
4646 */
4747export default function DashboardDrawer ( props : DashboardDrawerProps ) {
48- // Get the current URL
49- const pathname = usePathname ( ) ;
5048 // Determine the container for the Drawer based on whether the window object exists.
5149 const container =
5250 window !== undefined ? ( ) => window . document . body : undefined ;
5351 // Check if the drawer is in "temporary" mode.
5452 const isTemporary = props . variant === "temporary" ;
55-
56- // Wether the modal for Application Creation is open
53+ // Whether the modal for Application Creation is open
5754 const [ appDialogOpen , setAppDialogOpen ] = useState ( false ) ;
5855
5956 const [ contextMenu , setContextMenu ] = React . useState < {
@@ -73,7 +70,10 @@ export default function DashboardDrawer(props: DashboardDrawerProps) {
7370 // Each section has an associated icon and path.
7471 const [ userSections , setSections ] = useContext ( ApplicationsContext ) ;
7572
73+ const theme = useMUITheme ( ) ;
74+
7675 useEffect ( ( ) => {
76+ // Handle changes to sections when drag and drop occurs.
7777 return monitorForElements ( {
7878 onDrop ( { source, location } ) {
7979 const target = location . current . dropTargets [ 0 ] ;
@@ -84,6 +84,7 @@ export default function DashboardDrawer(props: DashboardDrawerProps) {
8484 const targetData = target . data ;
8585
8686 if ( location . current . dropTargets . length == 2 ) {
87+ // If the target is an item
8788 const groupTitle = targetData . title ;
8889 const closestEdgeOfTarget = extractClosestEdge ( targetData ) ;
8990 const targetIndex = targetData . index as number ;
@@ -105,6 +106,7 @@ export default function DashboardDrawer(props: DashboardDrawerProps) {
105106 destinationIndex ,
106107 ) ;
107108 } else {
109+ // If the target is a group
108110 const groupTitle = targetData . title ;
109111 const sourceGroup = userSections . find (
110112 ( group ) => group . title == sourceData . title ,
@@ -140,13 +142,13 @@ export default function DashboardDrawer(props: DashboardDrawerProps) {
140142 destinationIndex &&
141143 sourceIndex < destinationIndex
142144 ) {
143- destinationIndex -= 1 ;
145+ destinationIndex -= 1 ; // Corrects the index within the same group if needed
144146 }
145147 if (
146148 sourceGroup . title === destinationGroup . title &&
147149 ( destinationIndex == null || sourceIndex === destinationIndex )
148150 ) {
149- return ;
151+ return ; // Nothing to do
150152 }
151153
152154 if ( sourceGroup . title === destinationGroup . title ) {
@@ -195,8 +197,7 @@ export default function DashboardDrawer(props: DashboardDrawerProps) {
195197 /**
196198 * Handles the creation of a new app in the dashboard drawer.
197199 *
198- * @param appName - The name of the app.
199- * @param path - The path of the app.
200+ * @param appType - The type of the app to be created.
200201 * @param icon - The icon component for the app.
201202 */
202203 const handleAppCreation = ( appType : string , icon : ComponentType ) => {
@@ -361,8 +362,20 @@ export default function DashboardDrawer(props: DashboardDrawerProps) {
361362 style = { { display : "flex" , flexDirection : "column" , height : "100%" } }
362363 >
363364 { /* Display the logo in the toolbar section of the drawer. */ }
364- < Toolbar >
365- < DiracLogo />
365+ < Toolbar
366+ sx = { {
367+ position : "sticky" ,
368+ top : "0" ,
369+ zIndex : 1 ,
370+ backgroundColor : theme . palette . background . default ,
371+ } }
372+ >
373+ < Image
374+ src = "/DIRAC-logo.png"
375+ alt = "DIRAC logo"
376+ width = { 150 }
377+ height = { 45 }
378+ />
366379 </ Toolbar >
367380 { /* Map over user sections and render them as list items in the drawer. */ }
368381 < List >
@@ -380,8 +393,17 @@ export default function DashboardDrawer(props: DashboardDrawerProps) {
380393 </ ListItem >
381394 ) ) }
382395 </ List >
383- { /* Render a link to documentation, positioned at the bottom of the drawer. */ }
384- < List sx = { { mt : "auto" } } >
396+
397+ { /* Render a link to documentation and a button to add applications, positioned at the bottom of the drawer. */ }
398+ < List
399+ sx = { {
400+ mt : "auto" ,
401+ position : "sticky" ,
402+ bottom : "0" ,
403+ zIndex : 1 ,
404+ backgroundColor : theme . palette . background . default ,
405+ } }
406+ >
385407 < ListItem key = { "Add application" } >
386408 < ListItemButton onClick = { ( ) => setAppDialogOpen ( true ) } >
387409 < ListItemIcon >
0 commit comments