1
+ import React , { Component } from 'react' ;
1
2
import { useResourceDefinitions } from "ra-core" ;
2
3
import { DashboardMenuItem } from "ra-ui-materialui" ;
3
4
import { Menu } from "react-admin" ;
4
- import { ThemeProvider , createTheme } from "@mui/material" ;
5
- import { Component } from "react" ;
5
+ import { ThemeProvider , createTheme , Tooltip , Box , Typography } from "@mui/material" ;
6
6
7
7
/**
8
8
* A custom menu as defined in React Admin for selecting the query the user whishes to execute.
@@ -12,13 +12,25 @@ function SelectionMenu() {
12
12
const resources = useResourceDefinitions ( ) ;
13
13
return (
14
14
< ThemeProvider theme = { menuItemTheme } >
15
- < div style = { { height : '100%' , overflowY : 'auto' } } >
16
- < Menu >
17
- < DashboardMenuItem />
18
- { Object . keys ( resources ) . map ( ( id ) => (
19
- < Menu . ResourceItem key = { id } name = { id } />
20
- ) ) }
21
- </ Menu >
15
+ < div style = { { height : '100%' , overflowY : 'auto' , backgroundColor : 'white' } } >
16
+ < Menu >
17
+ < DashboardMenuItem />
18
+ { Object . keys ( resources ) . map ( ( id ) => (
19
+ < Tooltip
20
+ key = { id }
21
+ placement = "right"
22
+ title = {
23
+ < TooltipContent
24
+ title = { resources [ id ] . options . label }
25
+ description = { resources [ id ] . options . descr } />
26
+ }
27
+ >
28
+ < div >
29
+ < Menu . ResourceItem name = { id } />
30
+ </ div >
31
+ </ Tooltip >
32
+ ) ) }
33
+ </ Menu >
22
34
</ div >
23
35
</ ThemeProvider >
24
36
) ;
@@ -39,15 +51,43 @@ const menuItemTheme = createTheme({
39
51
verticalAlign : "middle" ,
40
52
} ,
41
53
"&:hover" : {
42
- display : "inline-flex" ,
43
- overflow : "visible" ,
44
- whiteSpace : "normal" ,
45
- minWidth : "fit-content" ,
54
+ display : "block" ,
55
+ whiteSpace : "nowrap" ,
56
+ textOverflow : "ellipsis" ,
46
57
}
47
58
} ,
48
59
} ,
49
60
}
50
61
} ,
51
62
} ) ;
52
63
64
+
65
+ const TooltipContent = ( { title, description } ) => (
66
+ < React . Fragment >
67
+ < Box
68
+ sx = { {
69
+ width : 'fit-content' ,
70
+ backgroundColor : '#6d6d6d' ,
71
+ paddingX : 1 ,
72
+ marginX : - 1 ,
73
+
74
+ } }
75
+ >
76
+ < Typography variant = "h6" component = "div" >
77
+ { title }
78
+ </ Typography >
79
+
80
+ < Typography variant = "body2" component = "div"
81
+ sx = { {
82
+ fontStyle : 'italic' ,
83
+ marginTop : 1 ,
84
+ } }
85
+ >
86
+ { description }
87
+ </ Typography >
88
+ </ Box >
89
+ </ React . Fragment >
90
+ )
91
+
92
+
53
93
export default SelectionMenu ;
0 commit comments