From f58a29fa1c45bf5fed444e530d8a30cac632adfb Mon Sep 17 00:00:00 2001 From: Pavel Laptev Date: Fri, 25 Oct 2024 14:13:57 +0200 Subject: [PATCH] added context menu to the whole hard --- .../src/lib/pr/StackingPullRequestCard.svelte | 138 +++++++++--------- .../src/lib/shared/DropDownButton.svelte | 7 + 2 files changed, 76 insertions(+), 69 deletions(-) diff --git a/apps/desktop/src/lib/pr/StackingPullRequestCard.svelte b/apps/desktop/src/lib/pr/StackingPullRequestCard.svelte index 4107ddf78..8c5c90b18 100644 --- a/apps/desktop/src/lib/pr/StackingPullRequestCard.svelte +++ b/apps/desktop/src/lib/pr/StackingPullRequestCard.svelte @@ -31,10 +31,8 @@ messageStyle?: MessageStyle; }; - let checksContextMenuEl = $state>(); - let prContextMenuEl = $state>(); - let checksContextMenuTarget = $state(); - let prContextMenuTarget = $state(); + let contextMenuEl = $state>(); + let contextMenuTarget = $state(); const vbranchService = getContext(VirtualBranchService); const baseBranchService = getContext(BaseBranchService); @@ -122,7 +120,52 @@ {#if $pr} -
+ + + { + openExternalUrl($pr.htmlUrl); + contextMenuEl?.close(); + }} + /> + { + copyToClipboard($pr.htmlUrl); + contextMenuEl?.close(); + }} + /> + + {#if checksTagInfo && checksTagInfo.text !== 'No PR checks' && checksTagInfo.text === 'Checks'} + + { + openExternalUrl(`${$pr.htmlUrl}/checks`); + contextMenuEl?.close(); + }} + /> + { + copyToClipboard(`${$pr.htmlUrl}/checks`); + contextMenuEl?.close(); + }} + /> + + {/if} + + +
{ + e.preventDefault(); + contextMenuEl?.open(e); + }} + >
PR #{$pr?.number}: {$pr?.title} @@ -140,72 +183,29 @@ {prStatusInfo.text} {#if !$pr?.closedAt && checksTagInfo} -
- -
- - - - { - openExternalUrl(`${$pr.htmlUrl}/checks`); - checksContextMenuEl?.close(); - }} - /> - { - copyToClipboard(`${$pr.htmlUrl}/checks`); - checksContextMenuEl?.close(); - }} - /> - - + {/if} {#if $pr?.htmlUrl} -
- -
- - - - { - copyToClipboard($pr.htmlUrl); - prContextMenuEl?.close(); - }} - /> - - + {/if}
diff --git a/apps/desktop/src/lib/shared/DropDownButton.svelte b/apps/desktop/src/lib/shared/DropDownButton.svelte index a53b95805..998faebbf 100644 --- a/apps/desktop/src/lib/shared/DropDownButton.svelte +++ b/apps/desktop/src/lib/shared/DropDownButton.svelte @@ -42,6 +42,11 @@ let iconEl = $state(); let visible = $state(false); + function preventContextMenu(e: MouseEvent) { + e.preventDefault(); + e.stopPropagation(); + } + export function show() { visible = true; contextMenu?.open(); @@ -66,6 +71,7 @@ disabled={disabled || loading} dropdownChild {onclick} + oncontextmenu={preventContextMenu} > {@render children()} @@ -82,6 +88,7 @@ visible = !visible; contextMenu?.toggle(); }} + oncontextmenu={preventContextMenu} />