codeant-ai-for-open-source[bot] commented on code in PR #44982:
URL: https://github.com/apache/superset/pull/44982#discussion_r4182881893
##########
superset-frontend/src/dashboard/components/RefreshFrequency/RefreshFrequencySelect.tsx:
##########
@@ -50,28 +57,78 @@ const CustomContent = styled.div`
}
`;
-// Standard refresh frequency options used across modals
+// Standard refresh frequency options used when the deployment ships no
+// DASHBOARD_AUTO_REFRESH_INTERVALS value (embedded or partially bootstrapped
+// payloads). The `Custom` entry is a UI affordance, not an interval, so it is
+// kept out of the configured list.
export const REFRESH_FREQUENCY_OPTIONS = [
{ value: 0, label: t("Don't refresh") },
- { value: 10, label: t('10 seconds') },
- { value: 30, label: t('30 seconds') },
- { value: 60, label: t('1 minute') },
- { value: 300, label: t('5 minutes') },
- { value: 1800, label: t('30 minutes') },
- { value: 3600, label: t('1 hour') },
- { value: 21600, label: t('6 hours') },
- { value: 43200, label: t('12 hours') },
- { value: 86400, label: t('24 hours') },
- { value: -1, label: t('Custom') },
+ { value: 10, label: t("10 seconds") },
+ { value: 30, label: t("30 seconds") },
+ { value: 60, label: t("1 minute") },
+ { value: 300, label: t("5 minutes") },
+ { value: 1800, label: t("30 minutes") },
+ { value: 3600, label: t("1 hour") },
+ { value: 21600, label: t("6 hours") },
+ { value: 43200, label: t("12 hours") },
+ { value: 86400, label: t("24 hours") },
+ { value: CUSTOM_REFRESH_FREQUENCY, label: t("Custom") },
];
-const isPresetValue = (frequency: number) =>
- REFRESH_FREQUENCY_OPTIONS.some(
- option => option.value === frequency && option.value !== -1,
+const isPresetValue = (frequency: number, options: RefreshFrequencyOption[]) =>
+ options.some(
+ (option) =>
+ option.value === frequency && option.value !== CUSTOM_REFRESH_FREQUENCY,
);
-const getCustomValue = (frequency: number) =>
- !isPresetValue(frequency) && frequency > 0 ? frequency.toString() : '';
+/**
+ * Builds the interval list from DASHBOARD_AUTO_REFRESH_INTERVALS, which
reaches
+ * the browser as a list of `[seconds, label]` pairs. Labels stay verbatim: the
+ * deployment authored them, so translating them here would rewrite operator
+ * wording. Anything that is not a well-formed non-empty list falls back to the
+ * built-in options rather than rendering an empty selector.
+ */
+export const getRefreshFrequencyOptions = (
+ configuredIntervals?: unknown,
+): RefreshFrequencyOption[] => {
+ const options: RefreshFrequencyOption[] = [];
+
+ if (Array.isArray(configuredIntervals)) {
+ configuredIntervals.forEach((interval) => {
+ if (!Array.isArray(interval) || interval.length < 2) {
+ return;
+ }
+ const [value, label] = interval;
+ const seconds = Number(value);
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `2ea4d18`.
The parser now accepts only numeric values or non-empty strings before
converting them, so `null` and empty strings are rejected instead of becoming a
zero-second option.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]