Skip to content

Commit 577fca2

Browse files
ndom91krlvischaconByronmtsgrd
authored
feat: finish svelte5 migration (#5709)
Co-authored-by: Kiril Videlov <krlvi@users.noreply.github.com> Co-authored-by: Scott Chacon <schacon@gmail.com> Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com> Co-authored-by: Mattias Granlund <mtsgrd@gmail.com>
1 parent 8eb794d commit 577fca2

File tree

102 files changed

+1283
-906
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1283
-906
lines changed

apps/desktop/src/lib/barmenuActions/FileMenuAction.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@
3636
});
3737
</script>
3838

39-
<svelte:window on:keydown={handleKeyDown} />
39+
<svelte:window onkeydown={handleKeyDown} />

apps/desktop/src/lib/barmenuActions/ReloadMenuAction.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
});
2121
</script>
2222

23-
<svelte:window on:keydown={handleKeyDown} />
23+
<svelte:window onkeydown={handleKeyDown} />

apps/desktop/src/lib/barmenuActions/SwitchThemeMenuAction.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030
});
3131
</script>
3232

33-
<svelte:window on:keydown={handleKeyDown} />
33+
<svelte:window onkeydown={handleKeyDown} />

apps/desktop/src/lib/barmenuActions/ZoomInOutMenuAction.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@
5555
});
5656
</script>
5757

58-
<svelte:window on:keydown={handleKeyDown} />
58+
<svelte:window onkeydown={handleKeyDown} />

apps/desktop/src/lib/branch/BranchLane.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
readonly={selected instanceof RemoteFile}
8484
selectable={$commitBoxOpen && commitId === undefined}
8585
{commitId}
86-
on:close={() => {
86+
onClose={() => {
8787
fileIdSelection.clear();
8888
}}
8989
/>
@@ -92,8 +92,8 @@
9292
direction="right"
9393
minWidth={400}
9494
defaultLineColor="var(--clr-border-2)"
95-
on:width={(e) => {
96-
fileWidth = e.detail / (16 * $userSettings.zoom);
95+
onWidth={(value) => {
96+
fileWidth = value / (16 * $userSettings.zoom);
9797
lscache.set(fileWidthKey + branch.id, fileWidth, 7 * 1440); // 7 day ttl
9898
$defaultFileWidthRem = fileWidth;
9999
}}

apps/desktop/src/lib/branch/BranchPreviewHeader.svelte

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,27 @@
1515
import type { BranchData } from '$lib/vbranches/types';
1616
import { goto } from '$app/navigation';
1717
18-
export let localBranch: BranchData | undefined;
19-
export let remoteBranch: BranchData | undefined;
20-
export let pr: PullRequest | undefined;
18+
interface Props {
19+
localBranch: BranchData | undefined;
20+
remoteBranch: BranchData | undefined;
21+
pr: PullRequest | undefined;
22+
}
23+
24+
const { localBranch, remoteBranch, pr }: Props = $props();
2125
22-
$: branch = remoteBranch || localBranch!;
23-
$: upstream = remoteBranch?.givenName;
26+
const branch = $derived(remoteBranch || localBranch!);
27+
const upstream = $derived(remoteBranch?.givenName);
2428
2529
const branchController = getContext(BranchController);
2630
const project = getContext(Project);
2731
const forge = getForge();
2832
const modeSerivce = getContext(ModeService);
2933
const mode = modeSerivce.mode;
30-
$: forgeBranch = upstream ? $forge?.branch(upstream) : undefined;
34+
const forgeBranch = $derived(upstream ? $forge?.branch(upstream) : undefined);
3135
32-
let isApplying = false;
33-
let isDeleting = false;
34-
let deleteBranchModal: Modal;
36+
let isApplying = $state(false);
37+
let isDeleting = $state(false);
38+
let deleteBranchModal = $state<Modal>();
3539
</script>
3640

3741
<div class="header__wrapper">
@@ -132,7 +136,7 @@
132136
disabled={!localBranch}
133137
onclick={async () => {
134138
if (localBranch) {
135-
deleteBranchModal.show(branch);
139+
deleteBranchModal?.show(branch);
136140
}
137141
}}
138142
>

apps/desktop/src/lib/branch/BranchStatus.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{#if $mergedIncorrectly}
3535
{#if hasParent && parentIsIntegrated}
3636
<InfoMessage style="warning" filled outlined={false}>
37-
<svelte:fragment slot="content">
37+
{#snippet content()}
3838
<p>
3939
This branch appears to have been merged into an already merged branch. If this was a
4040
mistake, you can change the branch name and create a new pull request from the branch
@@ -45,11 +45,11 @@
4545
url: 'https://docs.gitbutler.com/features/stacked-branches#accidentally-merged-a-stack-branch-into-an-already-merged-branch-before-it'
4646
})}
4747
</p>
48-
</svelte:fragment>
48+
{/snippet}
4949
</InfoMessage>
5050
{:else}
5151
<InfoMessage style="warning" filled outlined={false}>
52-
<svelte:fragment slot="content">
52+
{#snippet content()}
5353
<p>
5454
This branch has been merged into a branch different from your target. If this was not
5555
intentional you can force push and create a new pull request from the branch context menu.
@@ -59,21 +59,21 @@
5959
url: 'https://docs.gitbutler.com/features/stacked-branches#accidentally-merged-a-branch-into-a-branch-before-it-not-integrated-into-mainmaster-yet'
6060
})}
6161
</p>
62-
</svelte:fragment>
62+
{/snippet}
6363
</InfoMessage>
6464
{/if}
6565
{/if}
6666

6767
{#if isPushed && hasParent && !parentIsPushed}
6868
<InfoMessage style="warning" filled outlined={false}>
69-
<svelte:fragment slot="content">
69+
{#snippet content()}
7070
<p>
7171
This branch is based on a branch that has been deleted from the remote. If this was not
7272
intentional you can force push to recreate the branch.
7373
</p>
7474
<p>
7575
{@render links({ url: 'https://docs.gitbutler.com/features/stacked-branches' })}
7676
</p>
77-
</svelte:fragment>
77+
{/snippet}
7878
</InfoMessage>
7979
{/if}

apps/desktop/src/lib/branch/PassphraseBox.svelte

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
import Textbox from '@gitbutler/ui/Textbox.svelte';
55
import type { SystemPromptHandle } from '$lib/backend/prompt';
66
7-
export let prompt: SystemPromptHandle | undefined;
8-
export let error: any;
9-
export let value: string = '';
7+
interface Props {
8+
prompt: SystemPromptHandle | undefined;
9+
error: any;
10+
value?: string;
11+
}
12+
13+
let { prompt, error, value = $bindable('') }: Props = $props();
1014
1115
let submitDisabled: boolean = false;
12-
let isSubmitting = false;
16+
let isSubmitting = $state(false);
1317
1418
async function submit() {
1519
if (!prompt) return;

apps/desktop/src/lib/commit/CommitDialog.svelte

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
import { tick } from 'svelte';
1212
import type { Writable } from 'svelte/store';
1313
14-
export let projectId: string;
15-
export let expanded: Writable<boolean>;
16-
export let hasSectionsAfter: boolean;
14+
interface Props {
15+
projectId: string;
16+
expanded: Writable<boolean>;
17+
hasSectionsAfter: boolean;
18+
}
19+
20+
const { projectId, expanded, hasSectionsAfter }: Props = $props();
1721
1822
const branchController = getContext(BranchController);
1923
const selectedOwnership = getContextStore(SelectedOwnership);
@@ -22,10 +26,10 @@
2226
const runCommitHooks = projectRunCommitHooks(projectId);
2327
const commitMessage = persistedCommitMessage(projectId, $branch.id);
2428
25-
let commitMessageInput: CommitMessageInput;
26-
let isCommitting = false;
27-
let commitMessageValid = false;
28-
let isInViewport = false;
29+
let commitMessageInput = $state<CommitMessageInput>();
30+
let isCommitting = $state(false);
31+
let commitMessageValid = $state(false);
32+
let isInViewport = $state(false);
2933
3034
async function commit() {
3135
const message = $commitMessage;
@@ -51,7 +55,7 @@
5155
export async function focus() {
5256
$expanded = true;
5357
await tick();
54-
commitMessageInput.focus();
58+
commitMessageInput?.focus();
5559
}
5660
</script>
5761

apps/desktop/src/lib/commit/CommitMessageInput.svelte

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import Textarea from '@gitbutler/ui/Textarea.svelte';
2323
import Tooltip from '@gitbutler/ui/Tooltip.svelte';
2424
import { isWhiteSpaceString } from '@gitbutler/ui/utils/string';
25-
import { createEventDispatcher, onMount, tick } from 'svelte';
25+
import { onMount, tick } from 'svelte';
2626
2727
interface Props {
2828
existingCommit?: DetailedCommit | Commit;
@@ -48,10 +48,6 @@
4848
const project = getContext(Project);
4949
const promptService = getContext(PromptService);
5050
51-
const dispatch = createEventDispatcher<{
52-
action: 'generate-branch-name';
53-
}>();
54-
5551
const aiGenEnabled = projectAiGenEnabled(project.id);
5652
const commitGenerationExtraConcise = projectCommitGenerationExtraConcise(project.id);
5753
const commitGenerationUseEmojis = projectCommitGenerationUseEmojis(project.id);
@@ -62,7 +58,7 @@
6258
let titleTextArea: HTMLTextAreaElement | undefined = $state();
6359
let descriptionTextArea: HTMLTextAreaElement | undefined = $state();
6460
65-
let { title, description } = $derived(splitMessage(commitMessage));
61+
const { title, description } = $derived(splitMessage(commitMessage));
6662
$effect(() => {
6763
valid = !!title;
6864
});
@@ -95,14 +91,6 @@
9591
async function generateCommitMessage() {
9692
const diffInput = await getDiffInput();
9793
98-
// Branches get their names generated only if there are at least 4 lines of code
99-
// If the change is a 'one-liner', the branch name is either left as "virtual branch"
100-
// or the user has to manually trigger the name generation from the meatball menu
101-
// This saves people this extra click
102-
if ($branch.name.toLowerCase().includes('lane')) {
103-
dispatch('action', 'generate-branch-name');
104-
}
105-
10694
aiLoading = true;
10795
10896
const prompt = promptService.selectedCommitPrompt(project.id);

0 commit comments

Comments
 (0)