Skip to content

Commit

Permalink
Prevent borg operation while renaming. By @bigtedde (#1791)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigtedde authored Sep 11, 2023
1 parent 7d2b363 commit 4350f78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/vorta/views/archive_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,9 @@ def extract_archive_result(self, result):
self._toggle_all_buttons(True)

def cell_double_clicked(self, row=None, column=None):
if not self.bRename.isEnabled():
return

if not row or not column:
row = self.archiveTable.currentRow()
column = self.archiveTable.currentColumn()
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/test_archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ def test_refresh_archive_info(qapp, qtbot, mocker, borg_json_output, archive_env
qtbot.waitUntil(lambda: tab.mountErrors.text() == 'Refreshed archives.', **pytest._wait_defaults)


def test_archive_rename(qapp, qtbot, mocker, borg_json_output, archive_env):
def test_inline_archive_rename(qapp, qtbot, mocker, borg_json_output, archive_env):
"""
Tests the functionality of in-line renaming an archive by double-clicking its name.
"""
main, tab = archive_env

tab.archiveTable.selectRow(0)
Expand All @@ -190,9 +193,12 @@ def test_archive_rename(qapp, qtbot, mocker, borg_json_output, archive_env):

pos = tab.archiveTable.visualRect(tab.archiveTable.model().index(0, 4)).center()
qtbot.mouseClick(tab.archiveTable.viewport(), QtCore.Qt.MouseButton.LeftButton, pos=pos)
assert tab.bRename.isEnabled()
qtbot.mouseDClick(tab.archiveTable.viewport(), QtCore.Qt.MouseButton.LeftButton, pos=pos)
tab.archiveTable.viewport().focusWidget().setText("")
qtbot.keyClicks(tab.archiveTable.viewport().focusWidget(), new_archive_name)
qtbot.keyClick(tab.archiveTable.viewport().focusWidget(), QtCore.Qt.Key.Key_Return)

# Successful rename case
qtbot.waitUntil(lambda: tab.archiveTable.model().index(0, 4).data() == new_archive_name, **pytest._wait_defaults)
assert tab.archiveTable.model().index(0, 4).data() == new_archive_name

0 comments on commit 4350f78

Please sign in to comment.