Enable adding blank commit with no commits already made

This commit is contained in:
Caleb Owens 2024-06-03 16:18:54 +02:00
parent 1771d8dcd2
commit 2658c37f87

View File

@ -75,12 +75,12 @@
return 'remote';
}
function insertBlankCommit(commit: Commit | RemoteCommit, location: 'above' | 'below' = 'below') {
function insertBlankCommit(commitId: string, location: 'above' | 'below' = 'below') {
if (!$branch || !$baseBranch) {
console.error('Unable to insert commit');
return;
}
branchController.insertBlankCommit($branch.id, commit.id, location == 'above' ? -1 : 1);
branchController.insertBlankCommit($branch.id, commitId, location == 'above' ? -1 : 1);
}
</script>
@ -120,19 +120,24 @@
</CommitCard>
{/each}
{/if}
<QuickActionMenu
offset={$localCommits.length == 0 &&
$remoteCommits.length == 0 &&
$integratedCommits.length == 0
? 0
: 0.75}
padding={1}
>
<Button style="ghost" size="tag" on:click={() => insertBlankCommit($branch.head, 'above')}
>Insert blank commit</Button
>
</QuickActionMenu>
<!-- LOCAL COMMITS -->
{#if $localCommits.length > 0}
<ReorderDropzone
index={reorderDropzoneIndexer.topDropzoneIndex}
indexer={reorderDropzoneIndexer}
/>
<QuickActionMenu offset={0.75} padding={1}>
<Button
style="ghost"
size="tag"
on:click={() => insertBlankCommit($localCommits[0], 'above')}>Insert blank commit</Button
>
</QuickActionMenu>
{#each $localCommits as commit, idx (commit.id)}
<CommitCard
{commit}
@ -173,7 +178,7 @@
padding={1}
offset={$remoteCommits.length > 0 && idx + 1 == $localCommits.length ? 0.25 : 0}
>
<Button style="ghost" size="tag" on:click={() => insertBlankCommit(commit, 'below')}
<Button style="ghost" size="tag" on:click={() => insertBlankCommit(commit.id, 'below')}
>Insert blank commit</Button
>
</QuickActionMenu>
@ -215,7 +220,7 @@
indexer={reorderDropzoneIndexer}
/>
<QuickActionMenu padding={1}>
<Button style="ghost" size="tag" on:click={() => insertBlankCommit(commit, 'below')}
<Button style="ghost" size="tag" on:click={() => insertBlankCommit(commit.id, 'below')}
>Insert blank commit</Button
>
</QuickActionMenu>