Prevent commit when no files selected

This commit is contained in:
Mattias Granlund 2023-12-23 18:13:33 +02:00
parent 56b50af8ae
commit 5209087b8d
3 changed files with 7 additions and 4 deletions

View File

@ -63,4 +63,8 @@ export class Ownership {
.map(([fileId, hunks]) => fileId + ':' + Array.from(hunks.values()).join(','))
.join('\n');
}
isEmpty() {
return this.files.size == 0;
}
}

View File

@ -75,7 +75,7 @@
<div class="header" bind:this={headerElement}>
<div class="header__left">
{#if showCheckboxes && selectedListMode == 'list'}
{#if showCheckboxes && selectedListMode == 'list' && branch.files.length > 1}
<Checkbox
small
{checked}

View File

@ -12,7 +12,7 @@
projectCommitGenerationUseEmojis,
projectRunCommitHooks
} from '$lib/config/config';
import { Ownership } from '$lib/vbranches/ownership';
import type { Ownership } from '$lib/vbranches/ownership';
import Button from '$lib/components/Button.svelte';
import DropDown from '$lib/components/DropDown.svelte';
import ContextMenuItem from '$lib/components/contextmenu/ContextMenuItem.svelte';
@ -51,7 +51,6 @@
function commit() {
isCommitting = true;
selectedOwnership.set(Ownership.fromBranch(branch));
branchController
.commitBranch(branch.id, commitMessage, $selectedOwnership.toString(), $runCommitHooks)
.then(() => {
@ -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) {