diff --git a/apps/desktop/src/lib/branch/BranchCard.svelte b/apps/desktop/src/lib/branch/BranchCard.svelte index 6e9c17802..5b9fcb12e 100644 --- a/apps/desktop/src/lib/branch/BranchCard.svelte +++ b/apps/desktop/src/lib/branch/BranchCard.svelte @@ -113,6 +113,9 @@ let isPushingCommits = $state(false); const localCommitsConflicted = $derived($localCommits.some((commit) => commit.conflicted)); + const localAndRemoteCommitsConflicted = $derived( + $localAndRemoteCommits.some((commit) => commit.conflicted) + ); const listingService = getGitHostListingService(); const prMonitor = getGitHostPrMonitor(); @@ -214,6 +217,21 @@ {/if} + {#snippet pushButton({disabled}: {disabled: boolean})} + + {/snippet} {#if $stackingFeature} {@const groups = groupCommitsByRef(branch.commits)} {#each groups as group (group.ref)} @@ -223,9 +241,8 @@ integratedCommits={group.integratedCommits} remoteCommits={[]} isUnapplied={false} - {isPushingCommits} {localCommitsConflicted} - {push} + {localAndRemoteCommitsConflicted} /> {/each} {:else} @@ -235,24 +252,16 @@ integratedCommits={$integratedCommits} remoteCommits={$remoteCommits} isUnapplied={false} - {isPushingCommits} {localCommitsConflicted} - {push} + {localAndRemoteCommitsConflicted} + {pushButton} /> {/if} - + {#if $stackingFeature} + {@render pushButton({ + disabled: localCommitsConflicted || localAndRemoteCommitsConflicted + })} + {/if} diff --git a/apps/desktop/src/lib/commit/CommitList.svelte b/apps/desktop/src/lib/commit/CommitList.svelte index 40c7ea59f..b93e7723c 100644 --- a/apps/desktop/src/lib/commit/CommitList.svelte +++ b/apps/desktop/src/lib/commit/CommitList.svelte @@ -20,6 +20,7 @@ import Button from '@gitbutler/ui/Button.svelte'; import LineGroup from '@gitbutler/ui/commitLines/LineGroup.svelte'; import { LineManagerFactory } from '@gitbutler/ui/commitLines/lineManager'; + import type { Snippet } from 'svelte'; import { goto } from '$app/navigation'; interface Props { @@ -28,9 +29,9 @@ integratedCommits: DetailedCommit[]; remoteCommits: Commit[]; isUnapplied: boolean; - isPushingCommits: boolean; + pushButton?: Snippet<[{ disabled: boolean }]>; localCommitsConflicted: boolean; - push: () => Promise; + localAndRemoteCommitsConflicted: boolean; } const { localCommits, @@ -38,9 +39,9 @@ integratedCommits, remoteCommits, isUnapplied, - isPushingCommits, localCommitsConflicted, - push + pushButton, + localAndRemoteCommitsConflicted }: Props = $props(); const branch = getContextStore(VirtualBranch); @@ -136,10 +137,6 @@ if (isLast) return 0; return 0; } - - const localAndRemoteCommitsConflicted = $derived( - localAndRemoteCommits.some((commit) => commit.conflicted) - ); {#snippet reorderDropzone(dropzone: ReorderDropzone, yOffsetPx: number)} @@ -238,26 +235,13 @@ on:click={() => insertBlankCommit(commit.id, 'below')} /> {/each} - - {#if !$stackingFeature} + {#if !$stackingFeature && pushButton} {#snippet lines()} {/snippet} {#snippet action()} - + {@render pushButton({ disabled: localCommitsConflicted })} {/snippet} {/if} @@ -294,25 +278,13 @@ /> {/each} - {#if remoteCommits.length > 0 && localCommits.length === 0} + {#if remoteCommits.length > 0 && localCommits.length === 0 && pushButton} {#snippet lines()} {/snippet} {#snippet action()} - + {@render pushButton({ disabled: localAndRemoteCommitsConflicted })} {/snippet} {/if}