Переглянути джерело

Improves visuals and descriptions for linked workspaces

main
Ramin Tadayon 1 рік тому
джерело
коміт
624385fae4
Не вдалося знайти GPG ключ що відповідає даному підпису Ідентифікатор GPG ключа: 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",
"when": "viewItem =~ /gitlens:repositories\\b(?=.*?\\b\\+synced\\b)/",
"when": "viewItem =~ /gitlens:repositories\\b(?=.*?\\b\\+linked\\b)(?=.*?\\b\\+current\\b)/",
"group": "1_gitlens_actions@3"
},
{
@ -11218,7 +11218,7 @@
},
{
"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"
},
{

+ 23
- 2
src/plus/workspaces/workspacesService.ts Переглянути файл

@ -50,6 +50,7 @@ export class WorkspacesService implements Disposable {
private _workspacesPathProvider: WorkspacesPathMappingProvider;
private _currentWorkspaceId: string | undefined;
private _currentWorkspaceAutoAddSetting: WorkspaceAutoAddSetting = WorkspaceAutoAddSetting.Disabled;
private _currentWorkspace: CloudWorkspace | LocalWorkspace | undefined;
constructor(
private readonly container: Container,
@ -75,6 +76,10 @@ export class WorkspacesService implements Disposable {
return this._currentWorkspaceId;
}
get currentWorkspace(): CloudWorkspace | LocalWorkspace | undefined {
return this._currentWorkspace;
}
private onSubscriptionChanged(event: SubscriptionChangeEvent): void {
if (
event.current.account == null ||
@ -211,6 +216,15 @@ export class WorkspacesService implements Disposable {
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.localWorkspaces = this._localWorkspaces ?? [];
@ -261,11 +275,13 @@ export class WorkspacesService implements Disposable {
if (
(!options?.force && this._currentWorkspaceAutoAddSetting === WorkspaceAutoAddSetting.Disabled) ||
!currentWorkspace.current
!currentWorkspace?.current
) {
return;
}
this._currentWorkspace = currentWorkspace;
if (!(await currentWorkspace.getRepositoryDescriptors())?.length) return;
const repositories = [
@ -281,7 +297,12 @@ export class WorkspacesService implements Disposable {
currentWorkspaceRepositoryIdMap.set(repository.id, repository);
}
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[] = [];
if (!options?.force && this._currentWorkspaceAutoAddSetting === WorkspaceAutoAddSetting.Prompt) {
const addChoice = await window.showInformationMessage(

+ 10
- 4
src/views/nodes/repositoriesNode.ts Переглянути файл

@ -1,5 +1,5 @@
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 { GitUri, unknownGitUri } from '../../git/gitUri';
import { gate } from '../../system/decorators/gate';
@ -51,7 +51,8 @@ export class RepositoriesNode extends SubscribeableViewNode
getTreeItem(): TreeItem {
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(
isInWorkspacesView ? 'Current Window' : 'Repositories',
isInWorkspacesView ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.Expanded,
@ -66,8 +67,13 @@ export class RepositoriesNode extends SubscribeableViewNode
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;

+ 5
- 1
src/views/nodes/workspaceNode.ts Переглянути файл

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

Завантаження…
Відмінити
Зберегти