mirror of
https://github.com/hexedtech/codemp-sublime.git
synced 2025-03-28 20:31:32 +01:00
made create and delete workspaces as internal commands as well.
Fixed the same issues that the workspace browser had for the creation and deletion also in the server browser.
This commit is contained in:
parent
164c60103b
commit
ce87c5334d
3 changed files with 48 additions and 36 deletions
|
@ -64,20 +64,20 @@
|
||||||
// "user": 'lupo'
|
// "user": 'lupo'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
"caption": "Codemp: Create Workspace",
|
// "caption": "Codemp: Create Workspace",
|
||||||
"command": "codemp_create_workspace",
|
// "command": "codemp_create_workspace",
|
||||||
"args": {
|
// "args": {
|
||||||
// "id": 'lmaaaao'
|
// // "id": 'lmaaaao'
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
"caption": "Codemp: Delete Workspace",
|
// "caption": "Codemp: Delete Workspace",
|
||||||
"command": "codemp_delete_workspace",
|
// "command": "codemp_delete_workspace",
|
||||||
"args": {
|
// "args": {
|
||||||
// "id": 'lmaaaao'
|
// // "id": 'lmaaaao'
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
"caption": "Codemp: Join Buffer",
|
"caption": "Codemp: Join Buffer",
|
||||||
"command": "codemp_join_buffer",
|
"command": "codemp_join_buffer",
|
||||||
|
|
|
@ -208,9 +208,9 @@ class CodempCreateWorkspaceCommand(sublime_plugin.WindowCommand):
|
||||||
def is_enabled(self):
|
def is_enabled(self):
|
||||||
return session.is_active()
|
return session.is_active()
|
||||||
|
|
||||||
def input(self, args):
|
# def input(self, args):
|
||||||
if "workspace_id" not in args:
|
# if "workspace_id" not in args:
|
||||||
return SimpleTextInput(("workspace_id", "new workspace name"))
|
# return SimpleTextInput(("workspace_id", "new workspace name"))
|
||||||
|
|
||||||
def run(self, workspace_id: str): # pyright: ignore[reportIncompatibleMethodOverride]
|
def run(self, workspace_id: str): # pyright: ignore[reportIncompatibleMethodOverride]
|
||||||
try:
|
try:
|
||||||
|
@ -224,25 +224,26 @@ class CodempDeleteWorkspaceCommand(sublime_plugin.WindowCommand):
|
||||||
def is_enabled(self):
|
def is_enabled(self):
|
||||||
return session.is_active()
|
return session.is_active()
|
||||||
|
|
||||||
def input(self, args):
|
# def input(self, args):
|
||||||
workspaces = session.get_workspaces(owned=True, invited=False) # noqa: F841
|
# workspaces = session.get_workspaces(owned=True, invited=False) # noqa: F841
|
||||||
if "workspace_id" not in args:
|
# if "workspace_id" not in args:
|
||||||
return SimpleListInput(("workspace_id", workspaces))
|
# return SimpleListInput(("workspace_id", workspaces))
|
||||||
|
|
||||||
def run(self, workspace_id: str): # pyright: ignore[reportIncompatibleMethodOverride]
|
def run(self, workspace_id: str): # pyright: ignore[reportIncompatibleMethodOverride]
|
||||||
try:
|
if workspace_id in workspaces:
|
||||||
vws = workspaces.lookupId(workspace_id)
|
|
||||||
if not sublime.ok_cancel_dialog(
|
if not sublime.ok_cancel_dialog(
|
||||||
"You are currently attached to '{workspace_id}'.\n\
|
"You are currently attached to '{workspace_id}'.\n\
|
||||||
Do you want to detach and delete it?",
|
Do you want to detach and delete it?",
|
||||||
ok_title="yes", title="Delete Workspace?",
|
ok_title="yes", title="Delete Workspace?",
|
||||||
):
|
): return
|
||||||
return
|
|
||||||
self.window.run_command(
|
self.window.run_command(
|
||||||
"codemp_leave_workspace",
|
"codemp_leave_workspace",
|
||||||
{"workspace_id": workspace_id})
|
{"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
|
session.client.delete_workspace(workspace_id).wait()
|
||||||
finally:
|
|
||||||
session.client.delete_workspace(workspace_id)
|
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ class QPServerBrowser():
|
||||||
def edit_server(self):
|
def edit_server(self):
|
||||||
actions = [
|
actions = [
|
||||||
qpi("Back", color=qpg.QP_COLOR_CYANISH, letter=qpg.QP_BACK),
|
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("New Workspace", color=qpg.QP_COLOR_GREENISH, letter=qpg.QP_ADD),
|
||||||
qpi("Delete Workspace", color=qpg.QP_COLOR_REDISH, letter=qpg.QP_NO)
|
qpi("Delete Workspace", color=qpg.QP_COLOR_REDISH, letter=qpg.QP_NO)
|
||||||
]
|
]
|
||||||
|
@ -84,27 +85,37 @@ class QPServerBrowser():
|
||||||
self.run()
|
self.run()
|
||||||
|
|
||||||
if index == 1:
|
if index == 1:
|
||||||
|
self.window.run_command("codemp_disconnect", {})
|
||||||
|
|
||||||
|
if index == 2:
|
||||||
def create_workspace(name):
|
def create_workspace(name):
|
||||||
self.window.run_command(
|
self.window.run_command(
|
||||||
"codemp_create_workspace", {"workspace_id": name})
|
"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)
|
self.window.show_input_panel("New Workspace Name", "", create_workspace, None, self.edit_server)
|
||||||
|
|
||||||
if index == 2:
|
if index == 3:
|
||||||
def delete_workspace(index):
|
def delete_workspace(index):
|
||||||
if index == -1 or index == 0:
|
if index == -1 or index == 0:
|
||||||
self.edit_server()
|
self.edit_server()
|
||||||
# we must be careful here. here with index 1 we are selecting the correct
|
return
|
||||||
# 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?
|
|
||||||
selected = self.entries[index]
|
selected = self.entries[index]
|
||||||
self.window.run_command(
|
self.window.run_command(
|
||||||
"codemp_delete_workspace",
|
"codemp_delete_workspace",
|
||||||
{"workspace_id": selected.trigger})
|
{"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())
|
show_qp(self.window, self.entries, delete_workspace, self.qp_placeholder())
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue