1
1
import { type CSSObject , useTheme } from "@emotion/react" ;
2
2
import AddIcon from "@mui/icons-material/AddOutlined" ;
3
3
import Button from "@mui/material/Button" ;
4
+ import Link from "@mui/material/Link" ;
4
5
import Table from "@mui/material/Table" ;
5
6
import TableBody from "@mui/material/TableBody" ;
6
7
import TableCell from "@mui/material/TableCell" ;
@@ -16,13 +17,14 @@ import { NotificationBannerDialog } from "./NotificationBannerDialog";
16
17
import { NotificationBannerItem } from "./NotificationBannerItem" ;
17
18
18
19
interface NotificationBannerSettingsProps {
20
+ isEntitled : boolean ;
19
21
notificationBanners : readonly BannerConfig [ ] ;
20
22
onSubmit : ( banners : readonly BannerConfig [ ] ) => Promise < void > ;
21
23
}
22
24
23
25
export const NotificationBannerSettings : FC <
24
26
NotificationBannerSettingsProps
25
- > = ( { notificationBanners, onSubmit } ) => {
27
+ > = ( { isEntitled , notificationBanners, onSubmit } ) => {
26
28
const theme = useTheme ( ) ;
27
29
const [ banners , setBanners ] = useState ( notificationBanners ) ;
28
30
const [ editingBannerId , setEditingBannerId ] = useState < number | null > ( null ) ;
@@ -60,73 +62,97 @@ export const NotificationBannerSettings: FC<
60
62
borderRadius : 8 ,
61
63
border : `1px solid ${ theme . palette . divider } ` ,
62
64
marginTop : 32 ,
63
- padding : 24 ,
65
+ overflow : "hidden" ,
64
66
} }
65
67
>
66
- < Stack
67
- direction = "row"
68
- justifyContent = "space-between"
69
- alignItems = "center"
70
- >
71
- < h3
68
+ < div css = { { padding : 24 } } >
69
+ < Stack
70
+ direction = "row"
71
+ justifyContent = "space-between"
72
+ alignItems = "center"
73
+ >
74
+ < h3
75
+ css = { {
76
+ fontSize : 20 ,
77
+ margin : 0 ,
78
+ fontWeight : 600 ,
79
+ } }
80
+ >
81
+ Notification Banners
82
+ </ h3 >
83
+ < Button
84
+ disabled = { ! isEntitled }
85
+ onClick = { ( ) => addBanner ( ) }
86
+ startIcon = { < AddIcon /> }
87
+ >
88
+ New
89
+ </ Button >
90
+ </ Stack >
91
+ < div
72
92
css = { {
73
- fontSize : 20 ,
74
- margin : 0 ,
75
- fontWeight : 600 ,
93
+ color : theme . palette . text . secondary ,
94
+ fontSize : 14 ,
95
+ marginTop : 8 ,
76
96
} }
77
97
>
78
- Notification Banners
79
- </ h3 >
80
- < Button onClick = { ( ) => addBanner ( ) } startIcon = { < AddIcon /> } >
81
- New
82
- </ Button >
83
- </ Stack >
84
- < div
85
- css = { {
86
- color : theme . palette . text . secondary ,
87
- fontSize : 14 ,
88
- marginTop : 8 ,
89
- } }
90
- >
91
- Display message banners to all users.
92
- </ div >
98
+ Display message banners to all users.
99
+ </ div >
93
100
94
- < div css = { [ theme . typography . body2 as CSSObject , { paddingTop : 16 } ] } >
95
- < TableContainer >
96
- < Table >
97
- < TableHead >
98
- < TableRow >
99
- < TableCell width = "1%" > Enabled</ TableCell >
100
- < TableCell > Message</ TableCell >
101
- < TableCell > Color</ TableCell >
102
- < TableCell width = "1%" />
103
- </ TableRow >
104
- </ TableHead >
105
- < TableBody >
106
- { banners . length < 1 ? (
107
- < TableCell colSpan = { 999 } >
108
- < EmptyState message = "No notification banners" />
109
- </ TableCell >
110
- ) : (
111
- banners . map ( ( banner , i ) => (
112
- < NotificationBannerItem
113
- key = { banner . message }
114
- enabled = { banner . enabled }
115
- backgroundColor = { banner . background_color }
116
- message = { banner . message }
117
- onEdit = { ( ) => setEditingBannerId ( i ) }
118
- onUpdate = { async ( banner ) => {
119
- const newBanners = updateBanner ( i , banner ) ;
120
- await onSubmit ( newBanners ) ;
121
- } }
122
- onDelete = { ( ) => setDeletingBannerId ( i ) }
123
- />
124
- ) )
125
- ) }
126
- </ TableBody >
127
- </ Table >
128
- </ TableContainer >
101
+ < div css = { [ theme . typography . body2 as CSSObject , { paddingTop : 16 } ] } >
102
+ < TableContainer >
103
+ < Table >
104
+ < TableHead >
105
+ < TableRow >
106
+ < TableCell width = "1%" > Enabled</ TableCell >
107
+ < TableCell > Message</ TableCell >
108
+ < TableCell > Color</ TableCell >
109
+ < TableCell width = "1%" />
110
+ </ TableRow >
111
+ </ TableHead >
112
+ < TableBody >
113
+ { ! isEntitled || banners . length < 1 ? (
114
+ < TableCell colSpan = { 999 } >
115
+ < EmptyState message = "No notification banners" />
116
+ </ TableCell >
117
+ ) : (
118
+ banners . map ( ( banner , i ) => (
119
+ < NotificationBannerItem
120
+ key = { banner . message }
121
+ enabled = { banner . enabled }
122
+ backgroundColor = { banner . background_color }
123
+ message = { banner . message }
124
+ onEdit = { ( ) => setEditingBannerId ( i ) }
125
+ onUpdate = { async ( banner ) => {
126
+ const newBanners = updateBanner ( i , banner ) ;
127
+ await onSubmit ( newBanners ) ;
128
+ } }
129
+ onDelete = { ( ) => setDeletingBannerId ( i ) }
130
+ />
131
+ ) )
132
+ ) }
133
+ </ TableBody >
134
+ </ Table >
135
+ </ TableContainer >
136
+ </ div >
129
137
</ div >
138
+
139
+ < footer
140
+ css = { [
141
+ theme . typography . body2 as CSSObject ,
142
+ {
143
+ background : theme . palette . background . paper ,
144
+ padding : "16px 24px" ,
145
+ } ,
146
+ ] }
147
+ >
148
+ < div css = { { color : theme . palette . text . secondary } } >
149
+ < p >
150
+ Your license does not include Service Banners.{ " " }
151
+ < Link href = "mailto:sales@coder.com" > Contact sales</ Link > to learn
152
+ more.
153
+ </ p >
154
+ </ div >
155
+ </ footer >
130
156
</ div >
131
157
132
158
{ editingBanner && (
0 commit comments