@@ -10,9 +10,11 @@ import {
1010 getCloneDestinationPath ,
1111 getCloneDirectoryName ,
1212 getDefaultCloneUrl ,
13- getNewProjectGitHubRepository ,
14- getNewProjectGitHubTarget ,
1513 getNewProjectPathPreview ,
14+ getNewProjectPublishTarget ,
15+ getNewProjectPublishTargets ,
16+ getNewProjectRepository ,
17+ type NewProjectPublishTarget ,
1618 normalizePastedCloneUrl ,
1719 addProjectRemoteSourceLabel ,
1820 addProjectRemoteSourcePathHint ,
@@ -195,7 +197,6 @@ import {
195197 CommandPaletteVirtualizedResults ,
196198 scrollCommandPaletteRowIntoView ,
197199} from "./CommandPaletteResults" ;
198- import { GitHubIcon } from "./Icons" ;
199200import { sourceControlIcon } from "~/sourceControlPresentation" ;
200201import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon" ;
201202import { Checkbox } from "./ui/checkbox" ;
@@ -221,6 +222,7 @@ import { resolveShortcutCommand, threadJumpIndexFromCommand } from "../keybindin
221222import { CommandDialog , CommandDialogPopup , CommandFooterAction } from "./ui/command" ;
222223import { Button } from "./ui/button" ;
223224import { Kbd , KbdGroup } from "./ui/kbd" ;
225+ import { Select , SelectItem , SelectPopup , SelectTrigger , SelectValue } from "./ui/select" ;
224226import { stackedThreadToast , toastManager } from "./ui/toast" ;
225227import { Tooltip , TooltipPopup , TooltipTrigger } from "./ui/tooltip" ;
226228import { ComposerHandleContext , useComposerHandleContext } from "../composerHandleContext" ;
@@ -280,6 +282,14 @@ function remoteProjectSourceIcon(source: AddProjectRemoteSource, className: stri
280282 return < Icon className = { className } /> ;
281283}
282284
285+ function sourceControlHostIcon (
286+ definition : NewProjectPublishTarget [ "definition" ] ,
287+ className : string ,
288+ ) : ReactNode {
289+ const Icon = sourceControlIcon ( definition ) ;
290+ return < Icon className = { className } /> ;
291+ }
292+
283293function projectFaviconIcon ( project : Project ) : ReactNode {
284294 return < ProjectFavicon project = { project } className = { ITEM_ICON_CLASS } /> ;
285295}
@@ -762,7 +772,11 @@ function OpenCommandPaletteDialog(props: {
762772 /** Machine of the Add project sources view under this step; null from the palette root. */
763773 readonly sourcesEnvironmentId : EnvironmentId | null ;
764774 } | null > ( null ) ;
765- const [ newProjectPublishesToGitHub , setNewProjectPublishesToGitHub ] = useState ( false ) ;
775+ const [ newProjectPublishes , setNewProjectPublishes ] = useState ( false ) ;
776+ // The host picked beside the publish toggle; null takes the first ready host, GitHub when ready.
777+ const [ newProjectPublishKind , setNewProjectPublishKind ] =
778+ useState < SourceControlProviderKind | null > ( null ) ;
779+ const [ newProjectHostPickerOpen , setNewProjectHostPickerOpen ] = useState ( false ) ;
766780 const [ isCreatingNewProject , setIsCreatingNewProject ] = useState ( false ) ;
767781 // State lags a render behind, so a repeated Enter could start a second create.
768782 const newProjectSubmittingRef = useRef ( false ) ;
@@ -1482,7 +1496,8 @@ function OpenCommandPaletteDialog(props: {
14821496 setAddProjectEnvironmentId ( environmentId ) ;
14831497 setAddProjectCloneFlow ( null ) ;
14841498 setNewProjectFlow ( { environmentId, sourcesEnvironmentId } ) ;
1485- setNewProjectPublishesToGitHub ( false ) ;
1499+ setNewProjectPublishes ( false ) ;
1500+ setNewProjectPublishKind ( null ) ;
14861501 pushPaletteView ( {
14871502 addonIcon : < FolderGit2Icon className = { ADDON_ICON_CLASS } /> ,
14881503 groups : [ ] ,
@@ -2417,8 +2432,12 @@ function OpenCommandPaletteDialog(props: {
24172432 ] ,
24182433 ) ;
24192434
2420- const newProjectGitHubTarget =
2421- newProjectFlow === null ? null : getNewProjectGitHubTarget ( sourceControlDiscovery . data ?? null ) ;
2435+ const newProjectPublishTargets =
2436+ newProjectFlow === null ? [ ] : getNewProjectPublishTargets ( sourceControlDiscovery . data ?? null ) ;
2437+ const newProjectPublishTarget = getNewProjectPublishTarget (
2438+ newProjectPublishTargets ,
2439+ newProjectPublishKind ,
2440+ ) ;
24222441 const newProjectName = query . trim ( ) ;
24232442 const canSubmitNewProject =
24242443 newProjectFlow !== null &&
@@ -2436,7 +2455,7 @@ function OpenCommandPaletteDialog(props: {
24362455 const created = await createNewProject ( {
24372456 environmentId : newProjectFlow . environmentId ,
24382457 name : newProjectName ,
2439- github : newProjectPublishesToGitHub ? newProjectGitHubTarget : null ,
2458+ publishTo : newProjectPublishes ? newProjectPublishTarget : null ,
24402459 } ) ;
24412460 if ( created ) setOpen ( false ) ;
24422461 } finally {
@@ -2742,7 +2761,7 @@ function OpenCommandPaletteDialog(props: {
27422761 const newProjectsRoot = newProjectFlow ? newProjectsRootFor ( newProjectFlow . environmentId ) : null ;
27432762 const newProjectPathPreview =
27442763 newProjectsRoot === null ? null : getNewProjectPathPreview ( newProjectsRoot , newProjectName ) ;
2745- const newProjectGitHubToggleValue = "new-project:github " ;
2764+ const newProjectPublishToggleValue = "new-project:publish " ;
27462765 // The name step's way out to folders and clones, for the selected machine.
27472766 // It replaces the name step (and a sources view for another machine under
27482767 // it), so Back returns to wherever New project was opened from.
@@ -2829,7 +2848,7 @@ function OpenCommandPaletteDialog(props: {
28292848 ] ,
28302849 } ;
28312850 const newProjectOptionGroups : CommandPaletteView [ "groups" ] =
2832- newProjectGitHubTarget === null || newProjectPathPreview === null
2851+ newProjectPublishTarget === null || newProjectPathPreview === null
28332852 ? [ ]
28342853 : [
28352854 {
@@ -2838,22 +2857,78 @@ function OpenCommandPaletteDialog(props: {
28382857 items : [
28392858 {
28402859 kind : "action" ,
2841- value : newProjectGitHubToggleValue ,
2860+ value : newProjectPublishToggleValue ,
28422861 searchTerms : [ ] ,
2843- title : "Create private repository on GitHub" ,
2862+ title :
2863+ newProjectPublishTargets . length > 1
2864+ ? "Create private repository"
2865+ : `Create private repository on ${ newProjectPublishTarget . definition . label } ` ,
28442866 description :
28452867 newProjectName . length > 0
2846- ? getNewProjectGitHubRepository ( newProjectGitHubTarget , newProjectPathPreview )
2847- : ( newProjectGitHubTarget . account ?? "Your GitHub account" ) ,
2848- icon : < GitHubIcon className = { ITEM_ICON_CLASS } /> ,
2868+ ? getNewProjectRepository ( newProjectPublishTarget , newProjectPathPreview )
2869+ : ( newProjectPublishTarget . owner ??
2870+ `Your ${ newProjectPublishTarget . definition . label } account` ) ,
2871+ icon : sourceControlHostIcon ( newProjectPublishTarget . definition , ITEM_ICON_CLASS ) ,
28492872 titleTrailingContent : (
2850- < span className = "pointer-events-none ms-auto flex" >
2851- < Checkbox checked = { newProjectPublishesToGitHub } tabIndex = { - 1 } aria-hidden />
2873+ < span className = "ms-auto flex items-center gap-2" >
2874+ { newProjectPublishTargets . length > 1 ? (
2875+ // The row toggles on click, so the picker keeps its clicks to itself. The
2876+ // row also cancels pointerdown to keep focus in the input, which drops the
2877+ // mousedown Select opens on, so the picker opens on click instead.
2878+ < span
2879+ className = "flex"
2880+ onClick = { ( event ) => {
2881+ event . stopPropagation ( ) ;
2882+ if ( ! isCreatingNewProject ) setNewProjectHostPickerOpen ( true ) ;
2883+ } }
2884+ >
2885+ < Select
2886+ disabled = { isCreatingNewProject }
2887+ open = { newProjectHostPickerOpen }
2888+ onOpenChange = { setNewProjectHostPickerOpen }
2889+ value = { newProjectPublishTarget . definition . kind }
2890+ onValueChange = { ( kind ) => {
2891+ if ( kind !== null ) setNewProjectPublishKind ( kind ) ;
2892+ } }
2893+ >
2894+ < SelectTrigger
2895+ size = "xs"
2896+ variant = "ghost"
2897+ aria-label = "Host for the new repository"
2898+ >
2899+ < SelectValue >
2900+ { ( kind : SourceControlProviderKind ) =>
2901+ sourceControlClients . get ( kind ) . label
2902+ }
2903+ </ SelectValue >
2904+ </ SelectTrigger >
2905+ < SelectPopup align = "end" alignItemWithTrigger = { false } >
2906+ { newProjectPublishTargets . map ( ( target ) => (
2907+ < SelectItem
2908+ key = { target . definition . kind }
2909+ hideIndicator
2910+ value = { target . definition . kind }
2911+ >
2912+ < span className = "inline-flex items-center gap-1.5" >
2913+ { sourceControlHostIcon ( target . definition , "size-3.5" ) }
2914+ { target . definition . label }
2915+ </ span >
2916+ </ SelectItem >
2917+ ) ) }
2918+ </ SelectPopup >
2919+ </ Select >
2920+ </ span >
2921+ ) : null }
2922+ < span className = "pointer-events-none flex" >
2923+ < Checkbox checked = { newProjectPublishes } tabIndex = { - 1 } aria-hidden />
2924+ </ span >
28522925 </ span >
28532926 ) ,
2927+ // The create in flight keeps the choice it started with.
2928+ ...( isCreatingNewProject ? { disabled : true } : { } ) ,
28542929 keepOpen : true ,
28552930 run : async ( ) => {
2856- setNewProjectPublishesToGitHub ( ( publishes ) => ! publishes ) ;
2931+ setNewProjectPublishes ( ( publishes ) => ! publishes ) ;
28572932 } ,
28582933 } ,
28592934 ] ,
@@ -3327,7 +3402,7 @@ function OpenCommandPaletteDialog(props: {
33273402 newProjectFlow !== null
33283403 ? highlightedItemValue === null
33293404 ? "Create"
3330- : highlightedItemValue === newProjectGitHubToggleValue
3405+ : highlightedItemValue === newProjectPublishToggleValue
33313406 ? "Toggle"
33323407 : "Select"
33333408 : addProjectCloneFlow ?. step === "repository"
0 commit comments