@@ -41,6 +41,7 @@ export interface TemplatePageViewProps {
41
41
templateVersions ?: TemplateVersion [ ]
42
42
handleDeleteTemplate : ( templateId : string ) => void
43
43
deleteTemplateError : Error | unknown
44
+ canDeleteTemplate : boolean
44
45
}
45
46
46
47
export const TemplatePageView : FC < React . PropsWithChildren < TemplatePageViewProps > > = ( {
@@ -50,6 +51,7 @@ export const TemplatePageView: FC<React.PropsWithChildren<TemplatePageViewProps>
50
51
templateVersions,
51
52
handleDeleteTemplate,
52
53
deleteTemplateError,
54
+ canDeleteTemplate
53
55
} ) => {
54
56
const styles = useStyles ( )
55
57
const readme = frontMatter ( activeTemplateVersion . readme )
@@ -59,6 +61,15 @@ export const TemplatePageView: FC<React.PropsWithChildren<TemplatePageViewProps>
59
61
return resources . filter ( ( resource ) => resource . workspace_transition === "start" )
60
62
}
61
63
64
+ const createWorkspaceButton = ( className : string ) => < Link
65
+ underline = "none"
66
+ component = { RouterLink }
67
+ to = { `/templates/${ template . name } /workspace` }
68
+ >
69
+ < Button className = { className } startIcon = { < AddCircleOutline /> } > { Language . createButton } </ Button >
70
+ </ Link >
71
+
72
+
62
73
return (
63
74
< Margins >
64
75
< >
@@ -76,24 +87,20 @@ export const TemplatePageView: FC<React.PropsWithChildren<TemplatePageViewProps>
76
87
</ Button >
77
88
</ Link >
78
89
79
- < DropdownButton
80
- primaryAction = {
81
- < Link
82
- underline = "none"
83
- component = { RouterLink }
84
- to = { `/templates/${ template . name } /workspace` }
85
- >
86
- < Button startIcon = { < AddCircleOutline /> } > { Language . createButton } </ Button >
87
- </ Link >
88
- }
89
- secondaryActions = { [
90
- {
91
- action : "delete" ,
92
- button : < DeleteButton handleAction = { ( ) => handleDeleteTemplate ( template . id ) } /> ,
93
- } ,
94
- ] }
95
- canCancel = { false }
96
- />
90
+ { canDeleteTemplate ?
91
+ < DropdownButton
92
+ primaryAction = { createWorkspaceButton ( styles . actionButton ) }
93
+ secondaryActions = { [
94
+ {
95
+ action : "delete" ,
96
+ button : < DeleteButton handleAction = { ( ) => handleDeleteTemplate ( template . id ) } /> ,
97
+ } ,
98
+ ] }
99
+ canCancel = { false }
100
+ />
101
+ :
102
+ createWorkspaceButton ( "" )
103
+ }
97
104
</ Stack >
98
105
}
99
106
>
@@ -156,6 +163,10 @@ export const TemplatePageView: FC<React.PropsWithChildren<TemplatePageViewProps>
156
163
157
164
export const useStyles = makeStyles ( ( theme ) => {
158
165
return {
166
+ actionButton : {
167
+ border : "none" ,
168
+ borderRadius : `${ theme . shape . borderRadius } px 0px 0px ${ theme . shape . borderRadius } px` ,
169
+ } ,
159
170
readmeContents : {
160
171
margin : 0 ,
161
172
} ,
0 commit comments