Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4304f32
Added dropdown to select drives in new project
sumana-2705 Mar 7, 2025
c49869e
Merge branch 'neuroinformatics-unit:main' into mount_external_drives
sumana-2705 Mar 13, 2025
aa38d36
updated UI of the Tree for clean view
sumana-2705 Mar 13, 2025
11140ca
Merge branch 'mount_external_drives' of https://github.com/sumana-270…
sumana-2705 Mar 13, 2025
42f41cd
made changes as per suggestions
sumana-2705 Mar 14, 2025
f5facb7
Merge branch 'neuroinformatics-unit:main' into mount_external_drives
sumana-2705 Mar 14, 2025
4db86db
Resolved merge conflicts
sumana-2705 Mar 23, 2025
8f00f79
used psutil replacing win32api
sumana-2705 Mar 23, 2025
4b08cbb
checked functionality in Mac and adjusted code
sumana-2705 Mar 23, 2025
9447c18
wrote code for linux and mac combinely
sumana-2705 Mar 23, 2025
a7b14fe
Merge branch 'neuroinformatics-unit:main' into mount_external_drives
sumana-2705 Jun 2, 2025
6064b31
included suggested changes
sumana-2705 Jun 2, 2025
b62f967
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 2, 2025
357ac51
Added tests for SelectDirectoryTree Modal screen
sumana-2705 Jun 10, 2025
ef40da9
Merge branch 'neuroinformatics-unit:main' into mount_external_drives
sumana-2705 Jun 10, 2025
c268f76
Merge branch 'mount_external_drives' of https://github.com/sumana-270…
sumana-2705 Jun 10, 2025
d1bc05f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 10, 2025
44a09f9
corrected tests
sumana-2705 Jun 15, 2025
6577f49
updated tests for SelectDirectoryTreeScreen
sumana-2705 Jun 15, 2025
7db7b69
corrected tests for SelectDirectoryTreeScreen
sumana-2705 Jun 15, 2025
7045467
Resolved merge conflicts in test_tui_selectdirectorytree_modalscreen.py
sumana-2705 Jun 15, 2025
9b1befa
Merge branch 'neuroinformatics-unit:main' into mount_external_drives
sumana-2705 Jun 18, 2025
ca78172
Added dropdown to select drives in new project
sumana-2705 Mar 7, 2025
429301c
checked functionality in Mac and adjusted code
sumana-2705 Mar 23, 2025
cd5026b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 10, 2025
0861abc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2025
1e1868a
corrected id in the modal_dialogs.py file
sumana-2705 Jun 18, 2025
92cccfa
Add `psutil` to `pyproject.toml`
JoeZiminski Jun 19, 2025
1b1802c
Merge branch 'main' into mount_external_drives
JoeZiminski Jun 19, 2025
b18a321
Refactor get_selected_drive and update test to use monkeypatching
sumana-2705 Jun 20, 2025
c52de58
Merge branch 'mount_external_drives' of https://github.com/sumana-270…
sumana-2705 Jun 20, 2025
262d001
Merge remote-tracking branch 'upstream/main' into mount_external_drives
JoeZiminski Jun 21, 2025
37a5826
Fix tests.
JoeZiminski Jun 21, 2025
41eaf07
Use base dir on macos.
JoeZiminski Jun 21, 2025
f2076d9
Small changes.
JoeZiminski Jun 21, 2025
1fc26d2
Use psutil disk_partitions(all=True)
JoeZiminski Jun 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions datashuttle/tui/screens/modal_dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

from datashuttle.tui.app import App

import os
import platform
from pathlib import Path

from textual.containers import Container, Horizontal
from textual.screen import ModalScreen
from textual.widgets import Button, Input, Label, Static
from textual.widgets import Button, Input, Label, Select, Static

from datashuttle.tui.custom_widgets import CustomDirectoryTree
from datashuttle.tui.utils.tui_decorators import require_double_click
Expand Down Expand Up @@ -124,10 +126,16 @@ def __init__(self, mainwindow: App, path_: Optional[Path] = None) -> None:
super(SelectDirectoryTreeScreen, self).__init__()
self.mainwindow = mainwindow

self.available_drives = self.get_drives()
Comment thread
sumana-2705 marked this conversation as resolved.
Outdated

if path_ is None:
path_ = Path().home()
self.path_ = path_

if platform.system() == "Windows":
self.selected_drive = self.path_.drive + "\\"
else:
self.selected_drive = "/"
self.prev_click_time = 0

def compose(self) -> ComposeResult:
Expand All @@ -139,15 +147,49 @@ def compose(self) -> ComposeResult:

yield Container(
Static(label_message, id="select_directory_tree_screen_label"),
Select( # Dropdown for drives
[(drive, drive) for drive in self.available_drives],
value=self.selected_drive,
id="drive_select",
Comment thread
sumana-2705 marked this conversation as resolved.
Outdated
Comment thread
sumana-2705 marked this conversation as resolved.
Outdated
),
CustomDirectoryTree(
self.mainwindow,
self.path_,
id="select_directory_tree_directory_tree",
id="select_directory_tree",
Comment thread
sumana-2705 marked this conversation as resolved.
Outdated
),
Button("Cancel", id="cancel_button"),
id="select_directory_tree_container",
)

@staticmethod
def get_drives():
"""Returns a list of available drives without using psutil."""
if platform.system() == "Windows":
drives = []
Comment thread
sumana-2705 marked this conversation as resolved.
Outdated
with os.popen("wmic logicaldisk get name") as f:
lines = f.readlines()[1:]
for line in lines:
drive = line.strip()
if drive:
drives.append(drive + "\\")
return drives
return ["/"] # Unix-based systems have a single root "/"
Comment thread
sumana-2705 marked this conversation as resolved.
Outdated

def on_drive_selected(self, event: Select.Changed) -> None:
Comment thread
sumana-2705 marked this conversation as resolved.
Outdated
"""Updates the directory tree when the drive is changed."""
self.selected_drive = event.value
Comment thread
sumana-2705 marked this conversation as resolved.
Outdated
self.path_ = Path(self.selected_drive)
self.refresh_directory_tree()

def refresh_directory_tree(self):
Comment thread
sumana-2705 marked this conversation as resolved.
Outdated
"""Rebuilds the directory tree UI."""
self.query_one("#select_directory_tree").remove()
self.mount(
CustomDirectoryTree(
self.mainwindow, str(self.path_), id="select_directory_tree"
)
)

@require_double_click
def on_directory_tree_directory_selected(self, node) -> None:
if node.path.is_file():
Expand Down