refactor(webui): simplify directory picker state and filtering
This commit is contained in:
1 parent
66c8d41f66
commit
8e8b14897e
3 files changed
+17
-15
No files matched your search
@@ -56,10 +56,12 @@ def browse_workspace_directories(
|
||||
path = path.parent
|
||||
partial = True
|
||||
path = path.resolve(strict=True)
|
||||
folded_query = query.casefold()
|
||||
matches: list[ProjectDirectory] = []
|
||||
with os.scandir(path) as entries:
|
||||
for entry in entries:
|
||||
if not entry.name.casefold().startswith(prefix) or query.casefold() not in entry.name.casefold():
|
||||
name = entry.name.casefold()
|
||||
if not name.startswith(prefix) or folded_query not in name:
|
||||
continue
|
||||
try:
|
||||
if not entry.is_dir():
|
||||
|
||||
@@ -178,7 +178,8 @@ def workspaces_payload(
|
||||
can_use_full_access: bool,
|
||||
folder_picker_available: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
default_access_mode = read_webui_default_access_mode()
|
||||
state = read_webui_workspace_state()
|
||||
default_access_mode = state["default_access_mode"]
|
||||
default_scope = (
|
||||
default_workspace_scope(
|
||||
default_workspace,
|
||||
@@ -195,11 +196,11 @@ def workspaces_payload(
|
||||
"host": {"name": socket.gethostname(), "platform": platform.system()},
|
||||
"favorite_projects": [
|
||||
{"name": Path(path).name or path, "path": path}
|
||||
for path in read_webui_workspace_state()["favorite_projects"]
|
||||
for path in state["favorite_projects"]
|
||||
],
|
||||
"recent_projects": [
|
||||
{"name": Path(path).name or path, "path": path}
|
||||
for path in read_webui_workspace_state()["recent_projects"]
|
||||
for path in state["recent_projects"]
|
||||
],
|
||||
"controls": {
|
||||
"can_change_project": can_change_project,
|
||||
|
||||
Reference in new issue
Block a user