Skip to content

Commit

Permalink
set current workspace now returns workspace object
Browse files Browse the repository at this point in the history
  • Loading branch information
hans-permana committed Feb 10, 2017
1 parent 4f8d20c commit 44b192f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dedop/ui/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class Workspace:
def __init__(self, workspace_dir, name, is_current=True):
def __init__(self, workspace_dir, name, is_current=False):
self._workspace_dir = workspace_dir if workspace_dir else DEFAULT_WORKSPACE_PATH
self._name = name
self._is_current = is_current
Expand Down
2 changes: 2 additions & 0 deletions dedop/ui/workspace_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def get_current_workspace(self) -> Workspace:
def set_current_workspace_name(self, workspace_name: str):
self._assert_workspace_exists(workspace_name)
_writeline(os.path.join(self._workspaces_dir, _CURRENT_FILE_NAME), workspace_name)
workspace_dir = self.get_workspace_path(workspace_name)
return Workspace(workspace_dir, workspace_name, is_current=True)

def workspace_exists(self, workspace_name) -> bool:
return os.path.exists(self.get_workspace_path(workspace_name))
Expand Down
14 changes: 8 additions & 6 deletions dedop/webapi/websocket.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List

from dedop.ui.workspace_manager import WorkspaceManager


Expand Down Expand Up @@ -42,8 +40,12 @@ def get_current_workspace(self) -> dict:
workspace = self.workspace_manager.get_current_workspace()
return workspace.to_json_dict()

def set_current_workspace(self, workspace_name) -> None:
self.workspace_manager.set_current_workspace_name(workspace_name)
def set_current_workspace(self, workspace_name) -> dict:
workspace = self.workspace_manager.set_current_workspace_name(workspace_name)
return workspace.to_json_dict()

def get_all_workspaces(self) -> List[str]:
return self.workspace_manager.get_workspace_names()
def get_all_workspaces(self) -> dict:
workspace_names = self.workspace_manager.get_workspace_names()
return {
"workspaces": workspace_names
}

0 comments on commit 44b192f

Please sign in to comment.