mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-20 08:01:46 +03:00
feat: add contextMenu to checks and pr btns in StackingPullRequestCard
This commit is contained in:
parent
97c344404f
commit
ffce14296a
@ -2,9 +2,13 @@
|
|||||||
import MergeButton from './MergeButton.svelte';
|
import MergeButton from './MergeButton.svelte';
|
||||||
import { Project } from '$lib/backend/projects';
|
import { Project } from '$lib/backend/projects';
|
||||||
import { BaseBranchService } from '$lib/baseBranch/baseBranchService';
|
import { BaseBranchService } from '$lib/baseBranch/baseBranchService';
|
||||||
|
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 { getGitHostChecksMonitor } from '$lib/gitHost/interface/gitHostChecksMonitor';
|
import { getGitHostChecksMonitor } from '$lib/gitHost/interface/gitHostChecksMonitor';
|
||||||
import { getGitHostListingService } from '$lib/gitHost/interface/gitHostListingService';
|
import { getGitHostListingService } from '$lib/gitHost/interface/gitHostListingService';
|
||||||
import { getGitHostPrService } from '$lib/gitHost/interface/gitHostPrService';
|
import { getGitHostPrService } from '$lib/gitHost/interface/gitHostPrService';
|
||||||
|
import { copyToClipboard } from '$lib/utils/clipboard';
|
||||||
import * as toasts from '$lib/utils/toasts';
|
import * as toasts from '$lib/utils/toasts';
|
||||||
import { openExternalUrl } from '$lib/utils/url';
|
import { openExternalUrl } from '$lib/utils/url';
|
||||||
import { VirtualBranchService } from '$lib/vbranches/virtualBranch';
|
import { VirtualBranchService } from '$lib/vbranches/virtualBranch';
|
||||||
@ -27,6 +31,11 @@
|
|||||||
messageStyle?: MessageStyle;
|
messageStyle?: MessageStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let checksContextMenuEl = $state<ReturnType<typeof ContextMenu>>();
|
||||||
|
let prContextMenuEl = $state<ReturnType<typeof ContextMenu>>();
|
||||||
|
let checksContextMenuTarget = $state<HTMLElement>();
|
||||||
|
let prContextMenuTarget = $state<HTMLElement>();
|
||||||
|
|
||||||
const vbranchService = getContext(VirtualBranchService);
|
const vbranchService = getContext(VirtualBranchService);
|
||||||
const baseBranchService = getContext(BaseBranchService);
|
const baseBranchService = getContext(BaseBranchService);
|
||||||
const project = getContext(Project);
|
const project = getContext(Project);
|
||||||
@ -131,17 +140,41 @@
|
|||||||
{prStatusInfo.text}
|
{prStatusInfo.text}
|
||||||
</Button>
|
</Button>
|
||||||
{#if !$pr?.closedAt && checksTagInfo}
|
{#if !$pr?.closedAt && checksTagInfo}
|
||||||
|
<div bind:this={checksContextMenuTarget}>
|
||||||
<Button
|
<Button
|
||||||
size="tag"
|
size="tag"
|
||||||
clickable={false}
|
clickable={false}
|
||||||
icon={checksTagInfo.icon}
|
icon={checksTagInfo.icon}
|
||||||
style={checksTagInfo.style}
|
style={checksTagInfo.style}
|
||||||
kind={checksTagInfo.icon === 'success-small' ? 'solid' : 'soft'}
|
kind={checksTagInfo.icon === 'success-small' ? 'solid' : 'soft'}
|
||||||
|
oncontextmenu={(e: MouseEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
checksContextMenuEl?.open();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{checksTagInfo.text}
|
{checksTagInfo.text}
|
||||||
</Button>
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ContextMenu bind:this={checksContextMenuEl} target={checksContextMenuTarget}>
|
||||||
|
<ContextMenuSection>
|
||||||
|
<ContextMenuItem
|
||||||
|
label="Open checks"
|
||||||
|
onclick={() => {
|
||||||
|
openExternalUrl(`${$pr.htmlUrl}/checks`);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ContextMenuItem
|
||||||
|
label="Copy Checks"
|
||||||
|
onclick={() => {
|
||||||
|
copyToClipboard(`${$pr.htmlUrl}/checks`);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ContextMenuSection>
|
||||||
|
</ContextMenu>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $pr?.htmlUrl}
|
{#if $pr?.htmlUrl}
|
||||||
|
<div bind:this={prContextMenuTarget}>
|
||||||
<Button
|
<Button
|
||||||
icon="open-link"
|
icon="open-link"
|
||||||
size="tag"
|
size="tag"
|
||||||
@ -151,9 +184,25 @@
|
|||||||
onclick={() => {
|
onclick={() => {
|
||||||
openExternalUrl($pr.htmlUrl);
|
openExternalUrl($pr.htmlUrl);
|
||||||
}}
|
}}
|
||||||
|
oncontextmenu={(e: MouseEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
prContextMenuEl?.open();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
View PR
|
View PR
|
||||||
</Button>
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ContextMenu bind:this={prContextMenuEl} target={prContextMenuTarget}>
|
||||||
|
<ContextMenuSection>
|
||||||
|
<ContextMenuItem
|
||||||
|
label="Copy PR Link"
|
||||||
|
onclick={() => {
|
||||||
|
copyToClipboard($pr.htmlUrl);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ContextMenuSection>
|
||||||
|
</ContextMenu>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -222,6 +271,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
padding: 0 14px 12px 14px;
|
padding: 0 14px 12px 14px;
|
||||||
|
align-items: baseline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pr-header-actions {
|
.pr-header-actions {
|
||||||
|
Loading…
Reference in New Issue
Block a user