From 11b2a804034bf3f8a21bcc800f72b3d2bb10ac22 Mon Sep 17 00:00:00 2001 From: Marco Mura Date: Thu, 20 Feb 2025 11:47:58 -0800 Subject: [PATCH 1/8] Added branch name validation for space characters --- src/react/atlascode/startwork/StartWorkPage.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/react/atlascode/startwork/StartWorkPage.tsx b/src/react/atlascode/startwork/StartWorkPage.tsx index 940d0a49..e1cd3074 100644 --- a/src/react/atlascode/startwork/StartWorkPage.tsx +++ b/src/react/atlascode/startwork/StartWorkPage.tsx @@ -181,6 +181,8 @@ const StartWorkPage: React.FunctionComponent = () => { const handleLocalBranchChange = useCallback( (event: React.ChangeEvent<{ name?: string | undefined; value: string }>) => { + // spaces are not allowed in branch names + event.target.value = event.target.value.replace(/ /g, '-'); setLocalBranch(event.target.value); }, [setLocalBranch], From 9b93482e69c7b758468e7dbb8efb9bfdc095a7b5 Mon Sep 17 00:00:00 2001 From: Marco Mura Date: Thu, 20 Feb 2025 12:37:13 -0800 Subject: [PATCH 2/8] Expose toggle switch to push branch to origin (Start work) --- src/ipc/issueActions.ts | 1 + src/lib/ipc/fromUI/startWork.ts | 1 + .../startwork/startWorkActionApi.ts | 1 + .../startwork/startWorkWebviewController.ts | 1 + .../atlascode/startwork/StartWorkPage.tsx | 27 +++++++++++++++++++ .../startwork/startWorkController.ts | 3 +++ .../startwork/vscStartWorkActionApi.ts | 7 +++-- .../components/issue/StartWorkPage.tsx | 1 + .../startWorkOnBitbucketIssueWebview.ts | 8 +++++- src/webviews/startWorkOnIssueWebview.ts | 9 ++++--- 10 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/ipc/issueActions.ts b/src/ipc/issueActions.ts index a8df0823..ec002ca3 100644 --- a/src/ipc/issueActions.ts +++ b/src/ipc/issueActions.ts @@ -120,6 +120,7 @@ export interface StartWorkAction extends Action { remoteName: string; setupJira: boolean; setupBitbucket: boolean; + pushBranchToOrigin: boolean; } export interface OpenStartWorkPageAction extends Action { diff --git a/src/lib/ipc/fromUI/startWork.ts b/src/lib/ipc/fromUI/startWork.ts index 6a2968bc..d3f2597b 100644 --- a/src/lib/ipc/fromUI/startWork.ts +++ b/src/lib/ipc/fromUI/startWork.ts @@ -27,6 +27,7 @@ export interface StartRequestAction { sourceBranch: Branch; targetBranch: string; upstream: string; + pushBranchToOrigin: boolean; } export interface OpenSettingsAction { diff --git a/src/lib/webview/controller/startwork/startWorkActionApi.ts b/src/lib/webview/controller/startwork/startWorkActionApi.ts index fb182cfa..22396d99 100644 --- a/src/lib/webview/controller/startwork/startWorkActionApi.ts +++ b/src/lib/webview/controller/startwork/startWorkActionApi.ts @@ -17,6 +17,7 @@ export interface StartWorkActionApi { destinationBranch: string, sourceBranch: Branch, remote: string, + pushBranchToOrigin: boolean, ): Promise; closePage(): void; getStartWorkConfig(): StartWorkBranchTemplate; diff --git a/src/lib/webview/controller/startwork/startWorkWebviewController.ts b/src/lib/webview/controller/startwork/startWorkWebviewController.ts index bd25f91e..e87eeadd 100644 --- a/src/lib/webview/controller/startwork/startWorkWebviewController.ts +++ b/src/lib/webview/controller/startwork/startWorkWebviewController.ts @@ -134,6 +134,7 @@ export class StartWorkWebviewController implements WebviewController { const [transitionIssueEnabled, setTransitionIssueEnabled] = useState(true); const [branchSetupEnabled, setbranchSetupEnabled] = useState(true); + const [pushBranchEnabled, setPushBranchEnabled] = useState(false); const [transition, setTransition] = useState(emptyTransition); const [repository, setRepository] = useState(emptyRepoData); const [branchType, setBranchType] = useState(emptyPrefix); @@ -120,6 +121,8 @@ const StartWorkPage: React.FunctionComponent = () => { [branchSetupEnabled], ); + const togglePushBranchEnabled = useCallback(() => setPushBranchEnabled(!pushBranchEnabled), [pushBranchEnabled]); + const handleTransitionChange = useCallback( (event: React.ChangeEvent<{ name?: string | undefined; value: any }>) => { setTransition(event.target.value); @@ -248,6 +251,7 @@ const StartWorkPage: React.FunctionComponent = () => { sourceBranch, localBranch, upstream, + pushBranchEnabled, ); setSubmitState('submit-success'); setSubmitResponse(response); @@ -264,6 +268,7 @@ const StartWorkPage: React.FunctionComponent = () => { sourceBranch, localBranch, upstream, + pushBranchEnabled, ]); const handleOpenSettings = useCallback(() => { @@ -704,6 +709,28 @@ const StartWorkPage: React.FunctionComponent = () => { + +