-
Notifications
You must be signed in to change notification settings - Fork 575
/
Copy pathPullRequestButton.svelte
42 lines (39 loc) · 1.14 KB
/
PullRequestButton.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<script lang="ts">
import { getPreferredPRAction, PRAction, PRActionLabels, prActions } from './pr';
import ContextMenuItem from '$lib/components/contextmenu/ContextMenuItem.svelte';
import ContextMenuSection from '$lib/components/contextmenu/ContextMenuSection.svelte';
import DropDownButton from '$lib/shared/DropDownButton.svelte';
type Props = {
loading: boolean;
disabled?: boolean;
tooltip?: string;
click: (opts: { draft: boolean }) => void;
};
const { loading, disabled, tooltip, click }: Props = $props();
const preferredAction = getPreferredPRAction();
let dropDown = $state<ReturnType<typeof DropDownButton>>();
</script>
<DropDownButton
style="ghost"
outline
{tooltip}
{disabled}
{loading}
bind:this={dropDown}
onclick={() => click({ draft: $preferredAction === PRAction.CreateDraft })}
>
{PRActionLabels[$preferredAction]}
{#snippet contextMenuSlot()}
<ContextMenuSection>
{#each prActions as method}
<ContextMenuItem
label={PRActionLabels[method]}
onclick={() => {
preferredAction.set(method);
dropDown?.close();
}}
/>
{/each}
</ContextMenuSection>
{/snippet}
</DropDownButton>