1
1
import { makeStyles } from "@mui/styles"
2
2
import { useMachine } from "@xstate/react"
3
- import { UpdateCheckResponse } from "api/typesGenerated"
4
3
import { DeploymentBanner } from "components/DeploymentBanner/DeploymentBanner"
5
4
import { LicenseBanner } from "components/LicenseBanner/LicenseBanner"
6
5
import { Loader } from "components/Loader/Loader"
7
- import { Margins } from "components/Margins/Margins"
8
6
import { ServiceBanner } from "components/ServiceBanner/ServiceBanner"
9
- import { UpdateCheckBanner } from "components/UpdateCheckBanner/UpdateCheckBanner"
10
7
import { usePermissions } from "hooks/usePermissions"
11
8
import { FC , Suspense } from "react"
12
9
import { Outlet } from "react-router-dom"
13
10
import { dashboardContentBottomPadding } from "theme/constants"
14
11
import { updateCheckMachine } from "xServices/updateCheck/updateCheckXService"
15
12
import { Navbar } from "../Navbar/Navbar"
13
+ import Snackbar from "@mui/material/Snackbar"
14
+ import Link from "@mui/material/Link"
15
+ import Box from "@mui/material/Box"
16
+ import InfoOutlined from "@mui/icons-material/InfoOutlined"
17
+ import Button from "@mui/material/Button"
16
18
17
19
export const DashboardLayout : FC = ( ) => {
18
20
const styles = useStyles ( )
@@ -22,8 +24,7 @@ export const DashboardLayout: FC = () => {
22
24
permissions,
23
25
} ,
24
26
} )
25
- const { error : updateCheckError , updateCheck } = updateCheckState . context
26
-
27
+ const { updateCheck } = updateCheckState . context
27
28
const canViewDeployment = Boolean ( permissions . viewDeploymentValues )
28
29
29
30
return (
@@ -34,48 +35,80 @@ export const DashboardLayout: FC = () => {
34
35
< div className = { styles . site } >
35
36
< Navbar />
36
37
37
- { updateCheckState . matches ( "show" ) && (
38
- < div className = { styles . updateCheckBanner } >
39
- < Margins >
40
- < UpdateCheckBanner
41
- // We can trust when it is show, the update check is filled
42
- // unfortunately, XState does not has typed state - context yet
43
- updateCheck = { updateCheck as UpdateCheckResponse }
44
- error = { updateCheckError }
45
- onDismiss = { ( ) => updateCheckSend ( "DISMISS" ) }
46
- />
47
- </ Margins >
48
- </ div >
49
- ) }
50
-
51
38
< div className = { styles . siteContent } >
52
39
< Suspense fallback = { < Loader /> } >
53
40
< Outlet />
54
41
</ Suspense >
55
42
</ div >
56
43
57
44
< DeploymentBanner />
45
+
46
+ < Snackbar
47
+ data-testid = "update-check-snackbar"
48
+ open = { updateCheckState . matches ( "show" ) }
49
+ anchorOrigin = { {
50
+ vertical : "bottom" ,
51
+ horizontal : "right" ,
52
+ } }
53
+ ContentProps = { {
54
+ sx : ( theme ) => ( {
55
+ background : theme . palette . background . paper ,
56
+ color : theme . palette . text . primary ,
57
+ maxWidth : theme . spacing ( 55 ) ,
58
+ flexDirection : "row" ,
59
+ borderColor : theme . palette . info . light ,
60
+
61
+ "& .MuiSnackbarContent-message" : {
62
+ flex : 1 ,
63
+ } ,
64
+
65
+ "& .MuiSnackbarContent-action" : {
66
+ marginRight : 0 ,
67
+ } ,
68
+ } ) ,
69
+ } }
70
+ message = {
71
+ < Box display = "flex" gap = { 2 } >
72
+ < InfoOutlined
73
+ sx = { ( theme ) => ( {
74
+ fontSize : 16 ,
75
+ height : 20 , // 20 is the height of the text line so we can align them
76
+ color : theme . palette . info . light ,
77
+ } ) }
78
+ />
79
+ < Box >
80
+ Coder { updateCheck ?. version } is now available. View the{ " " }
81
+ < Link href = { updateCheck ?. url } > release notes</ Link > and{ " " }
82
+ < Link href = "https://coder.com/docs/coder-oss/latest/admin/upgrade" >
83
+ upgrade instructions
84
+ </ Link > { " " }
85
+ for more information.
86
+ </ Box >
87
+ </ Box >
88
+ }
89
+ action = {
90
+ < Button
91
+ variant = "text"
92
+ size = "small"
93
+ onClick = { ( ) => updateCheckSend ( "DISMISS" ) }
94
+ >
95
+ Dismiss
96
+ </ Button >
97
+ }
98
+ />
58
99
</ div >
59
100
</ >
60
101
)
61
102
}
62
103
63
- const useStyles = makeStyles ( ( theme ) => ( {
104
+ const useStyles = makeStyles ( {
64
105
site : {
65
106
display : "flex" ,
66
107
minHeight : "100vh" ,
67
108
flexDirection : "column" ,
68
109
} ,
69
- updateCheckBanner : {
70
- // Add spacing at the top and remove some from the bottom. Removal
71
- // is necessary to avoid a visual jerk when the banner is dismissed.
72
- // It also give a more pleasant distance to the site content when
73
- // the banner is visible.
74
- marginTop : theme . spacing ( 2 ) ,
75
- marginBottom : theme . spacing ( - 2 ) ,
76
- } ,
77
110
siteContent : {
78
111
flex : 1 ,
79
112
paddingBottom : dashboardContentBottomPadding , // Add bottom space since we don't use a footer
80
113
} ,
81
- } ) )
114
+ } )
0 commit comments