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 3bd8c47 commit e757819
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 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?: (e: MouseEvent) => 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 @@ -38,15 +48,15 @@
{tooltip}
{disabled}
onclick={() => {
dispatch('click', { method: $action });
onclick($action);
}}
>
{labels[$action]}
{#snippet contextMenuSlot()}
<ContextMenuSection>
{#each Object.values(MergeMethod) as method}
<ContextMenuItem
label={labels[method]}
label={labels[method as string]}
onclick={() => {
$action = method;
dropDown?.close();
Expand Down

0 comments on commit e757819

Please sign in to comment.