From e686753af4377968858f27550b9175b4556ceab9 Mon Sep 17 00:00:00 2001 From: Piotr Czarnas Date: Tue, 30 Jan 2024 15:54:31 +0100 Subject: [PATCH] Rule and sensor screens loading fixes, when switching tabs. --- .../main/frontend/src/pages/RuleDetail/index.tsx | 14 ++++++++------ .../main/frontend/src/pages/SensorDetail/index.tsx | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/dqops/src/main/frontend/src/pages/RuleDetail/index.tsx b/dqops/src/main/frontend/src/pages/RuleDetail/index.tsx index 7b1b7db0cd..2ea5f4cb1d 100644 --- a/dqops/src/main/frontend/src/pages/RuleDetail/index.tsx +++ b/dqops/src/main/frontend/src/pages/RuleDetail/index.tsx @@ -53,7 +53,7 @@ export const RuleDetail = () => { const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); useEffect(() => { - if (!ruleDetail && (type !== 'create' || copied === true)) { + if (full_rule_name !== undefined && !ruleDetail && (type !== 'create' || copied === true)) { dispatch(getRule(urlencodeDecoder(String(full_rule_name)))); } }, [full_rule_name, ruleDetail, type]); @@ -62,11 +62,13 @@ export const RuleDetail = () => { if (type === 'create' && copied !== true) { setRuleName(''); } else { - setRuleName( - String(full_rule_name).split('/')[ - String(full_rule_name).split('/').length - 1 - ] + '_copy' - ); + if (full_rule_name !== undefined) { + setRuleName( + String(full_rule_name).split('/')[ + String(full_rule_name).split('/').length - 1 + ] + '_copy' + ); + } } }, [type, copied]); diff --git a/dqops/src/main/frontend/src/pages/SensorDetail/index.tsx b/dqops/src/main/frontend/src/pages/SensorDetail/index.tsx index 41ff9a7259..d2fc3a6411 100644 --- a/dqops/src/main/frontend/src/pages/SensorDetail/index.tsx +++ b/dqops/src/main/frontend/src/pages/SensorDetail/index.tsx @@ -97,7 +97,7 @@ export const SensorDetail = () => { ); useEffect(() => { - if (!sensorDetail && (type !== 'create' || copied === true)) { + if (full_sensor_name !== undefined && !sensorDetail && (type !== 'create' || copied === true)) { dispatch(getSensor(full_sensor_name)); } }, [full_sensor_name, sensorDetail, type]); @@ -105,11 +105,13 @@ export const SensorDetail = () => { if (type === 'create' && copied !== true) { setSensorName(''); } else { - setSensorName( - String(full_sensor_name).split('/')[ - String(full_sensor_name).split('/').length - 1 - ] + '_copy' - ); + if (full_sensor_name !== undefined) { + setSensorName( + String(full_sensor_name).split('/')[ + String(full_sensor_name).split('/').length - 1 + ] + '_copy' + ); + } } }, [type, copied]);