@@ -10,9 +10,11 @@ import { |
10 | 10 | getCloneDestinationPath, |
11 | 11 | getCloneDirectoryName, |
12 | 12 | getDefaultCloneUrl, |
13 | | - getNewProjectGitHubRepository, |
14 | | - getNewProjectGitHubTarget, |
15 | 13 | getNewProjectPathPreview, |
| 14 | + getNewProjectPublishTarget, |
| 15 | + getNewProjectPublishTargets, |
| 16 | + getNewProjectRepository, |
| 17 | + type NewProjectPublishTarget, |
16 | 18 | normalizePastedCloneUrl, |
17 | 19 | addProjectRemoteSourceLabel, |
18 | 20 | addProjectRemoteSourcePathHint, |
@@ -195,7 +197,6 @@ import { |
195 | 197 | CommandPaletteVirtualizedResults, |
196 | 198 | scrollCommandPaletteRowIntoView, |
197 | 199 | } from "./CommandPaletteResults"; |
198 | | -import { GitHubIcon } from "./Icons"; |
199 | 200 | import { sourceControlIcon } from "~/sourceControlPresentation"; |
200 | 201 | import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon"; |
201 | 202 | import { Checkbox } from "./ui/checkbox"; |
@@ -221,6 +222,7 @@ import { resolveShortcutCommand, threadJumpIndexFromCommand } from "../keybindin |
221 | 222 | import { CommandDialog, CommandDialogPopup, CommandFooterAction } from "./ui/command"; |
222 | 223 | import { Button } from "./ui/button"; |
223 | 224 | import { Kbd, KbdGroup } from "./ui/kbd"; |
| 225 | +import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./ui/select"; |
224 | 226 | import { stackedThreadToast, toastManager } from "./ui/toast"; |
225 | 227 | import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip"; |
226 | 228 | import { ComposerHandleContext, useComposerHandleContext } from "../composerHandleContext"; |
@@ -280,6 +282,14 @@ function remoteProjectSourceIcon(source: AddProjectRemoteSource, className: stri |
280 | 282 | return <Icon className={className} />; |
281 | 283 | } |
282 | 284 |
|
| 285 | +function sourceControlHostIcon( |
| 286 | + definition: NewProjectPublishTarget["definition"], |
| 287 | + className: string, |
| 288 | +): ReactNode { |
| 289 | + const Icon = sourceControlIcon(definition); |
| 290 | + return <Icon className={className} />; |
| 291 | +} |
| 292 | + |
283 | 293 | function projectFaviconIcon(project: Project): ReactNode { |
284 | 294 | return <ProjectFavicon project={project} className={ITEM_ICON_CLASS} />; |
285 | 295 | } |
@@ -762,7 +772,11 @@ function OpenCommandPaletteDialog(props: { |
762 | 772 | /** Machine of the Add project sources view under this step; null from the palette root. */ |
763 | 773 | readonly sourcesEnvironmentId: EnvironmentId | null; |
764 | 774 | } | 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); |
766 | 780 | const [isCreatingNewProject, setIsCreatingNewProject] = useState(false); |
767 | 781 | // State lags a render behind, so a repeated Enter could start a second create. |
768 | 782 | const newProjectSubmittingRef = useRef(false); |
@@ -1482,7 +1496,8 @@ function OpenCommandPaletteDialog(props: { |
1482 | 1496 | setAddProjectEnvironmentId(environmentId); |
1483 | 1497 | setAddProjectCloneFlow(null); |
1484 | 1498 | setNewProjectFlow({ environmentId, sourcesEnvironmentId }); |
1485 | | - setNewProjectPublishesToGitHub(false); |
| 1499 | + setNewProjectPublishes(false); |
| 1500 | + setNewProjectPublishKind(null); |
1486 | 1501 | pushPaletteView({ |
1487 | 1502 | addonIcon: <FolderGit2Icon className={ADDON_ICON_CLASS} />, |
1488 | 1503 | groups: [], |
@@ -2417,8 +2432,12 @@ function OpenCommandPaletteDialog(props: { |
2417 | 2432 | ], |
2418 | 2433 | ); |
2419 | 2434 |
|
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 | + ); |
2422 | 2441 | const newProjectName = query.trim(); |
2423 | 2442 | const canSubmitNewProject = |
2424 | 2443 | newProjectFlow !== null && |
@@ -2436,7 +2455,7 @@ function OpenCommandPaletteDialog(props: { |
2436 | 2455 | const created = await createNewProject({ |
2437 | 2456 | environmentId: newProjectFlow.environmentId, |
2438 | 2457 | name: newProjectName, |
2439 | | - github: newProjectPublishesToGitHub ? newProjectGitHubTarget : null, |
| 2458 | + publishTo: newProjectPublishes ? newProjectPublishTarget : null, |
2440 | 2459 | }); |
2441 | 2460 | if (created) setOpen(false); |
2442 | 2461 | } finally { |
@@ -2742,7 +2761,7 @@ function OpenCommandPaletteDialog(props: { |
2742 | 2761 | const newProjectsRoot = newProjectFlow ? newProjectsRootFor(newProjectFlow.environmentId) : null; |
2743 | 2762 | const newProjectPathPreview = |
2744 | 2763 | newProjectsRoot === null ? null : getNewProjectPathPreview(newProjectsRoot, newProjectName); |
2745 | | - const newProjectGitHubToggleValue = "new-project:github"; |
| 2764 | + const newProjectPublishToggleValue = "new-project:publish"; |
2746 | 2765 | // The name step's way out to folders and clones, for the selected machine. |
2747 | 2766 | // It replaces the name step (and a sources view for another machine under |
2748 | 2767 | // it), so Back returns to wherever New project was opened from. |
@@ -2829,7 +2848,7 @@ function OpenCommandPaletteDialog(props: { |
2829 | 2848 | ], |
2830 | 2849 | }; |
2831 | 2850 | const newProjectOptionGroups: CommandPaletteView["groups"] = |
2832 | | - newProjectGitHubTarget === null || newProjectPathPreview === null |
| 2851 | + newProjectPublishTarget === null || newProjectPathPreview === null |
2833 | 2852 | ? [] |
2834 | 2853 | : [ |
2835 | 2854 | { |
@@ -2838,22 +2857,75 @@ function OpenCommandPaletteDialog(props: { |
2838 | 2857 | items: [ |
2839 | 2858 | { |
2840 | 2859 | kind: "action", |
2841 | | - value: newProjectGitHubToggleValue, |
| 2860 | + value: newProjectPublishToggleValue, |
2842 | 2861 | 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}`, |
2844 | 2866 | description: |
2845 | 2867 | 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), |
2849 | 2872 | 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 | + setNewProjectHostPickerOpen(true); |
| 2883 | + }} |
| 2884 | + > |
| 2885 | + <Select |
| 2886 | + open={newProjectHostPickerOpen} |
| 2887 | + onOpenChange={setNewProjectHostPickerOpen} |
| 2888 | + value={newProjectPublishTarget.definition.kind} |
| 2889 | + onValueChange={(kind) => { |
| 2890 | + if (kind !== null) setNewProjectPublishKind(kind); |
| 2891 | + }} |
| 2892 | + > |
| 2893 | + <SelectTrigger |
| 2894 | + size="xs" |
| 2895 | + variant="ghost" |
| 2896 | + aria-label="Host for the new repository" |
| 2897 | + > |
| 2898 | + <SelectValue> |
| 2899 | + {(kind: SourceControlProviderKind) => |
| 2900 | + sourceControlClients.get(kind).label |
| 2901 | + } |
| 2902 | + </SelectValue> |
| 2903 | + </SelectTrigger> |
| 2904 | + <SelectPopup align="end" alignItemWithTrigger={false}> |
| 2905 | + {newProjectPublishTargets.map((target) => ( |
| 2906 | + <SelectItem |
| 2907 | + key={target.definition.kind} |
| 2908 | + hideIndicator |
| 2909 | + value={target.definition.kind} |
| 2910 | + > |
| 2911 | + <span className="inline-flex items-center gap-1.5"> |
| 2912 | + {sourceControlHostIcon(target.definition, "size-3.5")} |
| 2913 | + {target.definition.label} |
| 2914 | + </span> |
| 2915 | + </SelectItem> |
| 2916 | + ))} |
| 2917 | + </SelectPopup> |
| 2918 | + </Select> |
| 2919 | + </span> |
| 2920 | + ) : null} |
| 2921 | + <span className="pointer-events-none flex"> |
| 2922 | + <Checkbox checked={newProjectPublishes} tabIndex={-1} aria-hidden /> |
| 2923 | + </span> |
2852 | 2924 | </span> |
2853 | 2925 | ), |
2854 | 2926 | keepOpen: true, |
2855 | 2927 | run: async () => { |
2856 | | - setNewProjectPublishesToGitHub((publishes) => !publishes); |
| 2928 | + setNewProjectPublishes((publishes) => !publishes); |
2857 | 2929 | }, |
2858 | 2930 | }, |
2859 | 2931 | ], |
@@ -3327,7 +3399,7 @@ function OpenCommandPaletteDialog(props: { |
3327 | 3399 | newProjectFlow !== null |
3328 | 3400 | ? highlightedItemValue === null |
3329 | 3401 | ? "Create" |
3330 | | - : highlightedItemValue === newProjectGitHubToggleValue |
| 3402 | + : highlightedItemValue === newProjectPublishToggleValue |
3331 | 3403 | ? "Toggle" |
3332 | 3404 | : "Select" |
3333 | 3405 | : addProjectCloneFlow?.step === "repository" |
|