Skip to content

Commit

Permalink
elyra-ai#2028 default_value condition not run when setting property v…
Browse files Browse the repository at this point in the history
…alues (elyra-ai#2029)

Signed-off-by: Carita Ou <[email protected]>
  • Loading branch information
caritaou authored Jun 20, 2024
1 parent 3f43a0f commit 830bfe3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,14 @@ describe("Properties Controller handlers", () => {
expect(propertyListener.calledWith({
action: "SET_PROPERTIES"
})).to.be.true;

// Verify default_value condition is run when calling setPropertyValues() with setDefaultValues === true
expect(controller.getPropertyValues()).to.have.property("checkbox_null", null);
controller.setPropertyValues({
"checkbox_error": true,
"checkbox_warning": true
}, { setDefaultValues: true });
expect(controller.getPropertyValues()).to.have.property("checkbox_null", true);
});
it("should set default values having 0 or ' ' when setPropertyValues() is called with option { setDefaultValues: true }", () => {
const renderedObject = testUtils.flyoutEditorForm(oneofselectParamDef);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,30 @@
]
},
"conditions": [
{
"default_value": {
"parameter_ref": "checkbox_null",
"value": true,
"evaluate": {
"and": [
{
"condition": {
"parameter_ref": "checkbox_error",
"op": "equals",
"value": true
}
},
{
"condition": {
"parameter_ref": "checkbox_warning",
"op": "equals",
"value": true
}
}
]
}
}
},
{
"validation": {
"fail_message": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ export default class PropertiesController {

this.propertiesStore.setPropertyValues(inValues);

if (options && options.isInitProps) {
if (options?.isInitProps || options?.setDefaultValues) {
// Evaluate conditional defaults based on current_parameters upon loading of view
// For a given parameter_ref, if multiple conditions evaluate to true only the first one is used.
const conditionalDefaultValues = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,30 @@
]
},
"conditions": [
{
"default_value": {
"parameter_ref": "checkbox_null",
"value": true,
"evaluate": {
"and": [
{
"condition": {
"parameter_ref": "checkbox_error",
"op": "equals",
"value": true
}
},
{
"condition": {
"parameter_ref": "checkbox_warning",
"op": "equals",
"value": true
}
}
]
}
}
},
{
"validation": {
"fail_message": {
Expand Down

0 comments on commit 830bfe3

Please sign in to comment.