feat: welcome view

This commit is contained in:
əlemi 2024-09-06 23:15:03 +02:00
parent a5691d550a
commit 7ff90b8a3b
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 9 additions and 14 deletions

View file

@ -25,6 +25,12 @@
} }
] ]
}, },
"viewsWelcome": [
{
"view": "codemp-tree-view",
"contents": "[codemp](https://codemp.dev) -- code multiplexer\n[Connect](command:codemp.connect)"
}
],
"views": { "views": {
"codemp-tree-container": [ "codemp-tree-container": [

View file

@ -1,5 +1,4 @@
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import * as codemp from 'codemp';
import { client, workspace, workspace_list } from './commands'; import { client, workspace, workspace_list } from './commands';
export class CodempTreeProvider implements vscode.TreeDataProvider<CodempTreeItem> { export class CodempTreeProvider implements vscode.TreeDataProvider<CodempTreeItem> {
@ -20,9 +19,6 @@ export class CodempTreeProvider implements vscode.TreeDataProvider<CodempTreeIte
async getChildren(element?: CodempTreeItem): Promise<CodempTreeItem[]> { async getChildren(element?: CodempTreeItem): Promise<CodempTreeItem[]> {
if (element) { if (element) {
switch (element.type) { switch (element.type) {
case Type.Root:
if (client === null) { return [] };
return workspace_list.map((x) => new CodempTreeItem(x, Type.Workspace));
case Type.Workspace: case Type.Workspace:
if (workspace === null) { return [] }; if (workspace === null) { return [] };
if (element.label == workspace.id()) { if (element.label == workspace.id()) {
@ -45,14 +41,8 @@ export class CodempTreeProvider implements vscode.TreeDataProvider<CodempTreeIte
return []; return [];
} }
} else { } else {
if(client === null) { if(client === null) return [];
return [ return workspace_list.map((x) => new CodempTreeItem(x, Type.Workspace));
new CodempTreeItem("Connect", Type.Root)
];
}
return [
new CodempTreeItem("Codemp", Type.Root)
];
} }
} }
@ -66,8 +56,7 @@ class CodempTreeItem extends vscode.TreeItem {
} }
} }
enum Type{ enum Type {
Root,
Workspace, Workspace,
BufferContainer, BufferContainer,
UserContainer, UserContainer,