Skip to content

Commit b360a91

Browse files
authored
Merge pull request #1494 from stakwork/feature/add-base-branch-to-codespace-form-1749478861
Add Base Branch parameter to Code Space Management form
2 parents 0297e6c + 78c753c commit b360a91

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

src/people/widgetViews/workspace/ManageCodeSpaceModal.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ interface CodeSpaceMap {
7474
codeSpaceURL: string;
7575
userPubkey: string;
7676
githubPat?: string;
77+
baseBranch?: string;
7778
}
7879

7980
interface CodeSpaceProps {
@@ -92,6 +93,7 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
9293
const { main, ui } = useStores();
9394
const [codeSpace, setCodeSpace] = useState<CodeSpaceMap | null>(null);
9495
const [githubPat, setGithubPat] = useState('');
96+
const [baseBranch, setBaseBranch] = useState('');
9597
const [urlError, setUrlError] = useState(false);
9698
const [isLoading, setIsLoading] = useState(false);
9799
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
@@ -120,6 +122,7 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
120122
// Check if response is valid and has an ID
121123
setCodeSpace(response);
122124
setGithubPat(response.githubPat || ''); // Initialize PAT state
125+
setBaseBranch(response.baseBranch || ''); // Initialize Base Branch state
123126
setUrlError(!isValidUrl(response.codeSpaceURL)); // Also validate fetched URL
124127
} else {
125128
// Initialize state for creating a new code space
@@ -180,15 +183,20 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
180183
setGithubPat(e.target.value);
181184
};
182185

186+
const handleBaseBranchChange = (e: React.ChangeEvent<HTMLInputElement>) => {
187+
setBaseBranch(e.target.value);
188+
};
189+
183190
const handleSave = async () => {
184191
if (!codeSpace || !isValidUrl(codeSpace.codeSpaceURL)) return;
185192

186193
setIsLoading(true);
187194
try {
188-
// Prepare the payload including the githubPat
195+
// Prepare the payload including the githubPat and baseBranch
189196
const payload = {
190197
...codeSpace,
191198
githubPat: githubPat, // Add the PAT from state
199+
baseBranch: baseBranch, // Add the Base Branch from state
192200
workspaceID: workspaceUUID, // Ensure workspaceID is always set
193201
userPubkey: ui.meInfo?.pubkey || '' // Ensure userPubkey is always set
194202
};
@@ -202,11 +210,13 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
202210
// Remove id, createdAt, updatedAt before creating
203211
const createPayload: Omit<CodeSpaceMap, 'id' | 'createdAt' | 'updatedAt'> & {
204212
githubPat?: string;
213+
baseBranch?: string;
205214
} = {
206215
workspaceID: workspaceUUID,
207216
codeSpaceURL: codeSpace.codeSpaceURL,
208217
userPubkey: ui.meInfo?.pubkey || '',
209-
githubPat: githubPat
218+
githubPat: githubPat,
219+
baseBranch: baseBranch
210220
};
211221
const newCodeSpace = await main.createCodeSpace(createPayload);
212222
if (newCodeSpace) {
@@ -257,6 +267,15 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
257267
onChange={handlePatChange}
258268
/>
259269
</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>
260279
{urlError && (
261280
<p style={{ color: 'red', fontSize: '12px', marginLeft: '33%' }}>
262281
Invalid URL. Ensure it starts with https://

src/store/interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ export interface CodeSpaceMap {
875875
codeSpaceURL: string;
876876
userPubkey: string;
877877
githubPat?: string;
878+
baseBranch?: string;
878879
}
879880

880881
export type ChargeModel = 'Free' | 'PAYG';

src/store/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5074,7 +5074,10 @@ export class MainStore {
50745074
}
50755075
// Update body type to allow githubPat
50765076
async createCodeSpace(
5077-
body: Omit<CodeSpaceMap, 'id' | 'createdAt' | 'updatedAt'> & { githubPat?: string }
5077+
body: Omit<CodeSpaceMap, 'id' | 'createdAt' | 'updatedAt'> & {
5078+
githubPat?: string;
5079+
baseBranch?: string;
5080+
}
50785081
): Promise<any> {
50795082
try {
50805083
if (!uiStore.meInfo) return null;

0 commit comments

Comments
 (0)