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:
@@ -64,6 +64,22 @@ Select {
|
||||
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 */
|
||||
#backup-buttons,
|
||||
#restore-buttons,
|
||||
|
||||
@@ -6,7 +6,7 @@ from textual import work, on
|
||||
|
||||
from tui.config import list_conf_dir
|
||||
from tui.backend import run_cli, stream_cli
|
||||
from tui.widgets import ConfirmDialog, OperationLog
|
||||
from tui.widgets import ConfirmDialog, OperationLog, FolderPicker
|
||||
|
||||
|
||||
class RestoreScreen(Screen):
|
||||
@@ -32,7 +32,9 @@ class RestoreScreen(Screen):
|
||||
with RadioSet(id="restore-location"):
|
||||
yield RadioButton("In-place (original)", value=True)
|
||||
yield RadioButton("Custom directory")
|
||||
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"):
|
||||
yield Button("Restore", variant="primary", id="btn-restore")
|
||||
yield Button("Back", id="btn-back")
|
||||
@@ -67,9 +69,18 @@ class RestoreScreen(Screen):
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
if event.button.id == "btn-back":
|
||||
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":
|
||||
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:
|
||||
target_sel = self.query_one("#restore-target", Select)
|
||||
remote_sel = self.query_one("#restore-remote", Select)
|
||||
|
||||
Reference in New Issue
Block a user