1
+ import Link from "@material-ui/core/Link"
2
+ import { makeStyles } from "@material-ui/core/styles"
1
3
import { useMachine , useSelector } from "@xstate/react"
2
4
import { DeleteDialog } from "components/Dialogs/DeleteDialog/DeleteDialog"
5
+ import { ErrorSummary } from "components/ErrorSummary/ErrorSummary"
6
+ import { Margins } from "components/Margins/Margins"
7
+ import { Stack } from "components/Stack/Stack"
3
8
import { FC , useContext } from "react"
4
9
import { Helmet } from "react-helmet-async"
5
10
import { useTranslation } from "react-i18next"
@@ -22,7 +27,24 @@ const useTemplateName = () => {
22
27
return template
23
28
}
24
29
30
+ // const Language = {
31
+ // emptyMessage: "Template not found",
32
+ // emptyDescription: (
33
+ // <>
34
+ // You can view available templates{" "}
35
+ // <Link target="_blank" href="https://coder.com/docs/coder-oss/latest/templates">
36
+ // here
37
+ // </Link>{" "}
38
+ // or you can{" "}
39
+ // <Link target="_blank" href="https://coder.com/docs/coder-oss/latest/templates">
40
+ // create one from scratch.
41
+ // </Link>
42
+ // </>
43
+ // ),
44
+ // }
45
+
25
46
export const TemplatePage : FC < React . PropsWithChildren < unknown > > = ( ) => {
47
+ const styles = useStyles ( )
26
48
const organizationId = useOrganizationId ( )
27
49
const { t } = useTranslation ( "templatePage" )
28
50
const templateName = useTemplateName ( )
@@ -40,6 +62,7 @@ export const TemplatePage: FC<React.PropsWithChildren<unknown>> = () => {
40
62
templateVersions,
41
63
deleteTemplateError,
42
64
templateDAUs,
65
+ getTemplateError,
43
66
} = templateState . context
44
67
const xServices = useContext ( XServiceContext )
45
68
const permissions = useSelector ( xServices . authXService , selectPermissions )
@@ -57,6 +80,16 @@ export const TemplatePage: FC<React.PropsWithChildren<unknown>> = () => {
57
80
// site/src/xServices/template/templateXService.ts
58
81
// For an example, look here: site/src/xServices/workspaces/workspacesXService.ts
59
82
// displayError is the function we want to use
83
+ // const templateFound = false
84
+ if ( templateState . matches ( "error" ) && Boolean ( getTemplateError ) ) {
85
+ return (
86
+ < Margins >
87
+ < div className = { styles . errorBox } >
88
+ < ErrorSummary error = { getTemplateError } />
89
+ </ div >
90
+ </ Margins >
91
+ )
92
+ }
60
93
61
94
if ( isLoading ) {
62
95
return < Loader />
@@ -98,4 +131,10 @@ export const TemplatePage: FC<React.PropsWithChildren<unknown>> = () => {
98
131
)
99
132
}
100
133
134
+ const useStyles = makeStyles ( ( theme ) => ( {
135
+ errorBox : {
136
+ padding : theme . spacing ( 3 ) ,
137
+ } ,
138
+ } ) )
139
+
101
140
export default TemplatePage
0 commit comments