Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mscolab version history changed default to "All Changes" and is always uptodate #2585

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions mslib/msui/mscolab_version_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

import requests
from urllib.parse import urljoin, urlencode
from PyQt5 import QtCore, QtWidgets, QtGui

from mslib.utils.verify_user_token import verify_user_token
from mslib.msui.flighttrack import WaypointsTableModel
from PyQt5 import QtCore, QtWidgets, QtGui
from mslib.msui.qt5 import ui_mscolab_version_history as ui
from mslib.utils.qt import show_popup
from mslib.utils.config import config_loader
Expand Down Expand Up @@ -71,7 +71,7 @@ def __init__(self, token, op_id, user, operation_name, conn, parent=None,
self.mscolab_server_url = mscolab_server_url

# Event handlers
self.refreshBtn.clicked.connect(self.handle_refresh)
self.conn.signal_reload.connect(self.handle_refresh)
self.checkoutBtn.clicked.connect(self.handle_undo)
self.nameVersionBtn.clicked.connect(self.handle_named_version)
self.deleteVersionNameBtn.clicked.connect(self.handle_delete_version_name)
Expand Down Expand Up @@ -134,7 +134,7 @@ def load_all_changes(self):
"op_id": self.op_id
}
named_version_only = False
if self.versionFilterCB.currentIndex() == 0:
if self.versionFilterCB.currentIndex() == 1:
named_version_only = True
query_string = urlencode({"named_version": named_version_only})
url_path = f'get_all_changes?{query_string}'
Expand Down
15 changes: 6 additions & 9 deletions mslib/msui/qt5/ui_mscolab_version_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

# Form implementation generated from reading ui file 'ui_mscolab_version_history.ui'
#
# Created by: PyQt5 UI code generator 5.12.3
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING! All changes made in this file will be lost!
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
Expand Down Expand Up @@ -55,9 +56,6 @@ def setupUi(self, MscolabVersionHistory):
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.refreshBtn = QtWidgets.QPushButton(self.centralwidget)
self.refreshBtn.setObjectName("refreshBtn")
self.verticalLayout_2.addWidget(self.refreshBtn)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(self.centralwidget)
Expand Down Expand Up @@ -137,18 +135,17 @@ def setupUi(self, MscolabVersionHistory):
MscolabVersionHistory.addAction(self.actionCloseWindow)

self.retranslateUi(MscolabVersionHistory)
self.actionCloseWindow.triggered.connect(MscolabVersionHistory.close)
self.actionCloseWindow.triggered.connect(MscolabVersionHistory.close) # type: ignore
QtCore.QMetaObject.connectSlotsByName(MscolabVersionHistory)

def retranslateUi(self, MscolabVersionHistory):
_translate = QtCore.QCoreApplication.translate
MscolabVersionHistory.setWindowTitle(_translate("MscolabVersionHistory", "Version History"))
self.usernameLabel.setText(_translate("MscolabVersionHistory", "Logged In: "))
self.operationNameLabel.setText(_translate("MscolabVersionHistory", "Operation:"))
self.refreshBtn.setText(_translate("MscolabVersionHistory", "Refresh Window"))
self.label.setText(_translate("MscolabVersionHistory", "Viewing:"))
self.versionFilterCB.setItemText(0, _translate("MscolabVersionHistory", "Named Versions"))
self.versionFilterCB.setItemText(1, _translate("MscolabVersionHistory", "All Changes"))
self.versionFilterCB.setItemText(0, _translate("MscolabVersionHistory", "All Changes"))
self.versionFilterCB.setItemText(1, _translate("MscolabVersionHistory", "Named Versions"))
self.label_3.setText(_translate("MscolabVersionHistory", "Current Waypoints:"))
self.label_2.setText(_translate("MscolabVersionHistory", "Version Preview:"))
self.deleteVersionNameBtn.setToolTip(_translate("MscolabVersionHistory", "Delete the name of the selected version"))
Expand Down
11 changes: 2 additions & 9 deletions mslib/msui/ui/ui_mscolab_version_history.ui
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="refreshBtn">
<property name="text">
<string>Refresh Window</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
Expand All @@ -103,12 +96,12 @@
</property>
<item>
<property name="text">
<string>Named Versions</string>
<string>All Changes</string>
</property>
</item>
<item>
<property name="text">
<string>All Changes</string>
<string>Named Versions</string>
</property>
</item>
</widget>
Expand Down
20 changes: 6 additions & 14 deletions tests/_test_msui/test_mscolab_version_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,13 @@ def setup(self, qtbot, mscolab_server):
self.window.mscolab.conn.disconnect()

def test_changes(self, qtbot):
self._change_version_filter(1)
self._change_version_filter(0)
len_prev = self.version_window.changes.count()
# make a changes
self.window.mscolab.waypoints_model.invert_direction()
self.window.mscolab.waypoints_model.invert_direction()

def assert_():
self.version_window.load_all_changes()
len_after = self.version_window.changes.count()
assert len_prev == (len_after - 2)
qtbot.wait_until(assert_)
Expand All @@ -83,16 +82,18 @@ def test_set_version_name(self, qtbot):

def test_version_name_delete(self, qtbot):
self._set_version_name(qtbot)
self._activate_change_at_index(0)
QtTest.QTest.mouseClick(self.version_window.deleteVersionNameBtn, QtCore.Qt.LeftButton)

def assert_():
assert self.version_window.changes.count() == 1
assert self.version_window.changes.currentItem().version_name is None
self._activate_change_at_index(0)
assert str(self.version_window.changes.currentItem().version_name) == "None"
qtbot.wait_until(assert_)

@mock.patch("PyQt5.QtWidgets.QMessageBox.question", return_value=QtWidgets.QMessageBox.Yes)
def test_undo_changes(self, mockbox, qtbot):
self._change_version_filter(1)
self._change_version_filter(0)
assert self.version_window.changes.count() == 0
# make changes
for i in range(2):
Expand All @@ -108,15 +109,6 @@ def assert_():
new_changes_count = self.version_window.changes.count()
assert changes_count + 1 == new_changes_count

def test_refresh(self):
self._change_version_filter(1)
changes_count = self.version_window.changes.count()
self.window.mscolab.waypoints_model.invert_direction()
self.window.mscolab.waypoints_model.invert_direction()
QtTest.QTest.mouseClick(self.version_window.refreshBtn, QtCore.Qt.LeftButton)
new_changes_count = self.version_window.changes.count()
assert new_changes_count == changes_count + 2

def _connect_to_mscolab(self, qtbot):
self.connect_window = mscolab.MSColab_ConnectDialog(parent=self.window, mscolab=self.window.mscolab)
self.window.mscolab.connect_window = self.connect_window
Expand Down Expand Up @@ -158,7 +150,7 @@ def _change_version_filter(self, index):
self.version_window.versionFilterCB.currentIndexChanged.emit(index)

def _set_version_name(self, qtbot):
self._change_version_filter(1)
self._change_version_filter(0)
num_changes_before = self.version_window.changes.count()
# make a changes
self.window.mscolab.waypoints_model.invert_direction()
Expand Down
Loading