Skip to content

Commit a83fba3

Browse files
authored
Merge pull request #1502 from stakwork/feature/add-username-field-to-codespace-form-1750689372
Add Username field to Code Space Management form
2 parents 6a6a5ca + 51447b9 commit a83fba3

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/people/widgetViews/workspace/ManageCodeSpaceModal.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ interface CodeSpaceMap {
7373
workspaceID: string;
7474
codeSpaceURL: string;
7575
userPubkey: string;
76+
username?: string;
7677
githubPat?: string;
7778
baseBranch?: string;
7879
}
@@ -92,6 +93,7 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
9293
}) => {
9394
const { main, ui } = useStores();
9495
const [codeSpace, setCodeSpace] = useState<CodeSpaceMap | null>(null);
96+
const [username, setUsername] = useState('');
9597
const [githubPat, setGithubPat] = useState('');
9698
const [baseBranch, setBaseBranch] = useState('');
9799
const [urlError, setUrlError] = useState(false);
@@ -127,6 +129,7 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
127129
if (response && response.id) {
128130
// Check if response is valid and has an ID
129131
setCodeSpace(response);
132+
setUsername(response.username || ''); // Initialize Username state
130133
setGithubPat(response.githubPat || ''); // Initialize PAT state
131134
setBaseBranch(response.baseBranch || ''); // Initialize Base Branch state
132135
setUrlError(!isValidCodeSpaceInput(response.codeSpaceURL)); // Also validate fetched input
@@ -185,6 +188,10 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
185188
setUrlError(!isValidCodeSpaceInput(newUrl));
186189
};
187190

191+
const handleUsernameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
192+
setUsername(e.target.value);
193+
};
194+
188195
const handlePatChange = (e: React.ChangeEvent<HTMLInputElement>) => {
189196
setGithubPat(e.target.value);
190197
};
@@ -198,9 +205,10 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
198205

199206
setIsLoading(true);
200207
try {
201-
// Prepare the payload including the githubPat and baseBranch
208+
// Prepare the payload including the username, githubPat and baseBranch
202209
const payload = {
203210
...codeSpace,
211+
username: username, // Add the Username from state
204212
githubPat: githubPat, // Add the PAT from state
205213
baseBranch: baseBranch, // Add the Base Branch from state
206214
workspaceID: workspaceUUID, // Ensure workspaceID is always set
@@ -215,12 +223,14 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
215223
// Create new code space
216224
// Remove id, createdAt, updatedAt before creating
217225
const createPayload: Omit<CodeSpaceMap, 'id' | 'createdAt' | 'updatedAt'> & {
226+
username?: string;
218227
githubPat?: string;
219228
baseBranch?: string;
220229
} = {
221230
workspaceID: workspaceUUID,
222231
codeSpaceURL: codeSpace.codeSpaceURL,
223232
userPubkey: ui.meInfo?.pubkey || '',
233+
username: username,
224234
githubPat: githubPat,
225235
baseBranch: baseBranch
226236
};
@@ -264,6 +274,15 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
264274
style={{ borderColor: urlError ? '#FF8F80' : '' }}
265275
/>
266276
</Wrapper>
277+
<Wrapper>
278+
<Label>Username:</Label>
279+
<TextInput
280+
type="text"
281+
placeholder="Enter Username"
282+
value={username}
283+
onChange={handleUsernameChange}
284+
/>
285+
</Wrapper>
267286
<Wrapper>
268287
<Label>GitHub PAT:</Label>
269288
<TextInput

src/store/interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ export interface CodeSpaceMap {
874874
workspaceID: string;
875875
codeSpaceURL: string;
876876
userPubkey: string;
877+
username?: string;
877878
githubPat?: string;
878879
baseBranch?: string;
879880
}

src/store/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5075,6 +5075,7 @@ export class MainStore {
50755075
// Update body type to allow githubPat
50765076
async createCodeSpace(
50775077
body: Omit<CodeSpaceMap, 'id' | 'createdAt' | 'updatedAt'> & {
5078+
username?: string;
50785079
githubPat?: string;
50795080
baseBranch?: string;
50805081
}

0 commit comments

Comments
 (0)