diff --git a/dqops/src/main/frontend/src/components/Connection/TableView/TableComparison/EditProfilingReferenceTable.tsx b/dqops/src/main/frontend/src/components/Connection/TableView/TableComparison/EditProfilingReferenceTable.tsx index c1778fb26d..c3f7929aca 100644 --- a/dqops/src/main/frontend/src/components/Connection/TableView/TableComparison/EditProfilingReferenceTable.tsx +++ b/dqops/src/main/frontend/src/components/Connection/TableView/TableComparison/EditProfilingReferenceTable.tsx @@ -86,67 +86,6 @@ export const EditProfilingReferenceTable = ({ ...obj })); }; - const checkIfRowAndColumnCountClicked = () => { - let values: string | any[] = []; - if (!checksUI) { - return; - } - values = Object.values(checksUI); - - if (values.length === 0 || !Array.isArray(values[0])) { - return; - } - const comparisonCategory = values[0].find( - (x) => x && x.category === `comparisons/${selectedReference}` - ); - if (!comparisonCategory || !comparisonCategory.checks) { - return; - } - - const rowCountElem = comparisonCategory.checks.find((c: any) => - c.check_name.includes('row_count_match') - ); - - const columnCountElem = comparisonCategory.checks.find((c: any) => - c.check_name.includes('column_count_match') - ); - - if (rowCountElem) { - setShowRowCount(!!rowCountElem.configured); - } - if (columnCountElem) { - setShowColumnCount(!!columnCountElem.configured); - } - if (rowCountElem?.configured === true) { - onChange({ - compare_row_count: { - warning_difference_percent: - rowCountElem.rule.warning.rule_parameters[0].double_value, - error_difference_percent: - rowCountElem.rule.error.rule_parameters[0].double_value, - fatal_difference_percent: - rowCountElem.rule.fatal.rule_parameters[0].double_value - } - }); - } else { - onChange({ compare_row_count: reference?.default_compare_thresholds }); - } - if (columnCountElem?.configured === true) { - onChange({ - compare_column_count: { - warning_difference_percent: - columnCountElem.rule.warning.rule_parameters[0].double_value, - error_difference_percent: - columnCountElem.rule.error.rule_parameters[0].double_value, - fatal_difference_percent: - columnCountElem.rule.fatal.rule_parameters[0].double_value - } - }); - } else { - onChange({ compare_column_count: reference?.default_compare_thresholds }); - } - //cCompareThreshholdsModel in java fatal returns null - }; const handleChange = async (value: CheckContainerModel) => { return new Promise((resolve) => { @@ -268,10 +207,77 @@ export const EditProfilingReferenceTable = ({ ).then(callback); } } - checkIfRowAndColumnCountClicked(); } }, [selectedReference]); + useEffect(() => { + const checkIfRowAndColumnCountClicked = () => { + let values: string | any[] = []; + if (!checksUI) { + return; + } + values = Object.values(checksUI); + + if (values.length === 0 || !Array.isArray(values[0])) { + return; + } + const comparisonCategory = values[0].find( + (x) => x && x.category === `comparisons/${selectedReference}` + ); + if (!comparisonCategory || !comparisonCategory.checks) { + return; + } + + const rowCountElem = comparisonCategory.checks.find((c: any) => + c.check_name.includes('row_count_match') + ); + + const columnCountElem = comparisonCategory.checks.find((c: any) => + c.check_name.includes('column_count_match') + ); + + if (rowCountElem) { + setShowRowCount(!!rowCountElem.configured); + } + if (columnCountElem) { + setShowColumnCount(!!columnCountElem.configured); + } + if (rowCountElem?.configured === true) { + onChange({ + compare_row_count: { + warning_difference_percent: + rowCountElem.rule.warning.rule_parameters[0].double_value, + error_difference_percent: + rowCountElem.rule.error.rule_parameters[0].double_value, + fatal_difference_percent: + rowCountElem.rule.fatal.rule_parameters[0].double_value + } + }); + } else { + onChange({ compare_row_count: reference?.default_compare_thresholds }); + } + if (columnCountElem?.configured === true) { + onChange({ + compare_column_count: { + warning_difference_percent: + columnCountElem.rule.warning.rule_parameters[0].double_value, + error_difference_percent: + columnCountElem.rule.error.rule_parameters[0].double_value, + fatal_difference_percent: + columnCountElem.rule.fatal.rule_parameters[0].double_value + } + }); + } else { + onChange({ + compare_column_count: reference?.default_compare_thresholds + }); + } + //cCompareThreshholdsModel in java fatal returns null + }; + + checkIfRowAndColumnCountClicked(); + }, [selectedReference, checksUI]); + const onChange = (obj: Partial): void => { setReference({ ...(reference || {}), @@ -609,7 +615,9 @@ export const EditProfilingReferenceTable = ({ checksUI={checksUI} type="row" /> - ) :
} + ) : ( +
+ )} {rowKey ? ( - ) :
} + ) : ( +
+ )} {columnKey ? (