From 2f9dd738cf796243cd775b5b9bcf63e8aced00f9 Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Mon, 11 Sep 2023 15:24:47 +0200 Subject: [PATCH] partial commit ui --- .../ui/src/lib/vbranches/branchController.ts | 4 +- .../routes/repo/[projectId]/BranchLane.svelte | 11 ++- .../repo/[projectId]/CommitDialog.svelte | 11 ++- .../routes/repo/[projectId]/FileTree.svelte | 81 ++++++++++++++++++- .../repo/[projectId]/FileTreeTabPanel.svelte | 21 ++++- 5 files changed, 121 insertions(+), 7 deletions(-) diff --git a/packages/ui/src/lib/vbranches/branchController.ts b/packages/ui/src/lib/vbranches/branchController.ts index 2c26ca21a..f7f73e393 100644 --- a/packages/ui/src/lib/vbranches/branchController.ts +++ b/packages/ui/src/lib/vbranches/branchController.ts @@ -28,9 +28,9 @@ export class BranchController { } } - async commitBranch(branch: string, message: string) { + async commitBranch(params: { branch: string; message: string; ownership?: string }) { try { - await invoke('commit_virtual_branch', { projectId: this.projectId, branch, message }); + await invoke('commit_virtual_branch', { projectId: this.projectId, ...params }); await this.virtualBranchStore.reload(); } catch (err) { toasts.error('Failed to commit branch'); diff --git a/packages/ui/src/routes/repo/[projectId]/BranchLane.svelte b/packages/ui/src/routes/repo/[projectId]/BranchLane.svelte index db4ea0625..3eb99e7f8 100644 --- a/packages/ui/src/routes/repo/[projectId]/BranchLane.svelte +++ b/packages/ui/src/routes/repo/[projectId]/BranchLane.svelte @@ -28,6 +28,7 @@ import IconBackspace from '$lib/icons/IconBackspace.svelte'; import { sortLikeFileTree } from '$lib/vbranches/filetree'; import CommitDialog from './CommitDialog.svelte'; + import { writable } from 'svelte/store'; const [send, receive] = crossfade({ duration: (d) => Math.sqrt(d * 200), @@ -158,6 +159,9 @@ } }); }); + + const selectedFileIds = writable(branch.files.map((f) => f.id)); + $: selectedFileIds.set(branch.files.map((f) => f.id));
{/if} @@ -298,7 +303,11 @@ name: 'files', displayName: 'Changed files (' + branch.files.length + ')', component: FileTreeTabPanel, - props: { files: branch.files } + props: { + files: branch.files, + selectedFileIds, + withCheckboxes: commitDialogShown + } }, { name: 'notes', diff --git a/packages/ui/src/routes/repo/[projectId]/CommitDialog.svelte b/packages/ui/src/routes/repo/[projectId]/CommitDialog.svelte index eb9258f4e..cb20eece3 100644 --- a/packages/ui/src/routes/repo/[projectId]/CommitDialog.svelte +++ b/packages/ui/src/routes/repo/[projectId]/CommitDialog.svelte @@ -16,14 +16,23 @@ export let cloudEnabled: boolean; export let cloud: ReturnType; export let user: User | null; + export let selectedFileIds: string[]; const dispatch = createEventDispatcher<{ close: null }>(); let commitMessage: string; $: messageRows = Math.min(Math.max(commitMessage ? commitMessage.split('\n').length : 0, 1), 10); + $: ownership = branch.files + .filter((f) => selectedFileIds.includes(f.id)) + .map((f) => { + return f.id + ':' + f.hunks.map((h) => h.id).join(','); + }) + .join('\n'); + $: console.log(ownership) + function commit() { - branchController.commitBranch(branch.id, commitMessage); + branchController.commitBranch({ branch: branch.id, message: commitMessage, ownership }); } export function git_get_config(params: { key: string }) { diff --git a/packages/ui/src/routes/repo/[projectId]/FileTree.svelte b/packages/ui/src/routes/repo/[projectId]/FileTree.svelte index 8cd8e3caf..d7e628899 100644 --- a/packages/ui/src/routes/repo/[projectId]/FileTree.svelte +++ b/packages/ui/src/routes/repo/[projectId]/FileTree.svelte @@ -3,6 +3,7 @@ - +