@@ -128,29 +128,6 @@ export function CreateWorkspacePage() {
128
128
}
129
129
} , [ project , selectedProjectID ] ) ;
130
130
131
- // Apply project ws class settings
132
- useEffect ( ( ) => {
133
- // If URL has a ws class set, we don't override it w/ project settings
134
- if ( props . workspaceClass ) {
135
- return ;
136
- }
137
-
138
- if ( ! project ) {
139
- // If no project and user hasn't changed ws class, reset it to default value
140
- // Empty value causes SelectWorkspaceClassComponent to use the default ws class
141
- if ( ! selectedWsClassIsDirty ) {
142
- setSelectedWsClass ( defaultWorkspaceClass , false ) ;
143
- }
144
- return ;
145
- }
146
- const wsClass = project . settings ?. workspaceClasses ;
147
-
148
- // only set if user hasn't changed the value themselves, and project has a vaue
149
- if ( wsClass ?. regular && ! selectedWsClassIsDirty ) {
150
- setSelectedWsClass ( wsClass ?. regular , false ) ;
151
- }
152
- } , [ defaultWorkspaceClass , project , props . workspaceClass , selectedWsClassIsDirty , setSelectedWsClass ] ) ;
153
-
154
131
// In addition to updating state, we want to update the url hash as well
155
132
// This allows the contextURL to persist if user changes orgs, or copies/shares url
156
133
const handleContextURLChange = useCallback (
@@ -276,6 +253,9 @@ export function CreateWorkspacePage() {
276
253
277
254
// when workspaceContext is available, we look up if options are remembered
278
255
useEffect ( ( ) => {
256
+ if ( ! workspaceContext . data || ! user || ! currentOrg ) {
257
+ return ;
258
+ }
279
259
const cloneURL = CommitContext . is ( workspaceContext . data ) && workspaceContext . data . repository . cloneUrl ;
280
260
if ( ! cloneURL ) {
281
261
return undefined ;
@@ -299,13 +279,14 @@ export function CreateWorkspacePage() {
299
279
setUseLatestIde ( defaultLatestIde ) ;
300
280
}
301
281
if ( ! selectedWsClassIsDirty ) {
302
- setSelectedWsClass ( defaultWorkspaceClass , false ) ;
282
+ const projectWsClass = project ?. settings ?. workspaceClasses ?. regular ;
283
+ setSelectedWsClass ( projectWsClass || defaultWorkspaceClass , false ) ;
303
284
}
304
285
}
305
286
setOptionsLoaded ( true ) ;
306
287
// we only update the remembered options when the workspaceContext changes
307
288
// eslint-disable-next-line react-hooks/exhaustive-deps
308
- } , [ workspaceContext . data , setOptionsLoaded ] ) ;
289
+ } , [ workspaceContext . data , setOptionsLoaded , project ] ) ;
309
290
310
291
// Need a wrapper here so we call createWorkspace w/o any arguments
311
292
const onClickCreate = useCallback ( ( ) => createWorkspace ( ) , [ createWorkspace ] ) ;
0 commit comments