This is an automated email from the ASF dual-hosted git repository.
mtien pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/support/nifi-1.x by this push:
new 70bb41ec95 NIFI-11593: Fix hiding logic for properties (#7339)
70bb41ec95 is described below
commit 70bb41ec95ef44561bc8a1ed570a080ce7a5354d
Author: Shane Ardell <[email protected]>
AuthorDate: Mon Jun 5 16:36:49 2023 -0400
NIFI-11593: Fix hiding logic for properties (#7339)
* NIFI-11593: fix hiding logic for properties with references or without
dependent values
* NIFI-11593: remove arrow functions
Merged #7339 into main.
---
.../jquery/propertytable/jquery.propertytable.js | 45 ++++++++++++++--------
1 file changed, 29 insertions(+), 16 deletions(-)
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
index 0929daee79..f954e17aa8 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/jquery/propertytable/jquery.propertytable.js
@@ -1722,20 +1722,25 @@
// Get the current property
value to compare with the dependent value
var propertyValue =
property.value;
- var referencingParameter =
null;
-
// check if the property
references a parameter
if
(!_.isEmpty(currentParameters)) {
const paramReference =
getExistingParametersReferenced(propertyValue);
+ // if parameter references
exist, loop through all and interpolate the value in the propertyValue string
if (paramReference.length
> 0) {
- referencingParameter =
paramReference[0].value;
+
paramReference.forEach(function (param) {
+ // handle null
values by replacing with an empty string instead
+ propertyValue =
propertyValue.replace('#{' + param.name + '}',
nfCommon.isDefinedAndNotNull(param.value) ? param.value : '');
+ });
}
}
// Test the dependentValues
array against the current value of the property
- // If not, then mark the
current property hidden attribute is true
- if (propertyValue != null &&
dependency.hasOwnProperty("dependentValues")) {
- hidden =
!dependency.dependentValues.includes(referencingParameter || propertyValue);
+ if (propertyValue) {
+ if
(dependency.dependentValues) {
+ hidden =
!dependency.dependentValues.includes(propertyValue);
+ } else {
+ hidden = false;
+ }
} else {
hidden = true;
}
@@ -1748,7 +1753,7 @@
return false;
}
}
- })
+ });
});
}
} else {
@@ -1955,22 +1960,28 @@
if (property.property === dependency.propertyName)
{
dependent = true;
if (property.hidden === false) {
- // Get the property value by propertyName
- var propertyValue =
properties[dependency.propertyName];
- var referencingParameter = null;
+ // Get the current property value to
compare with the dependent value
+ var propertyValue = property.value;
// check if the property references a
parameter
if (!_.isEmpty(currentParameters)) {
const paramReference =
getExistingParametersReferenced(propertyValue);
+ // if parameter references exist, loop
through all and interpolate the value in the propertyValue string
if (paramReference.length > 0) {
- referencingParameter =
paramReference[0].value;
+ paramReference.forEach(function
(param) {
+ // handle null values by
replacing with an empty string instead
+ propertyValue =
propertyValue.replace('#{' + param.name + '}',
nfCommon.isDefinedAndNotNull(param.value) ? param.value : '');
+ });
}
}
- // Test the dependentValues against the
current value of the property
- // If not, then mark the current property
hidden attribute is true
- if (propertyValue != null &&
dependency.hasOwnProperty("dependentValues")) {
- hidden =
!dependency.dependentValues.includes(referencingParameter || propertyValue);
+ // Test the dependentValues array against
the current value of the property
+ if (propertyValue) {
+ if (dependency.dependentValues) {
+ hidden =
!dependency.dependentValues.includes(propertyValue);
+ } else {
+ hidden = false;
+ }
} else {
hidden = true;
}
@@ -1978,10 +1989,12 @@
hidden = true;
}
if (hidden) {
+ // It is sufficient to have found a single
instance of not meeting the
+ // requirement for a dependent value in
order to hide a property
return false;
}
}
- })
+ });
});
}