@@ -9,7 +9,6 @@ import { ChooseOne, Cond } from "components/Conditionals/ChooseOne"
9
9
import { DeleteDialog } from "components/Dialogs/DeleteDialog/DeleteDialog"
10
10
import { DeleteButton } from "components/DropdownButton/ActionCtas"
11
11
import { DropdownButton } from "components/DropdownButton/DropdownButton"
12
- import { Loader } from "components/Loader/Loader"
13
12
import {
14
13
PageHeader ,
15
14
PageHeaderSubtitle ,
@@ -53,7 +52,7 @@ const useTemplateName = () => {
53
52
54
53
type TemplateLayoutContextValue = {
55
54
context : TemplateContext
56
- permissions : Permissions
55
+ permissions ? : Permissions
57
56
}
58
57
59
58
const TemplateLayoutContext = createContext <
@@ -97,23 +96,23 @@ export const TemplateLayout: FC<PropsWithChildren> = ({ children }) => {
97
96
! templateDAUs ||
98
97
! templatePermissions
99
98
100
- if ( isLoading ) {
101
- return < Loader />
102
- }
103
-
104
99
if ( templateState . matches ( "deleted" ) ) {
105
100
return < Navigate to = "/templates" />
106
101
}
107
102
108
- const hasIcon = template . icon && template . icon !== ""
103
+ const hasIcon = template && template . icon && template . icon !== ""
109
104
110
105
const createWorkspaceButton = ( className ?: string ) => (
111
106
< Link
112
107
underline = "none"
113
108
component = { RouterLink }
114
- to = { `/templates/${ template . name } /workspace` }
109
+ to = { `/templates/${ templateName } /workspace` }
115
110
>
116
- < Button className = { className ?? "" } startIcon = { < AddCircleOutline /> } >
111
+ < Button
112
+ className = { className ?? "" }
113
+ startIcon = { < AddCircleOutline /> }
114
+ disabled = { isLoading }
115
+ >
117
116
{ Language . createButton }
118
117
</ Button >
119
118
</ Link >
@@ -128,89 +127,98 @@ export const TemplateLayout: FC<PropsWithChildren> = ({ children }) => {
128
127
< Margins >
129
128
< PageHeader
130
129
actions = {
131
- < ChooseOne >
132
- < Cond condition = { templatePermissions . canUpdateTemplate } >
133
- < Link
134
- underline = "none"
135
- component = { RouterLink }
136
- to = { `/templates/${ template . name } /settings` }
137
- >
138
- < Button variant = "outlined" startIcon = { < SettingsOutlined /> } >
139
- { Language . settingsButton }
140
- </ Button >
141
- </ Link >
130
+ isLoading ? undefined : (
131
+ < ChooseOne >
132
+ < Cond condition = { templatePermissions . canUpdateTemplate } >
133
+ < Link
134
+ underline = "none"
135
+ component = { RouterLink }
136
+ to = { `/templates/${ template . name } /settings` }
137
+ >
138
+ < Button variant = "outlined" startIcon = { < SettingsOutlined /> } >
139
+ { Language . settingsButton }
140
+ </ Button >
141
+ </ Link >
142
142
143
- < DropdownButton
144
- primaryAction = { createWorkspaceButton ( styles . actionButton ) }
145
- secondaryActions = { [
146
- {
147
- action : "delete" ,
148
- button : (
149
- < DeleteButton handleAction = { handleDeleteTemplate } />
150
- ) ,
151
- } ,
152
- ] }
153
- canCancel = { false }
154
- />
155
- </ Cond >
143
+ < DropdownButton
144
+ primaryAction = { createWorkspaceButton ( styles . actionButton ) }
145
+ secondaryActions = { [
146
+ {
147
+ action : "delete" ,
148
+ button : (
149
+ < DeleteButton handleAction = { handleDeleteTemplate } />
150
+ ) ,
151
+ } ,
152
+ ] }
153
+ canCancel = { false }
154
+ />
155
+ </ Cond >
156
156
157
- < Cond > { createWorkspaceButton ( ) } </ Cond >
158
- </ ChooseOne >
157
+ < Cond > { createWorkspaceButton ( ) } </ Cond >
158
+ </ ChooseOne >
159
+ )
159
160
}
160
161
>
161
162
< Stack direction = "row" spacing = { 3 } className = { styles . pageTitle } >
162
- < div >
163
- { hasIcon ? (
164
- < div className = { styles . iconWrapper } >
165
- < img src = { template . icon } alt = "" />
166
- </ div >
167
- ) : (
168
- < Avatar className = { styles . avatar } >
169
- { firstLetter ( template . name ) }
170
- </ Avatar >
171
- ) }
172
- </ div >
173
- < div >
174
- < PageHeaderTitle > { template . name } </ PageHeaderTitle >
175
- < PageHeaderSubtitle condensed >
176
- { template . description === ""
177
- ? Language . noDescription
178
- : template . description }
179
- </ PageHeaderSubtitle >
180
- </ div >
163
+ { ! isLoading && (
164
+ < div >
165
+ { hasIcon ? (
166
+ < div className = { styles . iconWrapper } >
167
+ < img src = { template . icon } alt = "" />
168
+ </ div >
169
+ ) : (
170
+ < Avatar className = { styles . avatar } >
171
+ { firstLetter ( templateName ) }
172
+ </ Avatar >
173
+ ) }
174
+ </ div >
175
+ ) }
176
+
177
+ { ! isLoading && (
178
+ < div >
179
+ < PageHeaderTitle > { templateName } </ PageHeaderTitle >
180
+ < PageHeaderSubtitle condensed >
181
+ { template . description === ""
182
+ ? Language . noDescription
183
+ : template . description }
184
+ </ PageHeaderSubtitle >
185
+ </ div >
186
+ ) }
181
187
</ Stack >
182
188
</ PageHeader >
183
189
</ Margins >
184
190
185
- < div className = { styles . tabs } >
186
- < Margins >
187
- < Stack direction = "row" spacing = { 0.25 } >
188
- < NavLink
189
- end
190
- to = { `/templates/${ template . name } ` }
191
- className = { ( { isActive } ) =>
192
- combineClasses ( [
193
- styles . tabItem ,
194
- isActive ? styles . tabItemActive : undefined ,
195
- ] )
196
- }
197
- >
198
- Summary
199
- </ NavLink >
200
- < NavLink
201
- to = { `/templates/${ template . name } /permissions` }
202
- className = { ( { isActive } ) =>
203
- combineClasses ( [
204
- styles . tabItem ,
205
- isActive ? styles . tabItemActive : undefined ,
206
- ] )
207
- }
208
- >
209
- Permissions
210
- </ NavLink >
211
- </ Stack >
212
- </ Margins >
213
- </ div >
191
+ { ! isLoading && (
192
+ < div className = { styles . tabs } >
193
+ < Margins >
194
+ < Stack direction = "row" spacing = { 0.25 } >
195
+ < NavLink
196
+ end
197
+ to = { `/templates/${ template . name } ` }
198
+ className = { ( { isActive } ) =>
199
+ combineClasses ( [
200
+ styles . tabItem ,
201
+ isActive ? styles . tabItemActive : undefined ,
202
+ ] )
203
+ }
204
+ >
205
+ Summary
206
+ </ NavLink >
207
+ < NavLink
208
+ to = { `/templates/${ template . name } /permissions` }
209
+ className = { ( { isActive } ) =>
210
+ combineClasses ( [
211
+ styles . tabItem ,
212
+ isActive ? styles . tabItemActive : undefined ,
213
+ ] )
214
+ }
215
+ >
216
+ Permissions
217
+ </ NavLink >
218
+ </ Stack >
219
+ </ Margins >
220
+ </ div >
221
+ ) }
214
222
215
223
< Margins >
216
224
< TemplateLayoutContext . Provider
@@ -220,18 +228,20 @@ export const TemplateLayout: FC<PropsWithChildren> = ({ children }) => {
220
228
</ TemplateLayoutContext . Provider >
221
229
</ Margins >
222
230
223
- < DeleteDialog
224
- isOpen = { templateState . matches ( "confirmingDelete" ) }
225
- confirmLoading = { templateState . matches ( "deleting" ) }
226
- onConfirm = { ( ) => {
227
- templateSend ( "CONFIRM_DELETE" )
228
- } }
229
- onCancel = { ( ) => {
230
- templateSend ( "CANCEL_DELETE" )
231
- } }
232
- entity = "template"
233
- name = { template . name }
234
- />
231
+ { ! isLoading && (
232
+ < DeleteDialog
233
+ isOpen = { templateState . matches ( "confirmingDelete" ) }
234
+ confirmLoading = { templateState . matches ( "deleting" ) }
235
+ onConfirm = { ( ) => {
236
+ templateSend ( "CONFIRM_DELETE" )
237
+ } }
238
+ onCancel = { ( ) => {
239
+ templateSend ( "CANCEL_DELETE" )
240
+ } }
241
+ entity = "template"
242
+ name = { template . name }
243
+ />
244
+ ) }
235
245
</ >
236
246
)
237
247
}
0 commit comments