From 213bf0a7ccd0ef1d9ca797fd78b6bb2e6a6bd929 Mon Sep 17 00:00:00 2001 From: Mattias Granlund Date: Fri, 25 Oct 2024 14:33:17 +0200 Subject: [PATCH] Fix "copy PR link" in context menu --- apps/desktop/src/lib/branch/BranchHeader.svelte | 2 +- .../src/lib/branch/BranchLaneContextMenu.svelte | 9 +++++---- .../desktop/src/lib/branch/StackingSeriesHeader.svelte | 2 +- .../lib/branch/StackingSeriesHeaderContextMenu.svelte | 10 ++++++---- apps/desktop/src/lib/stack/StackHeader.svelte | 1 - 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/desktop/src/lib/branch/BranchHeader.svelte b/apps/desktop/src/lib/branch/BranchHeader.svelte index b52753064..8637f9711 100644 --- a/apps/desktop/src/lib/branch/BranchHeader.svelte +++ b/apps/desktop/src/lib/branch/BranchHeader.svelte @@ -214,7 +214,7 @@ target={meatballButtonEl} onCollapse={collapseLane} {onGenerateBranchName} - hasPr={!!$pr} + prUrl={$pr?.htmlUrl} openPrDetailsModal={handleOpenPR} reloadPR={handleReloadPR} onopen={() => (isContexMenuOpen = true)} diff --git a/apps/desktop/src/lib/branch/BranchLaneContextMenu.svelte b/apps/desktop/src/lib/branch/BranchLaneContextMenu.svelte index f409375e4..2389b9163 100644 --- a/apps/desktop/src/lib/branch/BranchLaneContextMenu.svelte +++ b/apps/desktop/src/lib/branch/BranchLaneContextMenu.svelte @@ -7,6 +7,7 @@ import ContextMenuSection from '$lib/components/contextmenu/ContextMenuSection.svelte'; import { projectAiGenEnabled } from '$lib/config/config'; import { stackingFeature } from '$lib/config/uiFeatureFlags'; + import { copyToClipboard } from '$lib/utils/clipboard'; import { BranchController } from '$lib/vbranches/branchController'; import { VirtualBranch } from '$lib/vbranches/types'; import { getContext, getContextStore } from '@gitbutler/shared/context'; @@ -17,7 +18,7 @@ import Tooltip from '@gitbutler/ui/Tooltip.svelte'; interface Props { - hasPr: boolean; + prUrl?: string; contextMenuEl?: ReturnType; target?: HTMLElement; onCollapse: () => void; @@ -33,7 +34,7 @@ target, onCollapse, onGenerateBranchName, - hasPr, + prUrl, openPrDetailsModal, reloadPR, onopen, @@ -167,7 +168,7 @@ - {#if !$stackingFeature && hasPr} + {#if !$stackingFeature && prUrl} { - reloadPR?.(); + copyToClipboard(prUrl); contextMenuEl?.close(); }} /> diff --git a/apps/desktop/src/lib/branch/StackingSeriesHeader.svelte b/apps/desktop/src/lib/branch/StackingSeriesHeader.svelte index b36ed986f..0bae20077 100644 --- a/apps/desktop/src/lib/branch/StackingSeriesHeader.svelte +++ b/apps/desktop/src/lib/branch/StackingSeriesHeader.svelte @@ -138,7 +138,7 @@ {addDescription} onGenerateBranchName={generateBranchName} hasGitHostBranch={!!gitHostBranch} - hasPr={!!$pr} + prUrl={$pr?.htmlUrl} openPrDetailsModal={handleOpenPR} reloadPR={handleReloadPR} onopen={() => (contextMenuOpened = true)} diff --git a/apps/desktop/src/lib/branch/StackingSeriesHeaderContextMenu.svelte b/apps/desktop/src/lib/branch/StackingSeriesHeaderContextMenu.svelte index 197681471..756577e13 100644 --- a/apps/desktop/src/lib/branch/StackingSeriesHeaderContextMenu.svelte +++ b/apps/desktop/src/lib/branch/StackingSeriesHeaderContextMenu.svelte @@ -5,6 +5,7 @@ import ContextMenuItem from '$lib/components/contextmenu/ContextMenuItem.svelte'; import ContextMenuSection from '$lib/components/contextmenu/ContextMenuSection.svelte'; import { projectAiGenEnabled } from '$lib/config/config'; + import { copyToClipboard } from '$lib/utils/clipboard'; import { BranchController } from '$lib/vbranches/branchController'; import { VirtualBranch } from '$lib/vbranches/types'; import { getContext, getContextStore } from '@gitbutler/shared/context'; @@ -18,7 +19,7 @@ headName: string; seriesCount: number; hasGitHostBranch: boolean; - hasPr: boolean; + prUrl?: string; addDescription: () => void; onGenerateBranchName: () => void; openPrDetailsModal: () => void; @@ -33,7 +34,7 @@ seriesCount, hasGitHostBranch, headName, - hasPr, + prUrl, addDescription, onGenerateBranchName, openPrDetailsModal, @@ -101,7 +102,7 @@ /> {/if} - {#if hasPr} + {#if prUrl} { - reloadPR?.(); + console.log(prUrl); + copyToClipboard(prUrl); contextMenuEl?.close(); }} /> diff --git a/apps/desktop/src/lib/stack/StackHeader.svelte b/apps/desktop/src/lib/stack/StackHeader.svelte index f4672d0ae..c3dc4cf46 100644 --- a/apps/desktop/src/lib/stack/StackHeader.svelte +++ b/apps/desktop/src/lib/stack/StackHeader.svelte @@ -125,7 +125,6 @@ bind:contextMenuEl={contextMenu} target={meatballButtonEl} onCollapse={collapseLane} - hasPr={false} onopen={() => (isContextMenuOpen = true)} onclose={() => (isContextMenuOpen = false)} />