@@ -106,35 +106,23 @@ export const TemplateLayout: FC<PropsWithChildren> = ({ children }) => {
106
106
organizationId,
107
107
} ,
108
108
} )
109
- const {
110
- template,
111
- activeTemplateVersion,
112
- templateResources,
113
- templateDAUs,
114
- permissions : templatePermissions ,
115
- } = templateState . context
109
+ const { template, permissions : templatePermissions } = templateState . context
116
110
const xServices = useContext ( XServiceContext )
117
111
const permissions = useSelector ( xServices . authXService , selectPermissions )
118
- const isLoading =
119
- ! template ||
120
- ! activeTemplateVersion ||
121
- ! templateResources ||
122
- ! permissions ||
123
- ! templateDAUs ||
124
- ! templatePermissions
125
-
126
112
const hasIcon = template && template . icon && template . icon !== ""
127
113
114
+ if ( ! template ) {
115
+ return < Loader />
116
+ }
117
+
128
118
const generatePageHeaderActions = ( ) : JSX . Element [ ] => {
129
119
const pageActions : JSX . Element [ ] = [ ]
130
120
131
- if ( ! isLoading && templatePermissions . canUpdateTemplate ) {
132
- pageActions . push ( < TemplateSettingsButton templateName = { templateName } /> )
121
+ if ( templatePermissions ? .canUpdateTemplate ) {
122
+ pageActions . push ( < TemplateSettingsButton templateName = { template . name } /> )
133
123
}
134
124
135
- if ( ! isLoading ) {
136
- pageActions . push ( < CreateWorkspaceButton templateName = { templateName } /> )
137
- }
125
+ pageActions . push ( < CreateWorkspaceButton templateName = { template . name } /> )
138
126
139
127
return pageActions
140
128
}
@@ -152,65 +140,59 @@ export const TemplateLayout: FC<PropsWithChildren> = ({ children }) => {
152
140
}
153
141
>
154
142
< Stack direction = "row" spacing = { 3 } className = { styles . pageTitle } >
155
- { ! isLoading && (
156
- < div >
157
- { hasIcon ? (
158
- < div className = { styles . iconWrapper } >
159
- < img src = { template . icon } alt = "" />
160
- </ div >
161
- ) : (
162
- < Avatar className = { styles . avatar } >
163
- { firstLetter ( templateName ) }
164
- </ Avatar >
165
- ) }
166
- </ div >
167
- ) }
143
+ < div >
144
+ { hasIcon ? (
145
+ < div className = { styles . iconWrapper } >
146
+ < img src = { template . icon } alt = "" />
147
+ </ div >
148
+ ) : (
149
+ < Avatar className = { styles . avatar } >
150
+ { firstLetter ( template . name ) }
151
+ </ Avatar >
152
+ ) }
153
+ </ div >
168
154
169
- { ! isLoading && (
170
- < div >
171
- < PageHeaderTitle > { templateName } </ PageHeaderTitle >
172
- < PageHeaderSubtitle condensed >
173
- { template . description === ""
174
- ? Language . noDescription
175
- : template . description }
176
- </ PageHeaderSubtitle >
177
- </ div >
178
- ) }
155
+ < div >
156
+ < PageHeaderTitle > { template . name } </ PageHeaderTitle >
157
+ < PageHeaderSubtitle condensed >
158
+ { template . description === ""
159
+ ? Language . noDescription
160
+ : template . description }
161
+ </ PageHeaderSubtitle >
162
+ </ div >
179
163
</ Stack >
180
164
</ PageHeader >
181
165
</ Margins >
182
166
183
- { ! isLoading && (
184
- < div className = { styles . tabs } >
185
- < Margins >
186
- < Stack direction = "row" spacing = { 0.25 } >
187
- < NavLink
188
- end
189
- to = { `/templates/${ template . name } ` }
190
- className = { ( { isActive } ) =>
191
- combineClasses ( [
192
- styles . tabItem ,
193
- isActive ? styles . tabItemActive : undefined ,
194
- ] )
195
- }
196
- >
197
- Summary
198
- </ NavLink >
199
- < NavLink
200
- to = { `/templates/${ template . name } /permissions` }
201
- className = { ( { isActive } ) =>
202
- combineClasses ( [
203
- styles . tabItem ,
204
- isActive ? styles . tabItemActive : undefined ,
205
- ] )
206
- }
207
- >
208
- Permissions
209
- </ NavLink >
210
- </ Stack >
211
- </ Margins >
212
- </ div >
213
- ) }
167
+ < div className = { styles . tabs } >
168
+ < Margins >
169
+ < Stack direction = "row" spacing = { 0.25 } >
170
+ < NavLink
171
+ end
172
+ to = { `/templates/${ template . name } ` }
173
+ className = { ( { isActive } ) =>
174
+ combineClasses ( [
175
+ styles . tabItem ,
176
+ isActive ? styles . tabItemActive : undefined ,
177
+ ] )
178
+ }
179
+ >
180
+ Summary
181
+ </ NavLink >
182
+ < NavLink
183
+ to = { `/templates/${ template . name } /permissions` }
184
+ className = { ( { isActive } ) =>
185
+ combineClasses ( [
186
+ styles . tabItem ,
187
+ isActive ? styles . tabItemActive : undefined ,
188
+ ] )
189
+ }
190
+ >
191
+ Permissions
192
+ </ NavLink >
193
+ </ Stack >
194
+ </ Margins >
195
+ </ div >
214
196
215
197
< Margins >
216
198
< TemplateLayoutContext . Provider
0 commit comments