feat: new workspace commands

This commit is contained in:
frelodev 2024-09-09 15:59:41 +02:00
parent e34f8e9ec9
commit 36e2a99f9e
3 changed files with 86 additions and 9 deletions

View file

@ -4,7 +4,7 @@
"description": "VSCode codemp plugin -- code multiplexer", "description": "VSCode codemp plugin -- code multiplexer",
"repository": "https://github.com/hexedtech/codemp-vscode", "repository": "https://github.com/hexedtech/codemp-vscode",
"publisher": "codemp", "publisher": "codemp",
"version": "0.0.1", "version": "0.0.5",
"engines": { "engines": {
"vscode": "^1.81.0" "vscode": "^1.81.0"
}, },
@ -94,6 +94,12 @@
"category": "codemp", "category": "codemp",
"icon": "$(diff-insert)" "icon": "$(diff-insert)"
}, },
{
"command": "codemp.inviteWorkspace",
"title": "Invite in Workspace",
"category": "codemp",
"icon": "$(arrow-up)"
},
{ {
"command": "codemp.listWorkspaces", "command": "codemp.listWorkspaces",
"title": "List Workspaces", "title": "List Workspaces",
@ -101,10 +107,16 @@
"icon": "$(extensions-view-icon)" "icon": "$(extensions-view-icon)"
}, },
{ {
"command": "codemp.listBuffers", "command": "codemp.activeWorkspaces",
"title": "List Buffers", "title": "Active Workspaces",
"category": "codemp", "category": "codemp",
"icon": "$(output-view-icon)" "icon": "$(extensions-view-icon)"
},
{
"command": "codemp.leaveWorkspace",
"title": "Leave Workspace",
"category": "codemp",
"icon": "$(arrow-down)"
}, },
{ {
"command": "codemp.createBuffer", "command": "codemp.createBuffer",
@ -113,16 +125,22 @@
"icon": "$(diff-insert)" "icon": "$(diff-insert)"
}, },
{ {
"command": "codemp.disconnectBuffer", "command": "codemp.listBuffers",
"title": "Disconnect Buffer", "title": "List Buffers",
"category": "codemp", "category": "codemp",
"icon": "$(testing-cancel-icon)" "icon": "$(output-view-icon)"
}, },
{ {
"command": "codemp.sync", "command": "codemp.sync",
"title": "Sync", "title": "Sync",
"category": "codemp", "category": "codemp",
"icon": "$(extensions-refresh)" "icon": "$(extensions-refresh)"
},
{
"command": "codemp.refresh",
"title": "Refresh",
"category": "codemp",
"icon": "$(extensions-refresh)"
} }
], ],
"configuration": { "configuration": {
@ -130,7 +148,7 @@
"properties": { "properties": {
"codemp.server": { "codemp.server": {
"type": "string", "type": "string",
"default": "http://code.mp:50053", "default": "http://codemp.dev:50053",
"description": "Server address to connect to" "description": "Server address to connect to"
}, },
"codemp.username": { "codemp.username": {

View file

@ -223,6 +223,27 @@ export async function createWorkspace() {
return; return;
} }
await client.create_workspace(workspace_id); await client.create_workspace(workspace_id);
vscode.window.showInformationMessage("Created new workspace " + workspace_id);
provider.refresh();
}
export async function inviteToWorkspace() {
if(client===null){
vscode.window.showInformationMessage("Connect first");
return;
}
let workspace_id = await vscode.window.showInputBox({ prompt: "Enter name of the workspace you want to invite the user into" });
if(workspace_id===undefined){
vscode.window.showInformationMessage("You didn't enter a name");
return;
}
let user_id = await vscode.window.showInputBox({ prompt: "Enter name of the user you want to invite" });
if(user_id===undefined){
vscode.window.showInformationMessage("You didn't enter a name");
return;
}
await client.invite_to_workspace(workspace_id,user_id);
vscode.window.showInformationMessage("Invited " + user_id + "into workspace " + workspace_id);
provider.refresh(); provider.refresh();
} }
@ -235,6 +256,40 @@ export async function listWorkspaces() {
provider.refresh(); provider.refresh();
} }
export async function leaveWorkspace() {
if(client===null){
vscode.window.showInformationMessage("Connect first");
return;
}
let workspace_id = await vscode.window.showInputBox({ prompt: "Enter name for workspace you want to leave" });
if(workspace_id===undefined){
vscode.window.showInformationMessage("You didn't enter a name");
return;
}
await client.leave_workspace(workspace_id);
vscode.window.showInformationMessage("Left workspace " + workspace_id);
provider.refresh();
}
export async function activeWorkspaces() {
if(client===null){
vscode.window.showInformationMessage("Connect first");
return;
}
workspace_list = await client.active_workspaces();
provider.refresh();
}
export async function refresh() {
if(client===null){
vscode.window.showInformationMessage("Connect first");
return;
}
await client.refresh();
vscode.window.showInformationMessage("Refreshed Session token");
provider.refresh();
}
// This method is called when your extension is deactivated // This method is called when your extension is deactivated
export function deactivate() { export function deactivate() {

View file

@ -20,10 +20,14 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('codemp.join', commands.join), vscode.commands.registerCommand('codemp.join', commands.join),
vscode.commands.registerCommand('codemp.attach', commands.attach), vscode.commands.registerCommand('codemp.attach', commands.attach),
vscode.commands.registerCommand('codemp.createWorkspace', commands.createWorkspace), vscode.commands.registerCommand('codemp.createWorkspace', commands.createWorkspace),
vscode.commands.registerCommand('codemp.inviteWorkspace', commands.inviteToWorkspace),
vscode.commands.registerCommand('codemp.listWorkspaces', commands.listWorkspaces), vscode.commands.registerCommand('codemp.listWorkspaces', commands.listWorkspaces),
vscode.commands.registerCommand('codemp.activeWorkspaces', commands.activeWorkspaces),
vscode.commands.registerCommand('codemp.leaveWorkspace', commands.leaveWorkspace),
vscode.commands.registerCommand('codemp.createBuffer', commands.createBuffer), vscode.commands.registerCommand('codemp.createBuffer', commands.createBuffer),
vscode.commands.registerCommand('codemp.listBuffers', commands.listBuffers), vscode.commands.registerCommand('codemp.listBuffers', commands.listBuffers),
vscode.commands.registerCommand('codemp.sync', commands.sync), vscode.commands.registerCommand('codemp.sync', commands.sync),
vscode.commands.registerCommand('codemp.refresh', commands.refresh),
]) { ]) {
context.subscriptions.push(cmd); context.subscriptions.push(cmd);
} }