Add Browse button for restore destination directory

Opens FolderPicker to select the destination path instead of
requiring manual typing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-06 01:48:47 +02:00
parent 8098cb90cf
commit 8149976170
2 changed files with 29 additions and 2 deletions

View File

@@ -64,6 +64,22 @@ Select {
margin: 0 0 1 0; margin: 0 0 1 0;
} }
/* Browse row */
#restore-dest-row {
height: auto;
margin: 0 0 1 0;
}
#restore-dest-row Input {
width: 1fr;
}
#restore-dest-row Button {
width: auto;
min-width: 12;
margin: 0 0 0 1;
}
/* Button rows */ /* Button rows */
#backup-buttons, #backup-buttons,
#restore-buttons, #restore-buttons,

View File

@@ -6,7 +6,7 @@ from textual import work, on
from tui.config import list_conf_dir from tui.config import list_conf_dir
from tui.backend import run_cli, stream_cli from tui.backend import run_cli, stream_cli
from tui.widgets import ConfirmDialog, OperationLog from tui.widgets import ConfirmDialog, OperationLog, FolderPicker
class RestoreScreen(Screen): class RestoreScreen(Screen):
@@ -32,7 +32,9 @@ class RestoreScreen(Screen):
with RadioSet(id="restore-location"): with RadioSet(id="restore-location"):
yield RadioButton("In-place (original)", value=True) yield RadioButton("In-place (original)", value=True)
yield RadioButton("Custom directory") yield RadioButton("Custom directory")
yield Input(placeholder="Destination directory (e.g. /tmp/restore)", id="restore-dest") with Horizontal(id="restore-dest-row"):
yield Input(placeholder="Destination directory (e.g. /tmp/restore)", id="restore-dest")
yield Button("Browse...", id="btn-browse-dest")
with Horizontal(id="restore-buttons"): with Horizontal(id="restore-buttons"):
yield Button("Restore", variant="primary", id="btn-restore") yield Button("Restore", variant="primary", id="btn-restore")
yield Button("Back", id="btn-back") yield Button("Back", id="btn-back")
@@ -67,9 +69,18 @@ class RestoreScreen(Screen):
def on_button_pressed(self, event: Button.Pressed) -> None: def on_button_pressed(self, event: Button.Pressed) -> None:
if event.button.id == "btn-back": if event.button.id == "btn-back":
self.app.pop_screen() self.app.pop_screen()
elif event.button.id == "btn-browse-dest":
self.app.push_screen(
FolderPicker("Select destination directory"),
callback=self._dest_selected,
)
elif event.button.id == "btn-restore": elif event.button.id == "btn-restore":
self._start_restore() self._start_restore()
def _dest_selected(self, path: str | None) -> None:
if path:
self.query_one("#restore-dest", Input).value = path
def _start_restore(self) -> None: def _start_restore(self) -> None:
target_sel = self.query_one("#restore-target", Select) target_sel = self.query_one("#restore-target", Select)
remote_sel = self.query_one("#restore-remote", Select) remote_sel = self.query_one("#restore-remote", Select)