diff --git a/oqtopus/gui/module_widget.py b/oqtopus/gui/module_widget.py index 5792dc3..bc8a1ca 100644 --- a/oqtopus/gui/module_widget.py +++ b/oqtopus/gui/module_widget.py @@ -268,16 +268,9 @@ def __installModuleClicked(self): try: parameters = self.parameters_groupbox.parameters_values() - beta_testing = False - if ( - self.__current_module_package.type == ModulePackage.Type.PULL_REQUEST - or self.__current_module_package.type == ModulePackage.Type.BRANCH - or self.__current_module_package.prerelease - ): - logger.warning( - "Installing module from branch, pull request, or prerelease: set parameter beta_testing to True" - ) - beta_testing = True + beta_testing = self.beta_testing_checkbox_pageInstall.isChecked() + if beta_testing: + logger.warning("Installing module with beta_testing enabled") # Warn user before installing in beta testing mode reply = QMessageBox.warning( @@ -285,7 +278,8 @@ def __installModuleClicked(self): self.tr("Beta Testing Installation"), self.tr( "You are about to install this module in BETA TESTING mode.\n\n" - "This means the module will not be allowed to receive future updates through normal upgrade process.\n" + "This means the module will not be allowed to receive future updates " + "through normal upgrade process.\n" "We strongly discourage using this for production databases.\n\n" "Are you sure you want to continue?" ), @@ -391,16 +385,26 @@ def __upgradeModuleClicked(self): try: parameters = self.parameters_groupbox.parameters_values() - beta_testing = False - if ( - self.__current_module_package.type == ModulePackage.Type.PULL_REQUEST - or self.__current_module_package.type == ModulePackage.Type.BRANCH - or self.__current_module_package.prerelease - ): - logger.warning( - "Upgrading module from branch, pull request, or prerelease: set parameter beta_testing to True" + beta_testing = self.beta_testing_checkbox_pageUpgrade.isChecked() + if beta_testing: + logger.warning("Upgrading module with beta_testing enabled") + + # Warn user before upgrading in beta testing mode + reply = QMessageBox.warning( + self, + self.tr("Beta Testing Upgrade"), + self.tr( + "You are about to upgrade this module in BETA TESTING mode.\n\n" + "This means the module will not be allowed to receive future updates " + "through normal upgrade process.\n" + "We strongly discourage using this for production databases.\n\n" + "Are you sure you want to continue?" + ), + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, + QMessageBox.StandardButton.No, ) - beta_testing = True + if reply != QMessageBox.StandardButton.Yes: + return # Start background upgrade operation options = { @@ -645,6 +649,10 @@ def __show_install_page(self, version: str): ) QtUtils.resetForegroundColor(self.moduleInfo_installation_label_install) self.moduleInfo_install_pushButton.setText(self.tr(f"Install {version}")) + + # Configure beta testing checkbox based on package source + self.__configure_beta_testing_checkbox(self.beta_testing_checkbox_pageInstall) + self.moduleInfo_stackedWidget.setCurrentWidget(self.moduleInfo_stackedWidget_pageInstall) # Ensure the stacked widget is visible when showing a valid page self.moduleInfo_stackedWidget.setVisible(True) @@ -667,6 +675,37 @@ def __set_installation_label(self, label, install_text: str, beta_testing: bool else: QtUtils.resetForegroundColor(label) + def __configure_beta_testing_checkbox(self, checkbox): + """Configure a beta testing checkbox based on the current module package source. + + - Release: disabled and unchecked + - Dev branch or PR: disabled and checked + - Zip file: enabled and checked by default + """ + tooltip = self.tr( + "If checked, the module is installed in beta testing mode.\n" + "This means that the module will not be allowed to receive\n" + "any future updates. We strongly discourage using this\n" + "for production." + ) + checkbox.setToolTip(tooltip) + + pkg = self.__current_module_package + if pkg.type == ModulePackage.Type.FROM_ZIP: + checkbox.setEnabled(True) + checkbox.setChecked(True) + elif ( + pkg.type == ModulePackage.Type.BRANCH + or pkg.type == ModulePackage.Type.PULL_REQUEST + or pkg.prerelease + ): + checkbox.setEnabled(False) + checkbox.setChecked(True) + else: + # Release + checkbox.setEnabled(False) + checkbox.setChecked(False) + def __show_upgrade_page( self, module_name: str, @@ -684,6 +723,10 @@ def __show_upgrade_page( ) QtUtils.resetForegroundColor(self.moduleInfo_selected_label) self.moduleInfo_upgrade_pushButton.setText(self.tr(f"Upgrade to {target_version}")) + + # Configure beta testing checkbox based on package source + self.__configure_beta_testing_checkbox(self.beta_testing_checkbox_pageUpgrade) + self.moduleInfo_stackedWidget.setCurrentWidget(self.moduleInfo_stackedWidget_pageUpgrade) self.moduleInfo_stackedWidget.setVisible(True) diff --git a/oqtopus/ui/module_widget.ui b/oqtopus/ui/module_widget.ui index cf130a7..04f62fb 100644 --- a/oqtopus/ui/module_widget.ui +++ b/oqtopus/ui/module_widget.ui @@ -14,14 +14,14 @@ Form - + 24 - + Cancel @@ -78,6 +78,13 @@ 3 + + + + Beta testing + + + @@ -135,7 +142,7 @@ 0 0 416 - 72 + 51 @@ -185,21 +192,31 @@ - + Uninstall - + + + + Create and grant roles + + + true + + + + Upgrade - + Qt::Horizontal @@ -213,12 +230,9 @@ - + - Create and grant roles - - - true + Beta testing @@ -227,7 +241,7 @@ - No installation found + true @@ -318,7 +332,7 @@ - No installation found + true