mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-20 16:11:46 +03:00
Only show "Force push to remote" when pushing zero commits to a branch
This commit is contained in:
parent
37c9ccfe28
commit
088cf5a4bb
@ -75,9 +75,9 @@
|
|||||||
<PushButton
|
<PushButton
|
||||||
wide
|
wide
|
||||||
isLoading={isPushing || $githubServiceState$?.busy}
|
isLoading={isPushing || $githubServiceState$?.busy}
|
||||||
isPushed={type == 'remote' && !branch.requiresForce}
|
|
||||||
requiresForcePush={branch.requiresForce}
|
|
||||||
isPr={!!$pr$}
|
isPr={!!$pr$}
|
||||||
|
{type}
|
||||||
|
{branch}
|
||||||
{projectId}
|
{projectId}
|
||||||
githubEnabled={$githubEnabled$}
|
githubEnabled={$githubEnabled$}
|
||||||
on:trigger={async (e) => {
|
on:trigger={async (e) => {
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Button from '$lib/components/Button.svelte';
|
import Button from '$lib/components/Button.svelte';
|
||||||
|
import type { Branch } from '$lib/vbranches/types';
|
||||||
import DropDownButton from '$lib/components/DropDownButton.svelte';
|
import DropDownButton from '$lib/components/DropDownButton.svelte';
|
||||||
import ContextMenu from '$lib/components/contextmenu/ContextMenu.svelte';
|
import ContextMenu from '$lib/components/contextmenu/ContextMenu.svelte';
|
||||||
import ContextMenuItem from '$lib/components/contextmenu/ContextMenuItem.svelte';
|
import ContextMenuItem from '$lib/components/contextmenu/ContextMenuItem.svelte';
|
||||||
@ -17,11 +18,11 @@
|
|||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
|
|
||||||
export let projectId: string;
|
export let projectId: string;
|
||||||
export let isPushed: boolean;
|
export let type: string;
|
||||||
export let isLoading = false;
|
export let isLoading = false;
|
||||||
export let githubEnabled: boolean;
|
export let githubEnabled: boolean;
|
||||||
export let wide = false;
|
export let wide = false;
|
||||||
export let requiresForcePush = false;
|
export let branch: Branch;
|
||||||
export let isPr = false;
|
export let isPr = false;
|
||||||
|
|
||||||
function defaultAction(projectId: string): Persisted<BranchAction> {
|
function defaultAction(projectId: string): Persisted<BranchAction> {
|
||||||
@ -37,7 +38,12 @@
|
|||||||
let disabled = false;
|
let disabled = false;
|
||||||
|
|
||||||
$: selection$ = contextMenu?.selection$;
|
$: selection$ = contextMenu?.selection$;
|
||||||
$: action = selectAction($preferredAction);
|
|
||||||
|
let action!: BranchAction;
|
||||||
|
$: {
|
||||||
|
isPushed; // selectAction is dependant on isPushed
|
||||||
|
action = selectAction($preferredAction);
|
||||||
|
}
|
||||||
|
|
||||||
function selectAction(preferredAction: BranchAction) {
|
function selectAction(preferredAction: BranchAction) {
|
||||||
if (isPushed && !githubEnabled) {
|
if (isPushed && !githubEnabled) {
|
||||||
@ -53,10 +59,12 @@
|
|||||||
return preferredAction;
|
return preferredAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
$: pushLabel = requiresForcePush ? 'Force push to remote' : 'Push to remote';
|
$: pushLabel = branch.requiresForce ? 'Force push to remote' : 'Push to remote';
|
||||||
|
$: commits = branch.commits.filter((c) => c.status == type);
|
||||||
|
$: isPushed = type === 'remote' && !branch.requiresForce;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if isPr && !isPushed}
|
{#if (isPr || commits.length === 0) && !isPushed}
|
||||||
<Button
|
<Button
|
||||||
color="primary"
|
color="primary"
|
||||||
kind="outlined"
|
kind="outlined"
|
||||||
|
Loading…
Reference in New Issue
Block a user