Fix "copy PR link" in context menu

This commit is contained in:
Mattias Granlund 2024-10-25 14:33:17 +02:00
parent ed84a25334
commit 213bf0a7cc
5 changed files with 13 additions and 11 deletions

View File

@ -214,7 +214,7 @@
target={meatballButtonEl}
onCollapse={collapseLane}
{onGenerateBranchName}
hasPr={!!$pr}
prUrl={$pr?.htmlUrl}
openPrDetailsModal={handleOpenPR}
reloadPR={handleReloadPR}
onopen={() => (isContexMenuOpen = true)}

View File

@ -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<typeof ContextMenu>;
target?: HTMLElement;
onCollapse: () => void;
@ -33,7 +34,7 @@
target,
onCollapse,
onGenerateBranchName,
hasPr,
prUrl,
openPrDetailsModal,
reloadPR,
onopen,
@ -167,7 +168,7 @@
</ContextMenuItem>
</ContextMenuSection>
{#if !$stackingFeature && hasPr}
{#if !$stackingFeature && prUrl}
<ContextMenuSection>
<ContextMenuItem
label="PR details"
@ -179,7 +180,7 @@
<ContextMenuItem
label="Copy PR link"
onclick={() => {
reloadPR?.();
copyToClipboard(prUrl);
contextMenuEl?.close();
}}
/>

View File

@ -138,7 +138,7 @@
{addDescription}
onGenerateBranchName={generateBranchName}
hasGitHostBranch={!!gitHostBranch}
hasPr={!!$pr}
prUrl={$pr?.htmlUrl}
openPrDetailsModal={handleOpenPR}
reloadPR={handleReloadPR}
onopen={() => (contextMenuOpened = true)}

View File

@ -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}
</ContextMenuSection>
{#if hasPr}
{#if prUrl}
<ContextMenuSection>
<ContextMenuItem
label="PR details"
@ -113,7 +114,8 @@
<ContextMenuItem
label="Copy PR link"
onclick={() => {
reloadPR?.();
console.log(prUrl);
copyToClipboard(prUrl);
contextMenuEl?.close();
}}
/>

View File

@ -125,7 +125,6 @@
bind:contextMenuEl={contextMenu}
target={meatballButtonEl}
onCollapse={collapseLane}
hasPr={false}
onopen={() => (isContextMenuOpen = true)}
onclose={() => (isContextMenuOpen = false)}
/>