From 5209087b8dcdee256e238ddcc375caf5da365191 Mon Sep 17 00:00:00 2001 From: Mattias Granlund Date: Sat, 23 Dec 2023 18:13:33 +0200 Subject: [PATCH] Prevent commit when no files selected --- gitbutler-ui/src/lib/vbranches/ownership.ts | 4 ++++ .../src/routes/[projectId]/components/BranchFiles.svelte | 2 +- .../src/routes/[projectId]/components/CommitDialog.svelte | 5 ++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gitbutler-ui/src/lib/vbranches/ownership.ts b/gitbutler-ui/src/lib/vbranches/ownership.ts index 144192f3a..113c75a4f 100644 --- a/gitbutler-ui/src/lib/vbranches/ownership.ts +++ b/gitbutler-ui/src/lib/vbranches/ownership.ts @@ -63,4 +63,8 @@ export class Ownership { .map(([fileId, hunks]) => fileId + ':' + Array.from(hunks.values()).join(',')) .join('\n'); } + + isEmpty() { + return this.files.size == 0; + } } diff --git a/gitbutler-ui/src/routes/[projectId]/components/BranchFiles.svelte b/gitbutler-ui/src/routes/[projectId]/components/BranchFiles.svelte index 841f929ae..30389f1cd 100644 --- a/gitbutler-ui/src/routes/[projectId]/components/BranchFiles.svelte +++ b/gitbutler-ui/src/routes/[projectId]/components/BranchFiles.svelte @@ -75,7 +75,7 @@
- {#if showCheckboxes && selectedListMode == 'list'} + {#if showCheckboxes && selectedListMode == 'list' && branch.files.length > 1} { @@ -203,7 +202,7 @@ grow color="primary" kind="filled" - disabled={(isCommitting || !commitMessage) && $expanded} + disabled={(isCommitting || !commitMessage || $selectedOwnership.isEmpty()) && $expanded} id="commit-to-branch" on:click={() => { if ($expanded) {