Browse Source

Hides some commands from empty workspaces

main
Ramin Tadayon 1 year ago
parent
commit
7a5d0be01f
No known key found for this signature in database GPG Key ID: 79D60DDE3DFB95F5
3 changed files with 14 additions and 6 deletions
  1. +4
    -4
      package.json
  2. +4
    -1
      src/plus/workspaces/workspacesService.ts
  3. +6
    -1
      src/views/nodes/workspaceNode.ts

+ 4
- 4
package.json View File

@ -11151,12 +11151,12 @@
},
{
"command": "gitlens.views.workspaces.locateAllRepos",
"when": "viewItem =~ /gitlens:workspace\\b(?=.*?\\b\\+cloud\\b)/",
"when": "viewItem =~ /gitlens:workspace\\b(?=.*?\\b\\+cloud\\b)(?!.*?\\b\\+empty\\b)/",
"group": "inline@2"
},
{
"command": "gitlens.views.workspaces.createLocal",
"when": "viewItem =~ /gitlens:workspace\\b(?=.*?\\b\\+(cloud|local)\\b)(?!.*?\\b\\+current\\b)(?!.*?\\b\\+hasPath\\b)/",
"when": "viewItem =~ /gitlens:workspace\\b(?=.*?\\b\\+(cloud|local)\\b)(?!.*?\\b\\+current\\b)(?!.*?\\b\\+hasPath\\b)(?!.*?\\b\\+empty\\b)/",
"group": "inline@3"
},
{
@ -11172,12 +11172,12 @@
},
{
"command": "gitlens.views.workspaces.locateAllRepos",
"when": "viewItem =~ /gitlens:workspace\\b(?=.*?\\b\\+cloud\\b)/",
"when": "viewItem =~ /gitlens:workspace\\b(?=.*?\\b\\+cloud\\b)(?!.*?\\b\\+empty\\b)/",
"group": "1_gitlens_actions@2"
},
{
"command": "gitlens.views.workspaces.createLocal",
"when": "viewItem =~ /gitlens:workspace\\b(?=.*?\\b\\+(cloud|local)\\b)/",
"when": "viewItem =~ /gitlens:workspace\\b(?=.*?\\b\\+(cloud|local)\\b)(?!.*?\\b\\+empty\\b)/",
"group": "2_gitlens_quickopen@3"
},
{

+ 4
- 1
src/plus/workspaces/workspacesService.ts View File

@ -983,7 +983,10 @@ export class WorkspacesService implements Disposable {
const workspaceRepositoriesByName = await workspace.getRepositoriesByName();
if (workspaceRepositoriesByName.size === 0) {
void window.showErrorMessage('No repositories could be found in this workspace.', { modal: true });
void window.showErrorMessage(
'No repositories in this workspace could be found locally. Please locate at least one repository.',
{ modal: true },
);
return;
}

+ 6
- 1
src/views/nodes/workspaceNode.ts View File

@ -84,7 +84,7 @@ export class WorkspaceNode extends ViewNode {
return this._children;
}
getTreeItem(): TreeItem {
async getTreeItem(): Promise<TreeItem> {
const item = new TreeItem(this.workspace.name, TreeItemCollapsibleState.Collapsed);
let contextValue = `${ContextValues.Workspace}`;
@ -101,6 +101,11 @@ export class WorkspaceNode extends ViewNode {
if (this.workspace.localPath != null) {
contextValue += '+hasPath';
}
if ((await this.workspace.getRepositoryDescriptors())?.length === 0) {
contextValue += '+empty';
}
item.id = this.id;
item.contextValue = contextValue;
item.iconPath = new ThemeIcon(this.workspace.type == WorkspaceType.Cloud ? 'cloud' : 'folder');

Loading…
Cancel
Save