Преглед изворни кода

Renames some workspace commands

Adds types for tree view commands
main
Eric Amodio пре 1 година
родитељ
комит
d1e91cdc1c
5 измењених фајлова са 168 додато и 63 уклоњено
  1. +34
    -34
      package.json
  2. +101
    -0
      src/constants.ts
  3. +6
    -2
      src/system/command.ts
  4. +3
    -3
      src/views/viewBase.ts
  5. +24
    -24
      src/views/workspacesView.ts

+ 34
- 34
package.json Прегледај датотеку

@ -6894,6 +6894,12 @@
"icon": "$(refresh)"
},
{
"command": "gitlens.views.workspaces.addRepos",
"title": "Add Repositories...",
"category": "GitLens",
"icon": "$(add)"
},
{
"command": "gitlens.views.workspaces.convert",
"title": "Convert to Cloud Workspace...",
"category": "GitLens",
@ -6912,18 +6918,6 @@
"icon": "$(trash)"
},
{
"command": "gitlens.views.workspaces.addRepos",
"title": "Add Repositories...",
"category": "GitLens",
"icon": "$(add)"
},
{
"command": "gitlens.views.workspaces.locateRepo",
"title": "Locate Repository...",
"category": "GitLens",
"icon": "$(location)"
},
{
"command": "gitlens.views.workspaces.locateAllRepos",
"title": "Locate Repositories...",
"category": "GitLens",
@ -6936,25 +6930,31 @@
"icon": "$(empty-window)"
},
{
"command": "gitlens.views.workspaces.openRepoNewWindow",
"title": "Open Repository in New Window",
"command": "gitlens.views.workspaces.repo.locate",
"title": "Locate Repository...",
"category": "GitLens",
"icon": "$(empty-window)"
"icon": "$(location)"
},
{
"command": "gitlens.views.workspaces.openRepoCurrentWindow",
"command": "gitlens.views.workspaces.repo.open",
"title": "Open Repository",
"category": "GitLens",
"icon": "$(window)"
},
{
"command": "gitlens.views.workspaces.openRepoWorkspace",
"command": "gitlens.views.workspaces.repo.openInNewWindow",
"title": "Open Repository in New Window",
"category": "GitLens",
"icon": "$(empty-window)"
},
{
"command": "gitlens.views.workspaces.repo.addToWindow",
"title": "Add Repository to VS Code Workspace",
"category": "GitLens"
},
{
"command": "gitlens.views.workspaces.removeRepo",
"title": "Remove from Cloud Workspace...",
"command": "gitlens.views.workspaces.repo.remove",
"title": "Remove from Workspace...",
"category": "GitLens",
"icon": "$(trash)"
},
@ -9457,7 +9457,7 @@
"when": "false"
},
{
"command": "gitlens.views.workspaces.locateRepo",
"command": "gitlens.views.workspaces.repo.locate",
"when": "false"
},
{
@ -9469,19 +9469,19 @@
"when": "false"
},
{
"command": "gitlens.views.workspaces.openRepoNewWindow",
"command": "gitlens.views.workspaces.repo.openInNewWindow",
"when": "false"
},
{
"command": "gitlens.views.workspaces.openRepoCurrentWindow",
"command": "gitlens.views.workspaces.repo.open",
"when": "false"
},
{
"command": "gitlens.views.workspaces.openRepoWorkspace",
"command": "gitlens.views.workspaces.repo.addToWindow",
"when": "false"
},
{
"command": "gitlens.views.workspaces.removeRepo",
"command": "gitlens.views.workspaces.repo.remove",
"when": "false"
},
{
@ -11836,38 +11836,38 @@
"group": "3_gitlens_explore@10"
},
{
"command": "gitlens.views.workspaces.locateRepo",
"command": "gitlens.views.workspaces.repo.locate",
"when": "viewItem =~ /gitlens:workspaceMissingRepository\\b/",
"group": "inline@1"
},
{
"command": "gitlens.views.workspaces.locateRepo",
"command": "gitlens.views.workspaces.repo.locate",
"when": "viewItem =~ /gitlens:workspaceMissingRepository\\b/",
"group": "1_gitlens_actions@1"
},
{
"command": "gitlens.views.workspaces.removeRepo",
"command": "gitlens.views.workspaces.repo.remove",
"when": "viewItem =~ /gitlens:workspaceMissingRepository\\b/",
"group": "6_gitlens_actions@1"
},
{
"command": "gitlens.views.workspaces.openRepoNewWindow",
"command": "gitlens.views.workspaces.repo.openInNewWindow",
"when": "viewItem =~ /gitlens:repository\\b(?=.*?\\b\\+workspace\\b)/",
"group": "inline@100",
"alt": "gitlens.views.workspaces.openRepoCurrentWindow"
"alt": "gitlens.views.workspaces.repo.open"
},
{
"command": "gitlens.views.workspaces.openRepoCurrentWindow",
"command": "gitlens.views.workspaces.repo.open",
"when": "viewItem =~ /gitlens:repository\\b(?=.*?\\b\\+workspace\\b)/",
"group": "0_1gitlens_actions@1"
},
{
"command": "gitlens.views.workspaces.openRepoNewWindow",
"command": "gitlens.views.workspaces.repo.openInNewWindow",
"when": "viewItem =~ /gitlens:repository\\b(?=.*?\\b\\+workspace\\b)/",
"group": "0_1gitlens_actions@2"
},
{
"command": "gitlens.views.workspaces.openRepoWorkspace",
"command": "gitlens.views.workspaces.repo.addToWindow",
"when": "viewItem =~ /gitlens:repository\\b(?=.*?\\b\\+workspace\\b)/",
"group": "0_1gitlens_actions@3"
},
@ -11877,12 +11877,12 @@
"group": "0_2gitlens_actions@1"
},
{
"command": "gitlens.views.workspaces.locateRepo",
"command": "gitlens.views.workspaces.repo.locate",
"when": "viewItem =~ /gitlens:repository\\b(?=.*?\\b\\+workspace\\b)(?!.*?\\b\\+local\\b)/",
"group": "0_2gitlens_actions@2"
},
{
"command": "gitlens.views.workspaces.removeRepo",
"command": "gitlens.views.workspaces.repo.remove",
"when": "viewItem =~ /gitlens:repository\\b(?=.*?\\b\\+workspace\\b)(?!.*?\\b\\+local\\b)/",
"group": "0_3gitlens_actions@1"
},

+ 101
- 0
src/constants.ts Прегледај датотеку

@ -314,6 +314,107 @@ export const enum Commands {
Deprecated_ShowFileHistoryInView = 'gitlens.showFileHistoryInView',
}
export type TreeViewCommands = `gitlens.views.${
| `branches.${
| 'copy'
| 'refresh'
| `setLayoutTo${'List' | 'Tree'}`
| `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}`
| `setShowAvatars${'On' | 'Off'}`
| `setShowBranchComparison${'On' | 'Off'}`
| `setShowBranchPullRequest${'On' | 'Off'}`}`
| `commits.${
| 'copy'
| 'refresh'
| `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}`
| `setMyCommitsOnly${'On' | 'Off'}`
| `setShowAvatars${'On' | 'Off'}`
| `setShowBranchComparison${'On' | 'Off'}`
| `setShowBranchPullRequest${'On' | 'Off'}`}`
| `contributors.${
| 'copy'
| 'refresh'
| `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}`
| `setShowAllBranches${'On' | 'Off'}`
| `setShowAvatars${'On' | 'Off'}`
| `setShowStatistics${'On' | 'Off'}`}`
| `fileHistory.${
| 'copy'
| 'refresh'
| 'changeBase'
| `setCursorFollowing${'On' | 'Off'}`
| `setEditorFollowing${'On' | 'Off'}`
| `setRenameFollowing${'On' | 'Off'}`
| `setShowAllBranches${'On' | 'Off'}`
| `setShowAvatars${'On' | 'Off'}`}`
| `lineHistory.${
| 'copy'
| 'refresh'
| 'changeBase'
| `setEditorFollowing${'On' | 'Off'}`
| `setShowAvatars${'On' | 'Off'}`}`
| `remotes.${
| 'copy'
| 'refresh'
| `setLayoutTo${'List' | 'Tree'}`
| `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}`
| `setShowAvatars${'On' | 'Off'}`
| `setShowBranchPullRequest${'On' | 'Off'}`}`
| `repositories.${
| 'copy'
| 'refresh'
| `setBranchesLayoutTo${'List' | 'Tree'}`
| `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}`
| `setAutoRefreshTo${'On' | 'Off'}`
| `setShowAvatars${'On' | 'Off'}`
| `setShowBranchComparison${'On' | 'Off'}`
| `setBranchesShowBranchComparison${'On' | 'Off'}`
| `setShowBranches${'On' | 'Off'}`
| `setShowCommits${'On' | 'Off'}`
| `setShowContributors${'On' | 'Off'}`
| `setShowRemotes${'On' | 'Off'}`
| `setShowStashes${'On' | 'Off'}`
| `setShowTags${'On' | 'Off'}`
| `setShowWorktrees${'On' | 'Off'}`
| `setShowUpstreamStatus${'On' | 'Off'}`
| `setShowSectionOff`}`
| `searchAndCompare.${
| 'copy'
| 'refresh'
| 'clear'
| 'pin'
| 'unpin'
| 'swapComparison'
| 'selectForCompare'
| 'compareWithSelected'
| `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}`
| `setKeepResultsTo${'On' | 'Off'}`
| `setShowAvatars${'On' | 'Off'}`
| `setFilesFilterOn${'Left' | 'Right'}`
| 'setFilesFilterOff'}`
| `stashes.${'copy' | 'refresh' | `setLayoutTo${'List' | 'Tree'}` | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}`}`
| `tags.${'copy' | 'refresh' | `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}`}`
| `workspaces.${
| 'copy'
| 'refresh'
| 'addRepos'
| 'convert'
| 'create'
| 'delete'
| 'locateAllRepos'
| 'open'
| `repo.${'locate' | 'open' | 'openInNewWindow' | 'addToWindow' | 'remove'}`}`
| `worktrees.${
| 'copy'
| 'refresh'
| `setFilesLayoutTo${'Auto' | 'List' | 'Tree'}`
| `setShowAvatars${'On' | 'Off'}`
| `setShowBranchComparison${'On' | 'Off'}`
| `setShowBranchPullRequest${'On' | 'Off'}`}`}`;
export type TreeViewCommandsByViewId<T extends TreeViewIds> = TreeViewCommands extends `${T}.${infer U}`
? `${U}`
: never;
export type CustomEditorTypes = 'rebase';
export type CustomEditorIds = `gitlens.${CustomEditorTypes}`;

+ 6
- 2
src/system/command.ts Прегледај датотеку

@ -2,7 +2,7 @@ import type { Command as CoreCommand, Disposable, Uri } from 'vscode';
import { commands } from 'vscode';
import type { Action, ActionContext } from '../api/gitlens';
import type { Command } from '../commands/base';
import type { CoreCommands, CoreGitCommands } from '../constants';
import type { CoreCommands, CoreGitCommands, TreeViewCommands } from '../constants';
import { Commands } from '../constants';
import { Container } from '../container';
@ -42,7 +42,11 @@ export function executeActionCommand(action: Action,
return commands.executeCommand(`${Commands.ActionPrefix}${action}`, { ...args, type: action });
}
export function createCommand<T extends unknown[]>(command: Commands, title: string, ...args: T): CoreCommand {
export function createCommand<T extends unknown[]>(
command: Commands | TreeViewCommands,
title: string,
...args: T
): CoreCommand {
return {
command: command,
title: title,

+ 3
- 3
src/views/viewBase.ts Прегледај датотеку

@ -28,7 +28,7 @@ import type {
WorktreesViewConfig,
} from '../config';
import { viewsCommonConfigKeys, viewsConfigKeys } from '../config';
import type { TreeViewTypes } from '../constants';
import type { TreeViewCommandsByViewId, TreeViewTypes } from '../constants';
import type { Container } from '../container';
import { executeCoreCommand } from '../system/command';
import { configuration } from '../system/configuration';
@ -281,8 +281,8 @@ export abstract class ViewBase<
}
}
getQualifiedCommand(command: string) {
return `${this.id}.${command}`;
getQualifiedCommand(command: TreeViewCommandsByViewId<typeof this.id>) {
return `${this.id}.${command}`; // satisfies ViewsCommandsById<typeof this.id>;
}
protected abstract getRoot(): RootNode;

+ 24
- 24
src/views/workspacesView.ts Прегледај датотеку

@ -88,6 +88,10 @@ export class WorkspacesView extends ViewBase
},
this,
),
registerViewCommand(this.getQualifiedCommand('addRepos'), async (node: WorkspaceNode) => {
await this.container.workspaces.addCloudWorkspaceRepos(node.workspace.id);
void node.getParent()?.triggerChange(true);
}),
registerViewCommand(
this.getQualifiedCommand('convert'),
async (node: RepositoriesNode) => {
@ -115,7 +119,7 @@ export class WorkspacesView extends ViewBase
registerViewCommand(
this.getQualifiedCommand('open'),
async (node: WorkspaceNode) => {
await this.container.workspaces.saveAsCodeWorkspaceFile(node.workspaceId, node.type, {
await this.container.workspaces.saveAsCodeWorkspaceFile(node.workspace.id, node.workspace.type, {
open: true,
});
},
@ -124,19 +128,7 @@ export class WorkspacesView extends ViewBase
registerViewCommand(
this.getQualifiedCommand('delete'),
async (node: WorkspaceNode) => {
await this.container.workspaces.deleteCloudWorkspace(node.workspaceId);
void node.getParent()?.triggerChange(true);
},
this,
),
registerViewCommand(
this.getQualifiedCommand('locateRepo'),
async (node: RepositoryNode | WorkspaceMissingRepositoryNode) => {
const descriptor = node.workspaceRepositoryDescriptor;
if (descriptor == null || node.workspaceId == null) return;
await this.container.workspaces.locateWorkspaceRepo(node.workspaceId, descriptor);
await this.container.workspaces.deleteCloudWorkspace(node.workspace.id);
void node.getParent()?.triggerChange(true);
},
this,
@ -144,7 +136,7 @@ export class WorkspacesView extends ViewBase
registerViewCommand(
this.getQualifiedCommand('locateAllRepos'),
async (node: WorkspaceNode) => {
if (node.type !== WorkspaceType.Cloud) return;
if (node.workspace.type !== WorkspaceType.Cloud) return;
await window.withProgress(
{
@ -153,7 +145,7 @@ export class WorkspacesView extends ViewBase
cancellable: true,
},
(_progress, token) =>
this.container.workspaces.locateAllCloudWorkspaceRepos(node.workspaceId, token),
this.container.workspaces.locateAllCloudWorkspaceRepos(node.workspace.id, token),
);
void node.triggerChange(true);
@ -161,7 +153,19 @@ export class WorkspacesView extends ViewBase
this,
),
registerViewCommand(
this.getQualifiedCommand('openRepoNewWindow'),
this.getQualifiedCommand('repo.locate'),
async (node: RepositoryNode | WorkspaceMissingRepositoryNode) => {
const descriptor = node.workspaceRepositoryDescriptor;
if (descriptor == null || node.workspaceId == null) return;
await this.container.workspaces.locateWorkspaceRepo(node.workspaceId, descriptor);
void node.getParent()?.triggerChange(true);
},
this,
),
registerViewCommand(
this.getQualifiedCommand('repo.openInNewWindow'),
(node: RepositoryNode) => {
const workspaceNode = node.getParent();
if (workspaceNode == null || !(workspaceNode instanceof WorkspaceNode)) {
@ -173,7 +177,7 @@ export class WorkspacesView extends ViewBase
this,
),
registerViewCommand(
this.getQualifiedCommand('openRepoCurrentWindow'),
this.getQualifiedCommand('repo.open'),
(node: RepositoryNode) => {
const workspaceNode = node.getParent();
if (workspaceNode == null || !(workspaceNode instanceof WorkspaceNode)) {
@ -185,7 +189,7 @@ export class WorkspacesView extends ViewBase
this,
),
registerViewCommand(
this.getQualifiedCommand('openRepoWorkspace'),
this.getQualifiedCommand('repo.addToWindow'),
(node: RepositoryNode) => {
const workspaceNode = node.getParent();
if (workspaceNode == null || !(workspaceNode instanceof WorkspaceNode)) {
@ -196,12 +200,8 @@ export class WorkspacesView extends ViewBase
},
this,
),
registerViewCommand(this.getQualifiedCommand('addRepos'), async (node: WorkspaceNode) => {
await this.container.workspaces.addCloudWorkspaceRepos(node.workspaceId);
void node.getParent()?.triggerChange(true);
}),
registerViewCommand(
this.getQualifiedCommand('removeRepo'),
this.getQualifiedCommand('repo.remove'),
async (node: RepositoryNode | WorkspaceMissingRepositoryNode) => {
const descriptor = node.workspaceRepositoryDescriptor;
if (descriptor?.id == null || node.workspaceId == null) return;

Loading…
Откажи
Сачувај