Browse Source

Unifies webview panel show command args

main
Eric Amodio 1 year ago
parent
commit
e052b44fad
8 changed files with 66 additions and 89 deletions
  1. +42
    -42
      package.json
  2. +14
    -14
      src/constants.ts
  3. +1
    -1
      src/plus/webviews/graph/graphWebview.ts
  4. +2
    -12
      src/plus/webviews/graph/registration.ts
  5. +1
    -1
      src/webviews/apps/home/home.html
  6. +2
    -2
      src/webviews/apps/welcome/welcome.html
  7. +1
    -1
      src/webviews/settings/registration.ts
  8. +3
    -16
      src/webviews/webviewsController.ts

+ 42
- 42
package.json View File

@ -5200,85 +5200,85 @@
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#views",
"command": "gitlens.showSettingsPage!views",
"title": "Open Settings",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#autolinks",
"command": "gitlens.showSettingsPage!autolinks",
"title": "Configure Autolinks",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#branches-view",
"command": "gitlens.showSettingsPage!branches-view",
"title": "Open View Settings",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#commits-view",
"command": "gitlens.showSettingsPage!commits-view",
"title": "Open View Settings",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#contributors-view",
"command": "gitlens.showSettingsPage!contributors-view",
"title": "Open View Settings",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#file-history-view",
"command": "gitlens.showSettingsPage!file-history-view",
"title": "Open View Settings",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#line-history-view",
"command": "gitlens.showSettingsPage!line-history-view",
"title": "Open View Settings",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#remotes-view",
"command": "gitlens.showSettingsPage!remotes-view",
"title": "Open View Settings",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#repositories-view",
"command": "gitlens.showSettingsPage!repositories-view",
"title": "Open View Settings",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#search-compare-view",
"command": "gitlens.showSettingsPage!search-compare-view",
"title": "Open View Settings",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#stashes-view",
"command": "gitlens.showSettingsPage!stashes-view",
"title": "Open View Settings",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#tags-view",
"command": "gitlens.showSettingsPage!tags-view",
"title": "Open View Settings",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#worktrees-view",
"command": "gitlens.showSettingsPage!worktrees-view",
"title": "Open View Settings",
"category": "GitLens",
"icon": "$(gear)"
},
{
"command": "gitlens.showSettingsPage#commit-graph",
"command": "gitlens.showSettingsPage!commit-graph",
"title": "Open Commit Graph Settings",
"category": "GitLens",
"icon": "$(gear)"
@ -8694,55 +8694,55 @@
"when": "gitlens:enabled"
},
{
"command": "gitlens.showSettingsPage#views",
"command": "gitlens.showSettingsPage!views",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#branches-view",
"command": "gitlens.showSettingsPage!branches-view",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#commits-view",
"command": "gitlens.showSettingsPage!commits-view",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#contributors-view",
"command": "gitlens.showSettingsPage!contributors-view",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#file-history-view",
"command": "gitlens.showSettingsPage!file-history-view",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#line-history-view",
"command": "gitlens.showSettingsPage!line-history-view",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#remotes-view",
"command": "gitlens.showSettingsPage!remotes-view",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#repositories-view",
"command": "gitlens.showSettingsPage!repositories-view",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#search-compare-view",
"command": "gitlens.showSettingsPage!search-compare-view",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#stashes-view",
"command": "gitlens.showSettingsPage!stashes-view",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#tags-view",
"command": "gitlens.showSettingsPage!tags-view",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#worktrees-view",
"command": "gitlens.showSettingsPage!worktrees-view",
"when": "false"
},
{
"command": "gitlens.showSettingsPage#commit-graph",
"command": "gitlens.showSettingsPage!commit-graph",
"when": "false"
},
{
@ -11959,57 +11959,57 @@
"group": "navigation@-98"
},
{
"command": "gitlens.showSettingsPage#branches-view",
"command": "gitlens.showSettingsPage!branches-view",
"when": "view =~ /^gitlens\\.views\\.branches/",
"group": "9_gitlens@1"
},
{
"command": "gitlens.showSettingsPage#commits-view",
"command": "gitlens.showSettingsPage!commits-view",
"when": "view =~ /^gitlens\\.views\\.commits/",
"group": "9_gitlens@1"
},
{
"command": "gitlens.showSettingsPage#contributors-view",
"command": "gitlens.showSettingsPage!contributors-view",
"when": "view =~ /^gitlens\\.views\\.contributors/",
"group": "9_gitlens@1"
},
{
"command": "gitlens.showSettingsPage#file-history-view",
"command": "gitlens.showSettingsPage!file-history-view",
"when": "view =~ /^gitlens\\.views\\.fileHistory/",
"group": "9_gitlens@1"
},
{
"command": "gitlens.showSettingsPage#line-history-view",
"command": "gitlens.showSettingsPage!line-history-view",
"when": "view =~ /^gitlens\\.views\\.lineHistory/",
"group": "9_gitlens@1"
},
{
"command": "gitlens.showSettingsPage#remotes-view",
"command": "gitlens.showSettingsPage!remotes-view",
"when": "view =~ /^gitlens\\.views\\.remotes/",
"group": "9_gitlens@1"
},
{
"command": "gitlens.showSettingsPage#repositories-view",
"command": "gitlens.showSettingsPage!repositories-view",
"when": "view =~ /^gitlens\\.views\\.repositories/",
"group": "9_gitlens@1"
},
{
"command": "gitlens.showSettingsPage#search-compare-view",
"command": "gitlens.showSettingsPage!search-compare-view",
"when": "view =~ /^gitlens\\.views\\.searchAndCompare\\b/",
"group": "9_gitlens@1"
},
{
"command": "gitlens.showSettingsPage#stashes-view",
"command": "gitlens.showSettingsPage!stashes-view",
"when": "view =~ /^gitlens\\.views\\.stashes/",
"group": "9_gitlens@1"
},
{
"command": "gitlens.showSettingsPage#tags-view",
"command": "gitlens.showSettingsPage!tags-view",
"when": "view =~ /^gitlens\\.views\\.tags/",
"group": "9_gitlens@1"
},
{
"command": "gitlens.showSettingsPage#worktrees-view",
"command": "gitlens.showSettingsPage!worktrees-view",
"when": "view =~ /^gitlens\\.views\\.worktrees/",
"group": "9_gitlens@1"
}
@ -12692,12 +12692,12 @@
"alt": "gitlens.copyRemoteFileUrlWithoutRange"
},
{
"command": "gitlens.showSettingsPage#autolinks",
"command": "gitlens.showSettingsPage!autolinks",
"when": "viewItem =~ /gitlens:autolinked:items\\b/",
"group": "inline@99"
},
{
"command": "gitlens.showSettingsPage#autolinks",
"command": "gitlens.showSettingsPage!autolinks",
"when": "viewItem =~ /gitlens:autolinked:items\\b/",
"group": "1_gitlens_actions@99"
},
@ -14531,7 +14531,7 @@
"group": "1_gitlens@1"
},
{
"command": "gitlens.showSettingsPage#commit-graph",
"command": "gitlens.showSettingsPage!commit-graph",
"group": "9_gitlens@1"
}
],
@ -15636,7 +15636,7 @@
{
"id": "gitlens.welcome.hostingServiceIntegrations",
"title": "Integrate with Git hosting services",
"description": "Simplify your workflow and quickly gain insights with automatic linking of issues and pull requests across multiple Git hosting services including GitHub, GitHub Enterprise ✨, GitLab, GitLab self-managed ✨, Gitea, Gerrit, Google Source, Bitbucket, Bitbucket Server, Azure DevOps, and custom servers.\n\nAll integration provide automatic linking, while rich integrations with GitHub & GitLab offer detailed hover information for autolinks, and correlations between pull requests, branches, and commits, as well as user avatars for added context.\n\n**Define your own autolinks**\nUse autolinks to linkify external references, like Jira issues or Zendesk tickets, in commit messages.\n\n[Configure Autolinks](command:gitlens.showSettingsPage?%22autolinks%22)",
"description": "Simplify your workflow and quickly gain insights with automatic linking of issues and pull requests across multiple Git hosting services including GitHub, GitHub Enterprise ✨, GitLab, GitLab self-managed ✨, Gitea, Gerrit, Google Source, Bitbucket, Bitbucket Server, Azure DevOps, and custom servers.\n\nAll integration provide automatic linking, while rich integrations with GitHub & GitLab offer detailed hover information for autolinks, and correlations between pull requests, branches, and commits, as well as user avatars for added context.\n\n**Define your own autolinks**\nUse autolinks to linkify external references, like Jira issues or Zendesk tickets, in commit messages.\n\n[Configure Autolinks](command:gitlens.showSettingsPage!autolinks)",
"media": {
"markdown": "walkthroughs/welcome/integrations.md"
}

+ 14
- 14
src/constants.ts View File

@ -272,20 +272,20 @@ export const enum Commands {
ShowRepositoriesView = 'gitlens.showRepositoriesView',
ShowSearchAndCompareView = 'gitlens.showSearchAndCompareView',
ShowSettingsPage = 'gitlens.showSettingsPage',
ShowSettingsPageAndJumpToBranchesView = 'gitlens.showSettingsPage#branches-view',
ShowSettingsPageAndJumpToCommitsView = 'gitlens.showSettingsPage#commits-view',
ShowSettingsPageAndJumpToContributorsView = 'gitlens.showSettingsPage#contributors-view',
ShowSettingsPageAndJumpToFileHistoryView = 'gitlens.showSettingsPage#file-history-view',
ShowSettingsPageAndJumpToLineHistoryView = 'gitlens.showSettingsPage#line-history-view',
ShowSettingsPageAndJumpToRemotesView = 'gitlens.showSettingsPage#remotes-view',
ShowSettingsPageAndJumpToRepositoriesView = 'gitlens.showSettingsPage#repositories-view',
ShowSettingsPageAndJumpToSearchAndCompareView = 'gitlens.showSettingsPage#search-compare-view',
ShowSettingsPageAndJumpToStashesView = 'gitlens.showSettingsPage#stashes-view',
ShowSettingsPageAndJumpToTagsView = 'gitlens.showSettingsPage#tags-view',
ShowSettingsPageAndJumpToWorkTreesView = 'gitlens.showSettingsPage#worktrees-view',
ShowSettingsPageAndJumpToViews = 'gitlens.showSettingsPage#views',
ShowSettingsPageAndJumpToCommitGraph = 'gitlens.showSettingsPage#commit-graph',
ShowSettingsPageAndJumpToAutolinks = 'gitlens.showSettingsPage#autolinks',
ShowSettingsPageAndJumpToBranchesView = 'gitlens.showSettingsPage!branches-view',
ShowSettingsPageAndJumpToCommitsView = 'gitlens.showSettingsPage!commits-view',
ShowSettingsPageAndJumpToContributorsView = 'gitlens.showSettingsPage!contributors-view',
ShowSettingsPageAndJumpToFileHistoryView = 'gitlens.showSettingsPage!file-history-view',
ShowSettingsPageAndJumpToLineHistoryView = 'gitlens.showSettingsPage!line-history-view',
ShowSettingsPageAndJumpToRemotesView = 'gitlens.showSettingsPage!remotes-view',
ShowSettingsPageAndJumpToRepositoriesView = 'gitlens.showSettingsPage!repositories-view',
ShowSettingsPageAndJumpToSearchAndCompareView = 'gitlens.showSettingsPage!search-compare-view',
ShowSettingsPageAndJumpToStashesView = 'gitlens.showSettingsPage!stashes-view',
ShowSettingsPageAndJumpToTagsView = 'gitlens.showSettingsPage!tags-view',
ShowSettingsPageAndJumpToWorkTreesView = 'gitlens.showSettingsPage!worktrees-view',
ShowSettingsPageAndJumpToViews = 'gitlens.showSettingsPage!views',
ShowSettingsPageAndJumpToCommitGraph = 'gitlens.showSettingsPage!commit-graph',
ShowSettingsPageAndJumpToAutolinks = 'gitlens.showSettingsPage!autolinks',
ShowStashesView = 'gitlens.showStashesView',
ShowTagsView = 'gitlens.showTagsView',
ShowTimelinePage = 'gitlens.showTimelinePage',

+ 1
- 1
src/plus/webviews/graph/graphWebview.ts View File

@ -395,7 +395,7 @@ export class GraphWebviewProvider implements WebviewProvider
() =>
void executeCommand<WebviewPanelShowCommandArgs>(
Commands.ShowGraphPage,
{ _type: 'WebviewPanelShowOptions' },
undefined,
this.repository,
),
),

+ 2
- 12
src/plus/webviews/graph/registration.ts View File

@ -99,21 +99,11 @@ export function registerGraphWebviewCommands(
return executeCommand(Commands.ShowGraphView, ...args);
}
return executeCommand<WebviewPanelShowCommandArgs>(
Commands.ShowGraphPage,
{ _type: 'WebviewPanelShowOptions' },
undefined,
...args,
);
return executeCommand<WebviewPanelShowCommandArgs>(Commands.ShowGraphPage, undefined, ...args);
}),
registerCommand(`${panels.id}.switchToEditorLayout`, async () => {
await configuration.updateEffective('graph.layout', 'editor');
queueMicrotask(
() =>
void executeCommand<WebviewPanelShowCommandArgs>(Commands.ShowGraphPage, {
_type: 'WebviewPanelShowOptions',
}),
);
queueMicrotask(() => void executeCommand<WebviewPanelShowCommandArgs>(Commands.ShowGraphPage));
}),
registerCommand(`${panels.id}.switchToPanelLayout`, async () => {
await configuration.updateEffective('graph.layout', 'panel');

+ 1
- 1
src/webviews/apps/home/home.html View File

@ -322,7 +322,7 @@
>
<a
class="nav-list__item"
href="command:gitlens.showSettingsPage?%22autolinks%22"
href="command:gitlens.showSettingsPage!autolinks"
title="Open Autolinks Settings"
aria-label="Open Autolinks Settings"
><code-icon class="nav-list__icon" icon="link"></code-icon

+ 2
- 2
src/webviews/apps/welcome/welcome.html View File

@ -385,7 +385,7 @@
Use autolinks to linkify external references, like Jira issues or Zendesk tickets, in commit
messages.
</p>
<gl-button appearance="secondary" href="command:gitlens.showSettingsPage?%22autolinks%22"
<gl-button appearance="secondary" href="command:gitlens.showSettingsPage!autolinks"
>Configure Autolinks</gl-button
>
@ -583,7 +583,7 @@
><code-icon icon="gear"></code-icon><span>GitLens Settings</span></a
>
<a
href="command:gitlens.showSettingsPage?%22autolinks%22"
href="command:gitlens.showSettingsPage!autolinks"
title="Open Autolinks Settings"
aria-label="Open Autolinks Settings"
><code-icon icon="link"></code-icon><span>Autolinks Settings</span></a

+ 1
- 1
src/webviews/settings/registration.ts View File

@ -50,7 +50,7 @@ export function registerSettingsWebviewCommands(panels: WebviewPanelsProxy
].map(c => {
// The show and jump commands are structured to have a # separating the base command from the anchor
let anchor: string | undefined;
const match = /.*?#(.*)/.exec(c);
const match = /.*?!(.*)/.exec(c);
if (match != null) {
[, anchor] = match;
}

+ 3
- 16
src/webviews/webviewsController.ts View File

@ -357,13 +357,8 @@ export class WebviewsController implements Disposable {
}),
registerCommand(
command.id,
(...args: unknown[]) => {
if (hasWebviewPanelShowOptions(args)) {
const [{ _type, ...opts }, ...rest] = args;
return show({ ...command.options, ...opts }, ...(rest as ShowingArgs));
}
return show({ ...command.options }, ...(args as ShowingArgs));
(opts: WebviewPanelShowOptions | undefined, ...args: unknown[]) => {
return show({ ...command.options, ...opts }, ...(args as ShowingArgs));
},
this,
),
@ -415,10 +410,7 @@ interface WebviewPanelsShowOptions extends WebviewPanelShowOptions {
preserveInstance?: string | boolean;
}
export type WebviewPanelShowCommandArgs = [
WebviewPanelsShowOptions & { _type: 'WebviewPanelShowOptions' },
...args: unknown[],
];
export type WebviewPanelShowCommandArgs = [WebviewPanelsShowOptions | undefined, ...args: unknown[]];
export interface WebviewViewShowOptions {
column?: never;
@ -518,8 +510,3 @@ function getBestController
export function isSerializedState<State>(o: unknown): o is { state: Partial<State> } {
return o != null && typeof o === 'object' && 'state' in o && o.state != null && typeof o.state === 'object';
}
function hasWebviewPanelShowOptions(args: unknown[]): args is WebviewPanelShowCommandArgs {
const [arg] = args;
return arg != null && typeof arg === 'object' && '_type' in arg && arg._type === 'WebviewPanelShowOptions';
}

Loading…
Cancel
Save