Skip to content

Commit

Permalink
fix: MergeButton runes
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Nov 28, 2024
1 parent 0b54a0f commit ac2b644
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
30 changes: 19 additions & 11 deletions apps/desktop/src/lib/pr/MergeButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,30 @@
import { MergeMethod } from '$lib/forge/interface/types';
import DropDownButton from '$lib/shared/DropDownButton.svelte';
import { persisted, type Persisted } from '@gitbutler/shared/persisted';
import { createEventDispatcher } from 'svelte';
export let projectId: string;
export let loading = false;
export let disabled = false;
export let wide = false;
export let tooltip = '';
interface Props {
projectId: string;
loading?: boolean;
disabled?: boolean;
wide?: boolean;
tooltip?: string;
onclick?: (method: MergeMethod) => void;
}
const {
projectId,
loading = false,
disabled = false,
wide = false,
tooltip = '',
onclick
}: Props = $props();
function persistedAction(projectId: string): Persisted<MergeMethod> {
const key = 'projectMergeMethod';
return persisted<MergeMethod>(MergeMethod.Merge, key + projectId);
}
const dispatch = createEventDispatcher<{ click: { method: MergeMethod } }>();
const action = persistedAction(projectId);
let dropDown: ReturnType<typeof DropDownButton> | undefined;
Expand All @@ -30,16 +40,14 @@
</script>

<DropDownButton
bind:this={dropDown}
onclick={() => onclick?.($action)}
style="ghost"
outline
{loading}
bind:this={dropDown}
{wide}
{tooltip}
{disabled}
onclick={() => {
dispatch('click', { method: $action });
}}
>
{labels[$action]}
{#snippet contextMenuSlot()}
Expand Down
3 changes: 1 addition & 2 deletions apps/desktop/src/lib/pr/PullRequestCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,9 @@
disabled={mergeStatus.disabled}
tooltip={mergeStatus.tooltip}
loading={isMerging}
on:click={async (e) => {
onclick={async (method) => {
if (!pr) return;
isMerging = true;
const method = e.detail.method;
try {
await $prService?.merge(method, pr.number);
await baseBranchService.fetchFromRemotes();
Expand Down

0 comments on commit ac2b644

Please sign in to comment.