From 87a7585d7820b2e5305aa22aa8775ad82aedd4f1 Mon Sep 17 00:00:00 2001 From: c8y3 <25362953+c8y3@users.noreply.github.com> Date: Fri, 9 Jun 2023 10:05:53 +0200 Subject: [PATCH] Factored code to display [not set] --- src/web/components/LoggingAlertConfig.jsx | 28 ++++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/web/components/LoggingAlertConfig.jsx b/src/web/components/LoggingAlertConfig.jsx index 60f3b93..727a2ec 100755 --- a/src/web/components/LoggingAlertConfig.jsx +++ b/src/web/components/LoggingAlertConfig.jsx @@ -66,7 +66,13 @@ const _formatOption = (key, value) => { return { value: value, label: key }; }; -// TODO factor all [not set] with a function displayConfigurationValue() +const _displayOptionalConfigurationValue = (value) => { + if (!value) { + return '[not set]'; + } + return value; +}; + const LoggingAlertConfig = ({ config = DEFAULT_CONFIG, updateConfig }) => { const [nextConfiguration, setNextConfiguration] = useState(config); const { streams: streamList = [] } = useStore(StreamsStore); @@ -75,11 +81,11 @@ const LoggingAlertConfig = ({ config = DEFAULT_CONFIG, updateConfig }) => { const configurationModal = useRef(); const _openModal = () => { - configurationModal.current.open() + configurationModal.current.open(); }; const _closeModal = () => { - configurationModal.current.close() + configurationModal.current.close(); }; /* TODO is this necessary? @@ -145,49 +151,49 @@ const LoggingAlertConfig = ({ config = DEFAULT_CONFIG, updateConfig }) => {
Log Content:
- {config.log_body ? config.log_body : '[not set]'} + {_displayOptionalConfigurationValue(config.log_body)}
Line Break Substitution:
- {config.separator ? config.separator : '[not set]'} + {_displayOptionalConfigurationValue(config.separator)}
Aggregation Time Range:
- {config.aggregation_time ? config.aggregation_time : '[not set]'} + {_displayOptionalConfigurationValue(config.aggregation_time)}
Alerts Stream:
- {config.aggregation_stream ? config.aggregation_stream : '[not set]'} + {_displayOptionalConfigurationValue(config.aggregation_stream)}
Alert ID Field:
- {config.field_alert_id ? config.field_alert_id : '[not set]'} + {_displayOptionalConfigurationValue(config.field_alert_id)}
Overflow Limit:
- {config.limit_overflow ? config.limit_overflow : '[not set]'} + {_displayOptionalConfigurationValue(config.limit_overflow)}
Alert Tag:
- {config.alert_tag ? config.alert_tag : '[not set]'} + {_displayOptionalConfigurationValue(config.alert_tag)}
Overflow Tag:
- {config.overflow_tag ? config.overflow_tag : '[not set]'} + {_displayOptionalConfigurationValue(config.overflow_tag)}