codeant-ai-for-open-source[bot] commented on code in PR #44982:
URL: https://github.com/apache/superset/pull/44982#discussion_r4182622850
##########
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:
**Suggestion:** <code>Number(value)</code> turns <code>null</code> and an
empty string into zero, so malformed configuration appears as a no-refresh
option and selecting it disables refresh.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Type error`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=41f1138e27004c1abeda9f4ca4f9e555&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=41f1138e27004c1abeda9f4ca4f9e555&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/src/dashboard/components/RefreshFrequency/RefreshFrequencySelect.tsx
**Line:** 102:102
**Comment:**
*Type Error: <code>Number(value)</code> turns <code>null</code> and an
empty string into zero, so malformed configuration appears as a no-refresh
option and selecting it disables refresh.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44982&comment_hash=0e86d275952d2044e419d110ff9cdd7504bb7a0105f3d5ad795030f6d8bcc779&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44982&comment_hash=0e86d275952d2044e419d110ff9cdd7504bb7a0105f3d5ad795030f6d8bcc779&reaction=dislike'>๐</a>
--
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]