Skip to content
Merged
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
83 changes: 63 additions & 20 deletions oqtopus/gui/module_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,24 +268,18 @@ 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(
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?"
),
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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)

Expand Down
40 changes: 27 additions & 13 deletions oqtopus/ui/module_widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<item row="1" column="0">
<widget class="QProgressBar" name="moduleInfo_progressbar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QPushButton" name="moduleInfo_cancel_button">
<property name="text">
<string>Cancel</string>
Expand Down Expand Up @@ -78,6 +78,13 @@
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QCheckBox" name="beta_testing_checkbox_pageInstall">
<property name="text">
<string>Beta testing</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="db_parameters_CreateAndGrantRoles_install_checkBox">
<property name="text">
Expand Down Expand Up @@ -135,7 +142,7 @@
<x>0</x>
<y>0</y>
<width>416</width>
<height>72</height>
<height>51</height>
</rect>
</property>
</widget>
Expand Down Expand Up @@ -185,21 +192,31 @@
</property>
<item row="5" column="0" colspan="4">
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="2">
<item row="2" column="2">
<widget class="QPushButton" name="uninstall_button">
<property name="text">
<string>Uninstall</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="db_parameters_CreateAndGrantRoles_upgrade_checkBox">
<property name="text">
<string>Create and grant roles</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="moduleInfo_upgrade_pushButton">
<property name="text">
<string>Upgrade</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -213,12 +230,9 @@
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="db_parameters_CreateAndGrantRoles_upgrade_checkBox">
<widget class="QCheckBox" name="beta_testing_checkbox_pageUpgrade">
<property name="text">
<string>Create and grant roles</string>
</property>
<property name="checked">
<bool>true</bool>
<string>Beta testing</string>
</property>
</widget>
</item>
Expand All @@ -227,7 +241,7 @@
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="moduleInfo_installation_label_upgrade">
<property name="text">
<string>No installation found</string>
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand Down Expand Up @@ -318,7 +332,7 @@
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="moduleInfo_installation_label_maintain">
<property name="text">
<string>No installation found</string>
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand Down