瀏覽代碼

Improves visuals and descriptions for linked workspaces

main
Ramin Tadayon 1 年之前
父節點
當前提交
624385fae4
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 79D60DDE3DFB95F5
共有 4 個檔案被更改,包括 40 行新增9 行删除
  1. +2
    -2
      package.json
  2. +23
    -2
      src/plus/workspaces/workspacesService.ts
  3. +10
    -4
      src/views/nodes/repositoriesNode.ts
  4. +5
    -1
      src/views/nodes/workspaceNode.ts

+ 2
- 2
package.json 查看文件

@ -11198,7 +11198,7 @@
}, },
{ {
"command": "gitlens.views.workspaces.addReposFromLinked", "command": "gitlens.views.workspaces.addReposFromLinked",
"when": "viewItem =~ /gitlens:repositories\\b(?=.*?\\b\\+synced\\b)/",
"when": "viewItem =~ /gitlens:repositories\\b(?=.*?\\b\\+linked\\b)(?=.*?\\b\\+current\\b)/",
"group": "1_gitlens_actions@3" "group": "1_gitlens_actions@3"
}, },
{ {
@ -11218,7 +11218,7 @@
}, },
{ {
"command": "gitlens.views.workspaces.changeAutoAddSetting", "command": "gitlens.views.workspaces.changeAutoAddSetting",
"when": "viewItem =~ /(gitlens:workspace\\b(?=.*?\\b\\+(cloud|local)\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+hasPath\\b)|gitlens:repositories\\b(?=.*?\\b\\+synced\\b))/",
"when": "viewItem =~ /(gitlens:workspace\\b(?=.*?\\b\\+(cloud|local)\\b)(?=.*?\\b\\+current\\b)(?=.*?\\b\\+hasPath\\b)|gitlens:repositories\\b(?=.*?\\b\\+linked\\b))/",
"group": "2_gitlens_quickopen@6" "group": "2_gitlens_quickopen@6"
}, },
{ {

+ 23
- 2
src/plus/workspaces/workspacesService.ts 查看文件

@ -50,6 +50,7 @@ export class WorkspacesService implements Disposable {
private _workspacesPathProvider: WorkspacesPathMappingProvider; private _workspacesPathProvider: WorkspacesPathMappingProvider;
private _currentWorkspaceId: string | undefined; private _currentWorkspaceId: string | undefined;
private _currentWorkspaceAutoAddSetting: WorkspaceAutoAddSetting = WorkspaceAutoAddSetting.Disabled; private _currentWorkspaceAutoAddSetting: WorkspaceAutoAddSetting = WorkspaceAutoAddSetting.Disabled;
private _currentWorkspace: CloudWorkspace | LocalWorkspace | undefined;
constructor( constructor(
private readonly container: Container, private readonly container: Container,
@ -75,6 +76,10 @@ export class WorkspacesService implements Disposable {
return this._currentWorkspaceId; return this._currentWorkspaceId;
} }
get currentWorkspace(): CloudWorkspace | LocalWorkspace | undefined {
return this._currentWorkspace;
}
private onSubscriptionChanged(event: SubscriptionChangeEvent): void { private onSubscriptionChanged(event: SubscriptionChangeEvent): void {
if ( if (
event.current.account == null || event.current.account == null ||
@ -211,6 +216,15 @@ export class WorkspacesService implements Disposable {
getWorkspacesResponse.localWorkspaceInfo = loadLocalWorkspacesResponse.localWorkspaceInfo; getWorkspacesResponse.localWorkspaceInfo = loadLocalWorkspacesResponse.localWorkspaceInfo;
} }
const currentWorkspace = [...(this._cloudWorkspaces ?? []), ...(this._localWorkspaces ?? [])].find(
workspace => workspace.current,
);
if (currentWorkspace != null) {
this._currentWorkspaceId = currentWorkspace.id;
this._currentWorkspace = currentWorkspace;
}
getWorkspacesResponse.cloudWorkspaces = this._cloudWorkspaces ?? []; getWorkspacesResponse.cloudWorkspaces = this._cloudWorkspaces ?? [];
getWorkspacesResponse.localWorkspaces = this._localWorkspaces ?? []; getWorkspacesResponse.localWorkspaces = this._localWorkspaces ?? [];
@ -261,11 +275,13 @@ export class WorkspacesService implements Disposable {
if ( if (
(!options?.force && this._currentWorkspaceAutoAddSetting === WorkspaceAutoAddSetting.Disabled) || (!options?.force && this._currentWorkspaceAutoAddSetting === WorkspaceAutoAddSetting.Disabled) ||
!currentWorkspace.current
!currentWorkspace?.current
) { ) {
return; return;
} }
this._currentWorkspace = currentWorkspace;
if (!(await currentWorkspace.getRepositoryDescriptors())?.length) return; if (!(await currentWorkspace.getRepositoryDescriptors())?.length) return;
const repositories = [ const repositories = [
@ -281,7 +297,12 @@ export class WorkspacesService implements Disposable {
currentWorkspaceRepositoryIdMap.set(repository.id, repository); currentWorkspaceRepositoryIdMap.set(repository.id, repository);
} }
const repositoriesToAdd = repositories.filter(r => !currentWorkspaceRepositoryIdMap.has(r.id)); const repositoriesToAdd = repositories.filter(r => !currentWorkspaceRepositoryIdMap.has(r.id));
if (repositoriesToAdd.length === 0) return;
if (repositoriesToAdd.length === 0) {
if (options?.force) {
void window.showInformationMessage('No new repositories found to add.', { modal: true });
}
return;
}
let chosenRepoPaths: string[] = []; let chosenRepoPaths: string[] = [];
if (!options?.force && this._currentWorkspaceAutoAddSetting === WorkspaceAutoAddSetting.Prompt) { if (!options?.force && this._currentWorkspaceAutoAddSetting === WorkspaceAutoAddSetting.Prompt) {
const addChoice = await window.showInformationMessage( const addChoice = await window.showInformationMessage(

+ 10
- 4
src/views/nodes/repositoriesNode.ts 查看文件

@ -1,5 +1,5 @@
import type { TextEditor } from 'vscode'; import type { TextEditor } from 'vscode';
import { Disposable, TreeItem, TreeItemCollapsibleState, window, workspace } from 'vscode';
import { Disposable, TreeItem, TreeItemCollapsibleState, Uri, window, workspace } from 'vscode';
import type { RepositoriesChangeEvent } from '../../git/gitProviderService'; import type { RepositoriesChangeEvent } from '../../git/gitProviderService';
import { GitUri, unknownGitUri } from '../../git/gitUri'; import { GitUri, unknownGitUri } from '../../git/gitUri';
import { gate } from '../../system/decorators/gate'; import { gate } from '../../system/decorators/gate';
@ -51,7 +51,8 @@ export class RepositoriesNode extends SubscribeableViewNode
getTreeItem(): TreeItem { getTreeItem(): TreeItem {
const isInWorkspacesView = this.view instanceof WorkspacesView; const isInWorkspacesView = this.view instanceof WorkspacesView;
const isSyncedWorkspace = isInWorkspacesView && this.view.container.workspaces.currentWorkspaceId != null;
const isLinkedWorkspace = isInWorkspacesView && this.view.container.workspaces.currentWorkspaceId != null;
const isCurrentLinkedWorkspace = isLinkedWorkspace && this.view.container.workspaces.currentWorkspace != null;
const item = new TreeItem( const item = new TreeItem(
isInWorkspacesView ? 'Current Window' : 'Repositories', isInWorkspacesView ? 'Current Window' : 'Repositories',
isInWorkspacesView ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.Expanded, isInWorkspacesView ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.Expanded,
@ -66,8 +67,13 @@ export class RepositoriesNode extends SubscribeableViewNode
contextValue += '+workspaces'; contextValue += '+workspaces';
} }
if (isSyncedWorkspace) {
contextValue += '+synced';
if (isLinkedWorkspace) {
contextValue += '+linked';
}
if (isCurrentLinkedWorkspace) {
contextValue += '+current';
item.resourceUri = Uri.parse('gitlens-view://workspaces/workspace/current');
} }
item.contextValue = contextValue; item.contextValue = contextValue;

+ 5
- 1
src/views/nodes/workspaceNode.ts 查看文件

@ -89,6 +89,7 @@ export class WorkspaceNode extends ViewNode {
let contextValue = `${ContextValues.Workspace}`; let contextValue = `${ContextValues.Workspace}`;
item.resourceUri = undefined; item.resourceUri = undefined;
const descriptionItems = [];
if (this.workspace.type === WorkspaceType.Cloud) { if (this.workspace.type === WorkspaceType.Cloud) {
contextValue += '+cloud'; contextValue += '+cloud';
} else { } else {
@ -96,6 +97,7 @@ export class WorkspaceNode extends ViewNode {
} }
if (this.workspace.current) { if (this.workspace.current) {
contextValue += '+current'; contextValue += '+current';
descriptionItems.push('current');
item.resourceUri = Uri.parse('gitlens-view://workspaces/workspace/current'); item.resourceUri = Uri.parse('gitlens-view://workspaces/workspace/current');
} }
if (this.workspace.localPath != null) { if (this.workspace.localPath != null) {
@ -120,8 +122,10 @@ export class WorkspaceNode extends ViewNode {
}`; }`;
if (this.workspace.type === WorkspaceType.Cloud && this.workspace.organizationId != null) { if (this.workspace.type === WorkspaceType.Cloud && this.workspace.organizationId != null) {
item.description = 'shared';
descriptionItems.push('shared');
} }
item.description = descriptionItems.join(', ');
return item; return item;
} }

Loading…
取消
儲存