Skip to content

Commit

Permalink
fix: when user removed, then re-added a check, it would use the check…
Browse files Browse the repository at this point in the history
…s default parameters and not the default parameters from the selected standard
  • Loading branch information
lachlanhurst committed Jun 19, 2024
1 parent f7b6589 commit 959d269
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion hyo2/qax/app/widgets/qax/plugin_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_check_ids_and_params(self):
for check_widget in self.check_widgets]
return check_ids_and_params

def set_selected_checks(self, checks: list[QaxCheckReference]):
def set_selected_checks(self, checks: list[QaxCheckReference], standard: QaxConfigSpecification|None = None):

# cache info users may have entered into the plugin params
# just because they've removed a check doesn't mean we should
Expand Down Expand Up @@ -117,6 +117,14 @@ def set_selected_checks(self, checks: list[QaxCheckReference]):
for cw in self.check_widgets:
if cw.check_reference.id in user_input_cache:
cw.set_params_and_values(user_input_cache[cw.check_reference.id])
elif standard is not None:
# then get values from the currently selected standard
check = standard.get_config_check(cw.check_reference.id)
if check is not None:
standard_p_and_v: dict[str, Any] = {}
for p in check.parameters:
standard_p_and_v[p.name] = p.value
cw.set_params_and_values(standard_p_and_v)

self.layout_checks.addStretch(1)

Expand Down
4 changes: 2 additions & 2 deletions hyo2/qax/app/widgets/qax/plugins_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def set_specification(self, specification: QaxConfigSpecification):
for plugin_tab in self.plugin_tabs:
plugin_tab.set_specification(specification)

def set_selected_checks(self, checks: list[QaxCheckReference]):
def set_selected_checks(self, checks: list[QaxCheckReference], standard: QaxConfigSpecification|None = None):
for plugin_tab in self.plugin_tabs:
plugin_tab.set_selected_checks(checks)
plugin_tab.set_selected_checks(checks, standard)

def update_plugin_tabs(self):
""" Updates what plugins are shown in the bottom tabs
Expand Down
2 changes: 1 addition & 1 deletion hyo2/qax/app/widgets/qax/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _on_update_check_inputs(self):
self.prj.qa_json = qa_json

def _on_check_selection_change(self, checks: list[QaxCheckReference]):
self.tab_plugins.set_selected_checks(checks)
self.tab_plugins.set_selected_checks(checks, self.tab_inputs.profile_selection.selected_specification)
qa_json = self._build_qa_json()
self.prj.qa_json = qa_json

Expand Down

0 comments on commit 959d269

Please sign in to comment.