Show the push button when there are differences after undoing commits and the branch requires force pushing

This commit is contained in:
Caleb Owens 2024-02-16 14:31:36 +00:00 committed by Kiril Videlov
parent f708c1568e
commit 5740c16ee8
3 changed files with 80 additions and 58 deletions

View File

@ -25,10 +25,13 @@
$: headCommit = branch.commits[0];
$: commits = type == 'upstream' ? [] : branch.commits.filter((c) => c.status == type);
$: hasCommits = commits && commits.length > 0;
$: remoteRequiresForcePush = type === 'remote' && branch.requiresForce;
let expanded = true;
</script>
{#if commits && commits.length > 0}
{#if hasCommits || remoteRequiresForcePush }
<div
class="commit-list card"
class:upstream={type == 'upstream'}

View File

@ -75,7 +75,9 @@
<PushButton
wide
isLoading={isPushing || $githubServiceState$?.busy}
isPushed={type == 'remote'}
isPushed={type == 'remote' && !branch.requiresForce}
requiresForcePush={branch.requiresForce}
isPr={$pr$}
{projectId}
githubEnabled={$githubEnabled$}
on:trigger={async (e) => {

View File

@ -7,6 +7,7 @@
</script>
<script lang="ts">
import Button from '$lib/components/Button.svelte';
import DropDownButton from '$lib/components/DropDownButton.svelte';
import ContextMenu from '$lib/components/contextmenu/ContextMenu.svelte';
import ContextMenuItem from '$lib/components/contextmenu/ContextMenuItem.svelte';
@ -20,6 +21,8 @@
export let isLoading = false;
export let githubEnabled: boolean;
export let wide = false;
export let requiresForcePush = false;
export let isPr = false;
function defaultAction(projectId: string): Persisted<BranchAction> {
const key = 'projectDefaultAction_';
@ -49,9 +52,22 @@
}
return preferredAction;
}
$: pushLabel = requiresForcePush ? 'Force push to remote' : 'Push to remote'
</script>
<DropDownButton
{#if isPr && requiresForcePush }
<Button
color="primary"
kind="outlined"
{wide}
disabled={isPushed}
on:click={() => {
dispatch('trigger', { action: BranchAction.Push });
}}>{pushLabel}</Button
>
{:else if !isPr }
<DropDownButton
color="primary"
kind="outlined"
loading={isLoading}
@ -61,7 +77,7 @@
on:click={() => {
dispatch('trigger', { action });
}}
>
>
{$selection$?.label}
<ContextMenu
type="select"
@ -88,7 +104,7 @@
<ContextMenuSection>
<ContextMenuItem
id="push"
label="Push to remote"
label={pushLabel}
selected={action == BranchAction.Push}
disabled={isPushed}
/>
@ -106,4 +122,5 @@
/>
</ContextMenuSection>
</ContextMenu>
</DropDownButton>
</DropDownButton>
{/if}