diff --git a/Codemp.sublime-commands b/Codemp.sublime-commands index 42523c6..c6c0858 100644 --- a/Codemp.sublime-commands +++ b/Codemp.sublime-commands @@ -64,20 +64,20 @@ // "user": 'lupo' } }, - { - "caption": "Codemp: Create Workspace", - "command": "codemp_create_workspace", - "args": { - // "id": 'lmaaaao' - } - }, - { - "caption": "Codemp: Delete Workspace", - "command": "codemp_delete_workspace", - "args": { - // "id": 'lmaaaao' - } - }, + // { + // "caption": "Codemp: Create Workspace", + // "command": "codemp_create_workspace", + // "args": { + // // "id": 'lmaaaao' + // } + // }, + // { + // "caption": "Codemp: Delete Workspace", + // "command": "codemp_delete_workspace", + // "args": { + // // "id": 'lmaaaao' + // } + // }, { "caption": "Codemp: Join Buffer", "command": "codemp_join_buffer", diff --git a/plugin/commands/client.py b/plugin/commands/client.py index bdadae7..16714fc 100644 --- a/plugin/commands/client.py +++ b/plugin/commands/client.py @@ -208,9 +208,9 @@ class CodempCreateWorkspaceCommand(sublime_plugin.WindowCommand): def is_enabled(self): return session.is_active() - def input(self, args): - if "workspace_id" not in args: - return SimpleTextInput(("workspace_id", "new workspace name")) + # def input(self, args): + # if "workspace_id" not in args: + # return SimpleTextInput(("workspace_id", "new workspace name")) def run(self, workspace_id: str): # pyright: ignore[reportIncompatibleMethodOverride] try: @@ -224,25 +224,26 @@ class CodempDeleteWorkspaceCommand(sublime_plugin.WindowCommand): def is_enabled(self): return session.is_active() - def input(self, args): - workspaces = session.get_workspaces(owned=True, invited=False) # noqa: F841 - if "workspace_id" not in args: - return SimpleListInput(("workspace_id", workspaces)) + # def input(self, args): + # workspaces = session.get_workspaces(owned=True, invited=False) # noqa: F841 + # if "workspace_id" not in args: + # return SimpleListInput(("workspace_id", workspaces)) def run(self, workspace_id: str): # pyright: ignore[reportIncompatibleMethodOverride] - try: - vws = workspaces.lookupId(workspace_id) + if workspace_id in workspaces: 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 + ): return self.window.run_command( "codemp_leave_workspace", {"workspace_id": workspace_id}) + else: + if not sublime.ok_cancel_dialog( + f"Confirm you want to delete the workspace '{workspace_id}'", + ok_title="delete", title="Delete Workspace?", + ): return - except KeyError: pass - finally: - session.client.delete_workspace(workspace_id) + session.client.delete_workspace(workspace_id).wait() diff --git a/plugin/quickpanel/qpbrowser.py b/plugin/quickpanel/qpbrowser.py index 21a7326..ef4dec3 100644 --- a/plugin/quickpanel/qpbrowser.py +++ b/plugin/quickpanel/qpbrowser.py @@ -71,6 +71,7 @@ class QPServerBrowser(): def edit_server(self): actions = [ qpi("Back", color=qpg.QP_COLOR_CYANISH, letter=qpg.QP_BACK), + qpi("Disconnect", color=qpg.QP_COLOR_REDISH, letter=qpg.QP_BACK), qpi("New Workspace", color=qpg.QP_COLOR_GREENISH, letter=qpg.QP_ADD), qpi("Delete Workspace", color=qpg.QP_COLOR_REDISH, letter=qpg.QP_NO) ] @@ -84,27 +85,37 @@ class QPServerBrowser(): self.run() if index == 1: + self.window.run_command("codemp_disconnect", {}) + + if index == 2: def create_workspace(name): self.window.run_command( "codemp_create_workspace", {"workspace_id": name}) - self.run() + self.window.run_command( + "codemp_browse_server", {}) + self.window.show_input_panel("New Workspace Name", "", create_workspace, None, self.edit_server) - if index == 2: + if index == 3: def delete_workspace(index): if index == -1 or index == 0: self.edit_server() - # we must be careful here. here with index 1 we are selecting the correct - # workspace, because the index zero in the entries is the workspace action submenu. - # which is occupied by the back action. - # if we add extra non workspace entries, then we must shift the index accordingly. - # Do this differently? + return + selected = self.entries[index] self.window.run_command( "codemp_delete_workspace", {"workspace_id": selected.trigger}) + self.window.run_command( + "codemp_browse_server", {}) - + if len(self.entries) < 2: + sublime.message_dialog("You don't have workspaces to delete!") + sublime.set_timeout(self.run, 10) + else: + selentries = self.entries + selentries[0] = qpi("Back", color=qpg.QP_COLOR_CYANISH, letter=qpg.QP_BACK) + show_qp(self.window, selentries, delete_workspace, self.qp_placeholder(), keepopen=False) show_qp(self.window, self.entries, delete_workspace, self.qp_placeholder())