Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an action list component #3786

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions contributions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2905,6 +2905,123 @@
]
}
},
"gitlens.home.createPullRequest": {
"label": "Create Pull Request...",
"icon": "$(git-pull-request-create)",
"menus": {
"webview/context": [
{
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.createPullRequest\\b)/",
"group": "30_gitlens_action",
"order": 1
}
]
}
},
"gitlens.home.fetch": {
"label": "Fetch",
"icon": "$(gl-repo-fetch)",
"menus": {
"webview/context": [
{
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.fetch\\b)/",
"group": "60_gitlens_action",
"order": 1
}
]
}
},
"gitlens.home.openInGraph": {
"label": "Open in Commit Graph",
"icon": "$(gl-graph)",
"menus": {
"webview/context": [
{
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.openInGraph\\b)/",
"group": "80_gitlens_action",
"order": 1
}
]
}
},
"gitlens.home.openPullRequestChanges": {
"label": "Open Pull Request Changes",
"icon": "$(request-changes)",
"menus": {
"webview/context": [
{
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.openPullRequestChanges\\b)/",
"group": "10_gitlens_action",
"order": 1
}
]
}
},
"gitlens.home.openPullRequestOnRemote": {
"label": "Open Pull Request on Remote",
"icon": "$(globe)",
"menus": {
"webview/context": [
{
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.openPullRequestOnRemote\\b)/",
"group": "20_gitlens_action",
"order": 1
}
]
}
},
"gitlens.home.openWorktree": {
"label": "Open Worktree",
"icon": "$(browser)",
"menus": {
"webview/context": [
{
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.openWorktree\\b)/",
"group": "40_gitlens_action",
"order": 1
}
]
}
},
"gitlens.home.openWorktreeInNewWindow": {
"label": "Open Worktree in New Window",
"icon": "$(empty-window)",
"menus": {
"webview/context": [
{
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.openWorktreeInNewWindow\\b)/",
"group": "40_gitlens_action",
"order": 1
}
]
}
},
"gitlens.home.pull": {
"label": "Pull",
"icon": "$(gl-repo-pull)",
"menus": {
"webview/context": [
{
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.pull\\b)/",
"group": "60_gitlens_action",
"order": 1
}
]
}
},
"gitlens.home.switchToBranch": {
"label": "Switch to Branch...",
"icon": "$(gl-switch)",
"menus": {
"webview/context": [
{
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.switchToBranch\\b)/",
"group": "50_gitlens_action",
"order": 1
}
]
}
},
"gitlens.inviteToLiveShare": {
"label": "Invite to Live Share",
"icon": "$(live-share)",
Expand Down
126 changes: 126 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6880,6 +6880,51 @@
"icon": "$(discard)",
"enablement": "!operationInProgress"
},
{
"command": "gitlens.home.createPullRequest",
"title": "Create Pull Request...",
"icon": "$(git-pull-request-create)"
},
{
"command": "gitlens.home.fetch",
"title": "Fetch",
"icon": "$(gl-repo-fetch)"
},
{
"command": "gitlens.home.openInGraph",
"title": "Open in Commit Graph",
"icon": "$(gl-graph)"
},
{
"command": "gitlens.home.openPullRequestChanges",
"title": "Open Pull Request Changes",
"icon": "$(request-changes)"
},
{
"command": "gitlens.home.openPullRequestOnRemote",
"title": "Open Pull Request on Remote",
"icon": "$(globe)"
},
{
"command": "gitlens.home.openWorktree",
"title": "Open Worktree",
"icon": "$(browser)"
},
{
"command": "gitlens.home.openWorktreeInNewWindow",
"title": "Open Worktree in New Window",
"icon": "$(empty-window)"
},
{
"command": "gitlens.home.pull",
"title": "Pull",
"icon": "$(gl-repo-pull)"
},
{
"command": "gitlens.home.switchToBranch",
"title": "Switch to Branch...",
"icon": "$(gl-switch)"
},
{
"command": "gitlens.inviteToLiveShare",
"title": "Invite to Live Share",
Expand Down Expand Up @@ -10793,6 +10838,42 @@
"command": "gitlens.graph.undoCommit",
"when": "false"
},
{
"command": "gitlens.home.createPullRequest",
"when": "false"
},
{
"command": "gitlens.home.fetch",
"when": "false"
},
{
"command": "gitlens.home.openInGraph",
"when": "false"
},
{
"command": "gitlens.home.openPullRequestChanges",
"when": "false"
},
{
"command": "gitlens.home.openPullRequestOnRemote",
"when": "false"
},
{
"command": "gitlens.home.openWorktree",
"when": "false"
},
{
"command": "gitlens.home.openWorktreeInNewWindow",
"when": "false"
},
{
"command": "gitlens.home.pull",
"when": "false"
},
{
"command": "gitlens.home.switchToBranch",
"when": "false"
},
{
"command": "gitlens.inviteToLiveShare",
"when": "false"
Expand Down Expand Up @@ -18736,6 +18817,51 @@
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/",
"group": "3_columns@2"
},
{
"command": "gitlens.home.openPullRequestChanges",
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.openPullRequestChanges\\b)/",
"group": "10_gitlens_action@1"
},
{
"command": "gitlens.home.openPullRequestOnRemote",
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.openPullRequestOnRemote\\b)/",
"group": "20_gitlens_action@1"
},
{
"command": "gitlens.home.createPullRequest",
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.createPullRequest\\b)/",
"group": "30_gitlens_action@1"
},
{
"command": "gitlens.home.openWorktree",
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.openWorktree\\b)/",
"group": "40_gitlens_action@1"
},
{
"command": "gitlens.home.openWorktreeInNewWindow",
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.openWorktreeInNewWindow\\b)/",
"group": "40_gitlens_action@1"
},
{
"command": "gitlens.home.switchToBranch",
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.switchToBranch\\b)/",
"group": "50_gitlens_action@1"
},
{
"command": "gitlens.home.fetch",
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.fetch\\b)/",
"group": "60_gitlens_action@1"
},
{
"command": "gitlens.home.pull",
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.pull\\b)/",
"group": "60_gitlens_action@1"
},
{
"command": "gitlens.home.openInGraph",
"when": "webviewItem =~ /gitlens:home\\b(?=.*?\\b\\+.*gitlens\\.home\\.openInGraph\\b)/",
"group": "80_gitlens_action@1"
},
{
"command": "gitlens.graph.openPullRequestChanges",
"when": "webviewItem =~ /gitlens:pullrequest\\b(?=.*?\\b\\+refs\\b)/ && config.multiDiffEditor.experimental.enabled",
Expand Down
2 changes: 2 additions & 0 deletions src/constants.commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,10 @@ type HomeWebviewCommands = `home.${
| 'openPullRequestDetails'
| 'createPullRequest'
| 'openWorktree'
| 'openWorktreeInNewWindow'
| 'switchToBranch'
| 'fetch'
| 'pull'
| 'openInGraph'
| 'createBranch'
| 'mergeIntoCurrent'
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/apps/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<body
class="preload"
data-placement="#{placement}"
data-vscode-context='{ "webview": "#{webviewId}", "webviewInstance": "#{webviewInstanceId}" }'
data-vscode-context='{ "preventDefaultContextMenuItems": true, "webview": "#{webviewId}", "webviewInstance": "#{webviewInstanceId}" }'
>
<gl-home-app name="HomeView" placement="#{placement}" bootstrap="#{state}"></gl-home-app>
</body>
Expand Down
47 changes: 24 additions & 23 deletions src/webviews/apps/plus/home/components/active-work.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,23 @@ import { createCommandLink } from '../../../../../system/commands';
import { createWebviewCommandLink } from '../../../../../system/webview';
import type { GetActiveOverviewResponse, GetOverviewBranch, OpenInGraphParams, State } from '../../../../home/protocol';
import { stateContext } from '../../../home/context';
import { linkStyles } from '../../shared/components/vscode.css';
import { branchCardStyles, GlBranchCardBase } from './branch-card';
import type { ActiveOverviewState } from './overviewState';
import { activeOverviewStateContext } from './overviewState';
import type { ActionList } from '../../../shared/components/actions/action-list';
import '../../../shared/components/button';
import '../../../shared/components/code-icon';
import '../../../shared/components/skeleton-loader';
import '../../../shared/components/card/card';
import '../../../shared/components/code-icon';
import '../../../shared/components/commit/commit-stats';
import '../../../shared/components/menu/menu-item';
import '../../../shared/components/overlays/popover';
import '../../../shared/components/overlays/tooltip';
import '../../../shared/components/pills/tracking';
import '../../../shared/components/rich/issue-icon';
import '../../../shared/components/rich/pr-icon';
import '../../../shared/components/skeleton-loader';
import '../../shared/components/merge-rebase-status';
import { linkStyles } from '../../shared/components/vscode.css';
import { branchCardStyles, GlBranchCardBase } from './branch-card';
import type { ActiveOverviewState } from './overviewState';
import { activeOverviewStateContext } from './overviewState';

export const activeWorkTagName = 'gl-active-work';

Expand Down Expand Up @@ -376,27 +377,27 @@ export class GlActiveBranchCard extends GlBranchCardBase {
></gl-merge-rebase-status>`;
}

protected getBranchActions(): TemplateResult[] {
protected getBranchActions(): (typeof ActionList.ItemProps)[] {
return [];
}

protected getPrActions(): TemplateResult[] {
protected getPrActions(): (typeof ActionList.ItemProps)[] {
return [
html`<action-item
label="Open Pull Request Changes"
icon="request-changes"
href=${this.createCommandLink('gitlens.home.openPullRequestChanges')}
></action-item>`,
html`<action-item
label="Compare Pull Request"
icon="git-compare"
href=${this.createCommandLink('gitlens.home.openPullRequestComparison')}
></action-item>`,
html`<action-item
label="Open Pull Request Details"
icon="eye"
href=${this.createCommandLink('gitlens.home.openPullRequestDetails')}
></action-item>`,
{
label: 'Open Pull Request Changes',
icon: 'request-changes',
href: this.createCommandLink('gitlens.home.openPullRequestChanges'),
},
{
label: 'Compare Pull Request',
icon: 'git-compare',
href: this.createCommandLink('gitlens.home.openPullRequestComparison'),
},
{
label: 'Open Pull Request Details',
icon: 'eye',
href: this.createCommandLink('gitlens.home.openPullRequestDetails'),
},
];
}
}
Loading