@@ -9,7 +9,6 @@ import { ChooseOne, Cond } from "components/Conditionals/ChooseOne"
99import { DeleteDialog } from "components/Dialogs/DeleteDialog/DeleteDialog"
1010import { DeleteButton } from "components/DropdownButton/ActionCtas"
1111import { DropdownButton } from "components/DropdownButton/DropdownButton"
12- import { Loader } from "components/Loader/Loader"
1312import {
1413 PageHeader ,
1514 PageHeaderSubtitle ,
@@ -53,7 +52,7 @@ const useTemplateName = () => {
5352
5453type TemplateLayoutContextValue = {
5554 context : TemplateContext
56- permissions : Permissions
55+ permissions ? : Permissions
5756}
5857
5958const TemplateLayoutContext = createContext <
@@ -97,23 +96,23 @@ export const TemplateLayout: FC<PropsWithChildren> = ({ children }) => {
9796 ! templateDAUs ||
9897 ! templatePermissions
9998
100- if ( isLoading ) {
101- return < Loader />
102- }
103-
10499 if ( templateState . matches ( "deleted" ) ) {
105100 return < Navigate to = "/templates" />
106101 }
107102
108- const hasIcon = template . icon && template . icon !== ""
103+ const hasIcon = template && template . icon && template . icon !== ""
109104
110105 const createWorkspaceButton = ( className ?: string ) => (
111106 < Link
112107 underline = "none"
113108 component = { RouterLink }
114- to = { `/templates/${ template . name } /workspace` }
109+ to = { `/templates/${ templateName } /workspace` }
115110 >
116- < Button className = { className ?? "" } startIcon = { < AddCircleOutline /> } >
111+ < Button
112+ className = { className ?? "" }
113+ startIcon = { < AddCircleOutline /> }
114+ disabled = { isLoading }
115+ >
117116 { Language . createButton }
118117 </ Button >
119118 </ Link >
@@ -128,89 +127,98 @@ export const TemplateLayout: FC<PropsWithChildren> = ({ children }) => {
128127 < Margins >
129128 < PageHeader
130129 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 >
142142
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 >
156156
157- < Cond > { createWorkspaceButton ( ) } </ Cond >
158- </ ChooseOne >
157+ < Cond > { createWorkspaceButton ( ) } </ Cond >
158+ </ ChooseOne >
159+ )
159160 }
160161 >
161162 < 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+ ) }
181187 </ Stack >
182188 </ PageHeader >
183189 </ Margins >
184190
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+ ) }
214222
215223 < Margins >
216224 < TemplateLayoutContext . Provider
@@ -220,18 +228,20 @@ export const TemplateLayout: FC<PropsWithChildren> = ({ children }) => {
220228 </ TemplateLayoutContext . Provider >
221229 </ Margins >
222230
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+ ) }
235245 </ >
236246 )
237247}
0 commit comments