|
1 | 1 | <script lang="ts"> |
2 | 2 | import { goto } from '$app/navigation'; |
3 | 3 | import DecorativeSplitView from '$components/DecorativeSplitView.svelte'; |
4 | | - import KeysForm from '$components/KeysForm.svelte'; |
5 | 4 | import ProjectSetupTarget from '$components/ProjectSetupTarget.svelte'; |
6 | 5 | import ReduxResult from '$components/ReduxResult.svelte'; |
7 | 6 | import { OnboardingEvent, POSTHOG_WRAPPER } from '$lib/analytics/posthog'; |
8 | 7 | import newProjectSvg from '$lib/assets/illustrations/new-project.svg?raw'; |
9 | | - import { BACKEND } from '$lib/backend'; |
10 | 8 | import { BASE_BRANCH_SERVICE } from '$lib/baseBranch/baseBranchService.svelte'; |
11 | 9 | import { PROJECTS_SERVICE } from '$lib/project/projectsService'; |
12 | 10 | import { inject } from '@gitbutler/core/context'; |
13 | | - import { Button, TestId } from '@gitbutler/ui'; |
| 11 | + import { TestId } from '@gitbutler/ui'; |
14 | 12 | import type { RemoteBranchInfo } from '$lib/baseBranch/baseBranch'; |
15 | 13 |
|
16 | 14 | interface Props { |
|
23 | 21 | const projectsService = inject(PROJECTS_SERVICE); |
24 | 22 | const baseService = inject(BASE_BRANCH_SERVICE); |
25 | 23 | const posthog = inject(POSTHOG_WRAPPER); |
26 | | - const backend = inject(BACKEND); |
27 | 24 | const projectQuery = $derived(projectsService.getProject(projectId)); |
28 | | - const [setBaseBranchTarget, settingBranch] = baseService.setTarget; |
| 25 | + const [setBaseBranchTarget] = baseService.setTarget; |
29 | 26 |
|
30 | | - let selectedBranch = $state(['', '']); |
31 | | -
|
32 | | - async function setTarget() { |
33 | | - if (!selectedBranch[0] || selectedBranch[0] === '') return; |
| 27 | + async function setTarget(branch: string[]) { |
| 28 | + if (!branch[0] || branch[0] === '') return; |
34 | 29 |
|
35 | 30 | try { |
36 | 31 | await setBaseBranchTarget({ |
37 | 32 | projectId: projectId, |
38 | | - branch: selectedBranch[0], |
39 | | - pushRemote: selectedBranch[1] |
| 33 | + branch: branch[0], |
| 34 | + pushRemote: branch[1] |
40 | 35 | }); |
41 | 36 | posthog.captureOnboarding(OnboardingEvent.SetTargetBranch); |
42 | 37 | goto(`/${projectId}/`, { invalidateAll: true }); |
|
54 | 49 | </script> |
55 | 50 |
|
56 | 51 | <DecorativeSplitView img={newProjectSvg} testId={TestId.ProjectSetupPage}> |
57 | | - {#if selectedBranch[0] && selectedBranch[0] !== '' && backend.platformName !== 'windows'} |
58 | | - {@const [remoteName, branchName] = selectedBranch[0].split(/\/(.*)/s)} |
59 | | - <KeysForm {projectId} {remoteName} {branchName} disabled={settingBranch.current.isLoading} /> |
60 | | - <div class="actions"> |
61 | | - <Button |
62 | | - kind="outline" |
63 | | - disabled={settingBranch.current.isLoading} |
64 | | - onclick={() => (selectedBranch[0] = '')} |
65 | | - > |
66 | | - Back |
67 | | - </Button> |
68 | | - <Button |
69 | | - style="pop" |
70 | | - loading={settingBranch.current.isLoading} |
71 | | - onclick={setTarget} |
72 | | - testId={TestId.ProjectSetupGitAuthPageButton}>Let's go!</Button |
73 | | - > |
74 | | - </div> |
75 | | - {:else} |
76 | | - <ReduxResult {projectId} result={projectQuery.result}> |
77 | | - {#snippet children(project)} |
78 | | - <ProjectSetupTarget |
79 | | - {projectId} |
80 | | - projectName={project.title} |
81 | | - {remoteBranches} |
82 | | - onBranchSelected={async (branch) => { |
83 | | - selectedBranch = branch; |
84 | | - if (backend.platformName !== 'windows') return; |
85 | | - setTarget(); |
86 | | - }} |
87 | | - /> |
88 | | - {/snippet} |
89 | | - </ReduxResult> |
90 | | - {/if} |
| 52 | + <ReduxResult {projectId} result={projectQuery.result}> |
| 53 | + {#snippet children(project)} |
| 54 | + <ProjectSetupTarget |
| 55 | + {projectId} |
| 56 | + projectName={project.title} |
| 57 | + {remoteBranches} |
| 58 | + onBranchSelected={async (branch) => { |
| 59 | + await setTarget(branch); |
| 60 | + }} |
| 61 | + /> |
| 62 | + {/snippet} |
| 63 | + </ReduxResult> |
91 | 64 | </DecorativeSplitView> |
92 | | - |
93 | | -<style lang="postcss"> |
94 | | - .actions { |
95 | | - margin-top: 20px; |
96 | | - text-align: right; |
97 | | - } |
98 | | -</style> |
0 commit comments