@@ -61,8 +61,10 @@ export function CreateWorkspacePage() {
61
61
) ;
62
62
const [ selectedWsClass , setSelectedWsClass ] = useState < string | undefined > ( props . workspaceClass ) ;
63
63
const [ errorWsClass , setErrorWsClass ] = useState < string | undefined > ( undefined ) ;
64
- const [ repo , setRepo ] = useState < string | undefined > ( location . hash . substring ( 1 ) ) ;
65
- const workspaceContext = useWorkspaceContext ( repo ) ;
64
+ const [ contextURL , setContextURL ] = useState < string | undefined > (
65
+ StartWorkspaceOptions . parseContextUrl ( location . hash ) ,
66
+ ) ;
67
+ const workspaceContext = useWorkspaceContext ( contextURL ) ;
66
68
const isLoading = workspaceContext . isLoading || projects . isLoading ;
67
69
const project = useMemo ( ( ) => {
68
70
if ( ! workspaceContext . data || ! projects . data ) {
@@ -108,28 +110,28 @@ export function CreateWorkspacePage() {
108
110
useLatestVersion : useLatestIde ,
109
111
} ;
110
112
}
111
- if ( ! repo ) {
113
+ if ( ! contextURL ) {
112
114
return ;
113
115
}
114
116
115
117
try {
116
118
const result = await createWorkspaceMutation . mutateAsync ( {
117
- contextUrl : repo ,
119
+ contextUrl : contextURL ,
118
120
organizationId : currentOrg ?. id ,
119
121
...opts ,
120
122
} ) ;
121
123
if ( result . workspaceURL ) {
122
124
window . location . href = result . workspaceURL ;
123
125
} else if ( result . createdWorkspaceId ) {
124
- history . push ( `/start/${ result . createdWorkspaceId } ` ) ;
126
+ history . push ( `/start/# ${ result . createdWorkspaceId } ` ) ;
125
127
} else if ( result . existingWorkspaces && result . existingWorkspaces . length > 0 ) {
126
128
setExistingWorkspaces ( result . existingWorkspaces ) ;
127
129
}
128
130
} catch ( error ) {
129
131
console . log ( error ) ;
130
132
}
131
133
} ,
132
- [ createWorkspaceMutation , history , repo , selectedIde , selectedWsClass , currentOrg ?. id , useLatestIde ] ,
134
+ [ createWorkspaceMutation , history , contextURL , selectedIde , selectedWsClass , currentOrg ?. id , useLatestIde ] ,
133
135
) ;
134
136
135
137
// Need a wrapper here so we call createWorkspace w/o any arguments
@@ -155,7 +157,12 @@ export function CreateWorkspacePage() {
155
157
</ div >
156
158
< div className = "-mx-6 px-6 mt-6 w-full" >
157
159
< div className = "pt-3" >
158
- < RepositoryFinder setSelection = { setRepo } initialValue = { repo } />
160
+ { workspaceContext . error && (
161
+ < div className = "text-red-500 text-sm" >
162
+ { workspaceContext . error . message } URL was: { contextURL }
163
+ </ div >
164
+ ) }
165
+ < RepositoryFinder setSelection = { setContextURL } initialValue = { contextURL } />
159
166
</ div >
160
167
< div className = "pt-3" >
161
168
{ errorIde && < div className = "text-red-500 text-sm" > { errorIde } </ div > }
@@ -178,8 +185,15 @@ export function CreateWorkspacePage() {
178
185
< div className = "w-full flex justify-end mt-6 space-x-2 px-6" >
179
186
< Button
180
187
onClick = { onClickCreate }
188
+ autoFocus = { true }
181
189
loading = { isStarting || isLoading }
182
- disabled = { ! repo || repo . length === 0 || ! ! errorIde || ! ! errorWsClass }
190
+ disabled = {
191
+ ! contextURL ||
192
+ contextURL . length === 0 ||
193
+ ! ! errorIde ||
194
+ ! ! errorWsClass ||
195
+ ! ! workspaceContext . error
196
+ }
183
197
>
184
198
{ isLoading ? "Loading ..." : isStarting ? "Creating Workspace ..." : "New Workspace" }
185
199
</ Button >
0 commit comments