From 36e2a99f9e545fe43ed320305e92c6ba5cb70024 Mon Sep 17 00:00:00 2001 From: frelodev Date: Mon, 9 Sep 2024 15:59:41 +0200 Subject: [PATCH] feat: new workspace commands --- package.json | 36 +++++++++++++++++++++++-------- src/commands.ts | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ src/extension.ts | 4 ++++ 3 files changed, 86 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 64e5efd..93bf2cb 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "VSCode codemp plugin -- code multiplexer", "repository": "https://github.com/hexedtech/codemp-vscode", "publisher": "codemp", - "version": "0.0.1", + "version": "0.0.5", "engines": { "vscode": "^1.81.0" }, @@ -94,6 +94,12 @@ "category": "codemp", "icon": "$(diff-insert)" }, + { + "command": "codemp.inviteWorkspace", + "title": "Invite in Workspace", + "category": "codemp", + "icon": "$(arrow-up)" + }, { "command": "codemp.listWorkspaces", "title": "List Workspaces", @@ -101,10 +107,16 @@ "icon": "$(extensions-view-icon)" }, { - "command": "codemp.listBuffers", - "title": "List Buffers", + "command": "codemp.activeWorkspaces", + "title": "Active Workspaces", "category": "codemp", - "icon": "$(output-view-icon)" + "icon": "$(extensions-view-icon)" + }, + { + "command": "codemp.leaveWorkspace", + "title": "Leave Workspace", + "category": "codemp", + "icon": "$(arrow-down)" }, { "command": "codemp.createBuffer", @@ -113,16 +125,22 @@ "icon": "$(diff-insert)" }, { - "command": "codemp.disconnectBuffer", - "title": "Disconnect Buffer", + "command": "codemp.listBuffers", + "title": "List Buffers", "category": "codemp", - "icon": "$(testing-cancel-icon)" + "icon": "$(output-view-icon)" }, { "command": "codemp.sync", "title": "Sync", "category": "codemp", "icon": "$(extensions-refresh)" + }, + { + "command": "codemp.refresh", + "title": "Refresh", + "category": "codemp", + "icon": "$(extensions-refresh)" } ], "configuration": { @@ -130,7 +148,7 @@ "properties": { "codemp.server": { "type": "string", - "default": "http://code.mp:50053", + "default": "http://codemp.dev:50053", "description": "Server address to connect to" }, "codemp.username": { @@ -173,4 +191,4 @@ "dependencies": { "codemp": "^0.0.5" } -} +} \ No newline at end of file diff --git a/src/commands.ts b/src/commands.ts index 96e7448..91f7e40 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -223,6 +223,27 @@ export async function createWorkspace() { return; } 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(); } @@ -235,6 +256,40 @@ export async function listWorkspaces() { 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 export function deactivate() { diff --git a/src/extension.ts b/src/extension.ts index a836c94..e3b8564 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -20,10 +20,14 @@ export function activate(context: vscode.ExtensionContext) { vscode.commands.registerCommand('codemp.join', commands.join), vscode.commands.registerCommand('codemp.attach', commands.attach), 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.activeWorkspaces', commands.activeWorkspaces), + vscode.commands.registerCommand('codemp.leaveWorkspace', commands.leaveWorkspace), vscode.commands.registerCommand('codemp.createBuffer', commands.createBuffer), vscode.commands.registerCommand('codemp.listBuffers', commands.listBuffers), vscode.commands.registerCommand('codemp.sync', commands.sync), + vscode.commands.registerCommand('codemp.refresh', commands.refresh), ]) { context.subscriptions.push(cmd); }