From a8b38e130743a24a2887a39249cf5a22fbdb2d44 Mon Sep 17 00:00:00 2001 From: cschen Date: Mon, 2 Sep 2024 11:38:29 +0200 Subject: [PATCH] feat: new commands Former-commit-id: 13cb46afc8f68d0c053ad02ff4426634020be0bd --- Codemp.sublime-commands | 22 +++++++ ...-cp38-macosx_11_0_arm64.whl.REMOVED.git-id | 2 +- plugin.py | 57 +++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/Codemp.sublime-commands b/Codemp.sublime-commands index 314d0e1..218e76f 100644 --- a/Codemp.sublime-commands +++ b/Codemp.sublime-commands @@ -55,6 +55,28 @@ // "id": 'lmaaaao' } }, + { + "caption": "Codemp: Invite To Workspace", + "command": "codemp_invite_to_workspace", + "arg": { + // "id": 'lmaaaao' + // "user": 'lupo' + } + }, + { + "caption": "Codemp: Create Workspace", + "command": "codemp_create_workspace", + "arg": { + // "id": 'lmaaaao' + } + }, + { + "caption": "Codemp: Delete Workspace", + "command": "codemp_delete_workspace", + "arg": { + // "id": 'lmaaaao' + } + }, { "caption": "Codemp: Join Buffer", "command": "codemp_join_buffer", diff --git a/bindings/codemp-0.7.0-cp38-cp38-macosx_11_0_arm64.whl.REMOVED.git-id b/bindings/codemp-0.7.0-cp38-cp38-macosx_11_0_arm64.whl.REMOVED.git-id index 8cfe1cc..0e6a02e 100644 --- a/bindings/codemp-0.7.0-cp38-cp38-macosx_11_0_arm64.whl.REMOVED.git-id +++ b/bindings/codemp-0.7.0-cp38-cp38-macosx_11_0_arm64.whl.REMOVED.git-id @@ -1 +1 @@ -d86401dbaaca8ebe4d8998563d9fceff4b6daac0 \ No newline at end of file +f0cef32c2765ba5d1bcaca6e11544caacf717006 \ No newline at end of file diff --git a/plugin.py b/plugin.py index afae1dc..216a778 100644 --- a/plugin.py +++ b/plugin.py @@ -276,6 +276,63 @@ class CodempLeaveWorkspaceCommand(sublime_plugin.WindowCommand): return ActiveWorkspacesIdList() +class CodempInviteToWorkspaceCommand(sublime_plugin.WindowCommand): + def is_enabled(self) -> bool: + return client.codemp is not None and len(client.all_workspaces(self.window)) > 0 + + def run(self, workspace_id: str, user: str): + assert client.codemp is not None + client.codemp.invite_to_workspace(workspace_id, user) + logger.debug(f"invite sent to user {user} for workspace {workspace_id}.") + + def input(self, args): + if "workspace_id" not in args: + wslist = client.codemp.list_workspaces(True, False) + return SimpleListInput( + ("workspace_id", wslist.wait()), ("user", "invitee's username") + ) + + if "user" not in args: + return SimpleTextInput(("user", "invitee's username")) + + +class CodempCreateWorkspaceCommand(sublime_plugin.WindowCommand): + def is_enabled(self): + return client.codemp is not None + + def run(self, workspace_id: str): + assert client.codemp is not None + client.codemp.create_workspace(workspace_id) + + def input(self, args): + if "workspace_id" not in args: + return SimpleTextInput(("workspace_id", "new workspace")) + + +class CodempDeleteWorkspaceCommand(sublime_plugin.WindowCommand): + def is_enabled(self): + return client.codemp is not None and len(client.all_workspaces(self.window)) > 0 + + def run(self, workspace_id: str): + assert client.codemp is not None + + vws = client.workspace_from_id(workspace_id) + if vws is not None: + if not sublime.ok_cancel_dialog( + "You are currently attached to '{workspace_id}'.\n\ + Do you want to detach and delete it?", + ok_title="yes", + title="Delete Workspace?", + ): + return + if not client.codemp.leave_workspace(workspace_id): + logger.debug("error while leaving the workspace:") + return + client.uninstall_workspace(vws) + + client.codemp.delete_workspace(workspace_id) + + # WORKSPACE COMMANDS #############################################################################