mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-24 01:51:57 +03:00
Add option to copy PR URL to clipboard
This commit is contained in:
parent
8b35614188
commit
a247f08802
@ -1,7 +1,9 @@
|
||||
<script lang="ts">
|
||||
import Tag from '$lib/components/Tag.svelte';
|
||||
import ViewPrContextMenu from '$lib/components/ViewPrContextMenu.svelte';
|
||||
import { normalizeBranchName } from '$lib/utils/branch';
|
||||
import { open } from '@tauri-apps/api/shell';
|
||||
import { onDestroy } from 'svelte';
|
||||
import type { Persisted } from '$lib/persisted/persisted';
|
||||
import type { BaseBranch, Branch } from '$lib/vbranches/types';
|
||||
|
||||
@ -11,6 +13,22 @@
|
||||
export let isUnapplied = false;
|
||||
export let hasIntegratedCommits = false;
|
||||
export let isLaneCollapsed: Persisted<boolean>;
|
||||
|
||||
function updateContextMenu() {
|
||||
if (popupMenu) popupMenu.$destroy();
|
||||
return new ViewPrContextMenu({
|
||||
target: document.body,
|
||||
props: { prUrl: prUrl || '' }
|
||||
});
|
||||
}
|
||||
|
||||
$: popupMenu = updateContextMenu();
|
||||
|
||||
onDestroy(() => {
|
||||
if (popupMenu) {
|
||||
popupMenu.$destroy();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if !branch.upstream}
|
||||
@ -86,6 +104,10 @@
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}}
|
||||
on:contextmenu={(e) => {
|
||||
e.preventDefault();
|
||||
popupMenu.openByMouse(e, undefined);
|
||||
}}
|
||||
>
|
||||
View PR
|
||||
</Tag>
|
||||
|
@ -45,6 +45,7 @@
|
||||
class:verticalOrientation
|
||||
class:not-button={!clickable}
|
||||
on:click
|
||||
on:contextmenu
|
||||
role={clickable ? 'button' : undefined}
|
||||
class:clickable
|
||||
use:tooltip={help}
|
||||
|
28
gitbutler-ui/src/lib/components/ViewPrContextMenu.svelte
Normal file
28
gitbutler-ui/src/lib/components/ViewPrContextMenu.svelte
Normal file
@ -0,0 +1,28 @@
|
||||
<script lang="ts">
|
||||
import PopupMenu from '$lib/components/PopupMenu.svelte';
|
||||
import ContextMenu from '$lib/components/contextmenu/ContextMenu.svelte';
|
||||
import ContextMenuItem from '$lib/components/contextmenu/ContextMenuItem.svelte';
|
||||
import ContextMenuSection from '$lib/components/contextmenu/ContextMenuSection.svelte';
|
||||
import { copyToClipboard } from '$lib/utils/clipboard';
|
||||
|
||||
export let prUrl: string;
|
||||
let popupMenu: PopupMenu;
|
||||
|
||||
export function openByMouse(e: MouseEvent, item: any) {
|
||||
popupMenu.openByMouse(e, item);
|
||||
}
|
||||
</script>
|
||||
|
||||
<PopupMenu bind:this={popupMenu} let:dismiss>
|
||||
<ContextMenu>
|
||||
<ContextMenuSection>
|
||||
<ContextMenuItem
|
||||
label="Copy to Clipbaord"
|
||||
on:click={() => {
|
||||
copyToClipboard(prUrl);
|
||||
dismiss();
|
||||
}}
|
||||
/>
|
||||
</ContextMenuSection>
|
||||
</ContextMenu>
|
||||
</PopupMenu>
|
Loading…
Reference in New Issue
Block a user