Skip to content

Commit

Permalink
Merge pull request #113 from hsorby/main
Browse files Browse the repository at this point in the history
Adjust determination of when a workflow settings can be imported.
  • Loading branch information
hsorby authored Mar 27, 2024
2 parents 06eb9c0 + aa4871f commit 1ed4c14
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
26 changes: 10 additions & 16 deletions src/mapclient/view/workflow/importconfigdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ def __init__(self, import_source, graphics_scene, parent=None):
self._undo_stack = self._graphics_scene.getUndoStack()

self._step_map = None
if self._check_compatibility():
self._setup_step_map()
self._setup_grid_layout()
else:
self._ui.pushButtonImport.setEnabled(False)
self._setup_step_map()
self._setup_grid_layout()

self._make_connections()

Expand Down Expand Up @@ -93,14 +90,14 @@ def _create_step_map(self, node_count, import_steps, workflow_steps):
# If the lists of step names match, assign a one-to-one mapping of step indices.
self._step_map["Selected"] = import_steps["ID"]

def _check_compatibility(self):
def is_compatible(self):
import_proj = self._import_settings()
# Check for version compatibility.
import_version = version.parse(import_proj.value('version'))
application_version = version.parse(VERSION_STRING)
if not _compatible_versions(import_version, application_version):
QtWidgets.QMessageBox.warning(self, 'Different Workflow Versions', f'The version of the imported workflow ({import_version})'
f' is not compatible with this version of the MAP Client ({application_version}).')
f' is not compatible with this version of the MAP Client ({application_version}).')
return False

return True
Expand Down Expand Up @@ -183,15 +180,12 @@ def _import_clicked(self):
"The selected configurations have been successfully imported.")


def _matches_major_minor_version(test_version, target_version):
return test_version.major == target_version.major and test_version.minor == target_version.minor


def _compatible_versions(import_settings_version, application_version):
if _matches_major_minor_version(import_settings_version, version.Version("0.20.0")) and import_settings_version <= application_version:
return True
if import_settings_version < version.Version("0.19.0"):
return False

if _matches_major_minor_version(import_settings_version, version.Version("0.19.0")) and import_settings_version <= application_version:
return True
significant_import_settings_version = version.Version(f"{import_settings_version.major}.{import_settings_version.minor}")
if significant_import_settings_version > application_version:
return False

return False
return True
5 changes: 3 additions & 2 deletions src/mapclient/view/workflow/workflowwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,9 @@ def import_cfg(self):

if len(import_source) > 0:
dlg = ImportConfigDialog(import_source, self._graphicsScene, self)
dlg.setModal(True)
dlg.exec_()
if dlg.is_compatible():
dlg.setModal(True)
dlg.exec()

def export_cfg(self):
self.save()
Expand Down

0 comments on commit 1ed4c14

Please sign in to comment.