@@ -74,6 +74,7 @@ interface CodeSpaceMap {
74
74
codeSpaceURL : string ;
75
75
userPubkey : string ;
76
76
githubPat ?: string ;
77
+ baseBranch ?: string ;
77
78
}
78
79
79
80
interface CodeSpaceProps {
@@ -92,6 +93,7 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
92
93
const { main, ui } = useStores ( ) ;
93
94
const [ codeSpace , setCodeSpace ] = useState < CodeSpaceMap | null > ( null ) ;
94
95
const [ githubPat , setGithubPat ] = useState ( '' ) ;
96
+ const [ baseBranch , setBaseBranch ] = useState ( '' ) ;
95
97
const [ urlError , setUrlError ] = useState ( false ) ;
96
98
const [ isLoading , setIsLoading ] = useState ( false ) ;
97
99
const [ isDeleteLoading , setIsDeleteLoading ] = useState ( false ) ;
@@ -120,6 +122,7 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
120
122
// Check if response is valid and has an ID
121
123
setCodeSpace ( response ) ;
122
124
setGithubPat ( response . githubPat || '' ) ; // Initialize PAT state
125
+ setBaseBranch ( response . baseBranch || '' ) ; // Initialize Base Branch state
123
126
setUrlError ( ! isValidUrl ( response . codeSpaceURL ) ) ; // Also validate fetched URL
124
127
} else {
125
128
// Initialize state for creating a new code space
@@ -180,15 +183,20 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
180
183
setGithubPat ( e . target . value ) ;
181
184
} ;
182
185
186
+ const handleBaseBranchChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
187
+ setBaseBranch ( e . target . value ) ;
188
+ } ;
189
+
183
190
const handleSave = async ( ) => {
184
191
if ( ! codeSpace || ! isValidUrl ( codeSpace . codeSpaceURL ) ) return ;
185
192
186
193
setIsLoading ( true ) ;
187
194
try {
188
- // Prepare the payload including the githubPat
195
+ // Prepare the payload including the githubPat and baseBranch
189
196
const payload = {
190
197
...codeSpace ,
191
198
githubPat : githubPat , // Add the PAT from state
199
+ baseBranch : baseBranch , // Add the Base Branch from state
192
200
workspaceID : workspaceUUID , // Ensure workspaceID is always set
193
201
userPubkey : ui . meInfo ?. pubkey || '' // Ensure userPubkey is always set
194
202
} ;
@@ -202,11 +210,13 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
202
210
// Remove id, createdAt, updatedAt before creating
203
211
const createPayload : Omit < CodeSpaceMap , 'id' | 'createdAt' | 'updatedAt' > & {
204
212
githubPat ?: string ;
213
+ baseBranch ?: string ;
205
214
} = {
206
215
workspaceID : workspaceUUID ,
207
216
codeSpaceURL : codeSpace . codeSpaceURL ,
208
217
userPubkey : ui . meInfo ?. pubkey || '' ,
209
- githubPat : githubPat
218
+ githubPat : githubPat ,
219
+ baseBranch : baseBranch
210
220
} ;
211
221
const newCodeSpace = await main . createCodeSpace ( createPayload ) ;
212
222
if ( newCodeSpace ) {
@@ -257,6 +267,15 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
257
267
onChange = { handlePatChange }
258
268
/>
259
269
</ Wrapper >
270
+ < Wrapper >
271
+ < Label > Base Branch:</ Label >
272
+ < TextInput
273
+ type = "text"
274
+ placeholder = "Enter Base Branch (e.g., main, master)"
275
+ value = { baseBranch }
276
+ onChange = { handleBaseBranchChange }
277
+ />
278
+ </ Wrapper >
260
279
{ urlError && (
261
280
< p style = { { color : 'red' , fontSize : '12px' , marginLeft : '33%' } } >
262
281
Invalid URL. Ensure it starts with https://
0 commit comments