Visitar URL original
fix(dashboard): respect DASHBOARD_AUTO_REFRESH_INTERVALS configuration in refresh dropdown by FrancescoCastaldi · Pull Request #45039 · apache/superset · GitHub
Skip to content

fix(dashboard): respect DASHBOARD_AUTO_REFRESH_INTERVALS configuration in refresh dropdown - #45039

Merged
rusackas merged 1 commit into
apache:masterfrom
FrancescoCastaldi:fix/issue-44981-dashboard-auto-refresh-intervals
Oct 20, 2026
Merged

rusackas merged 1 commit into
apache:masterfrom
FrancescoCastaldi:fix/issue-44981-dashboard-auto-refresh-intervals

Conversation

@FrancescoCastaldi

Copy link
Copy Markdown
Contributor

SUMMARY

Fixes #44981.

The dashboard auto-refresh frequency dropdown rendered hardcoded preset options and ignored the DASHBOARD_AUTO_REFRESH_INTERVALS configuration defined in Superset configuration (common.conf).

This change:

  1. Connects RefreshFrequencySelect.tsx to the Redux store selector (state.dashboardInfo.common.conf.DASHBOARD_AUTO_REFRESH_INTERVALS).
  2. Generates options dynamically from the configuration when present, while retaining transparent fallback to default intervals when unconfigured.
  3. Memoizes options and properly handles custom interval inputs and radio selection states.

TESTING INSTRUCTIONS

Run the Jest unit tests:
npm test -- RefreshFrequencySelect.test.tsx

All tests pass, confirming options rendering from custom store configurations and fallback behavior.

ADDITIONAL INFORMATION

@netlify

netlify Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 44f8e86
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6acd551d3b65a8a8af187c21
😎 Deploy Preview https://deploy-preview-45039--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; selecting a preset preserves the custom interval draft when switching back to Custom.
  • The added tests cover option overrides and clamping custom values below the minimum interval.

Assessed commit: 44f8e861a5b2

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.98%. Comparing base (ea06872) to head (44f8e86).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #45039      +/-   ##
==========================================
- Coverage   82.98%   82.98%   -0.01%     
==========================================
  Files        3026     3026              
  Lines      195842   195846       +4     
  Branches    45719    45723       +4     
==========================================
+ Hits       162520   162522       +2     
- Misses      30111    30113       +2     
  Partials     3211     3211              
Flag Coverage Δ
javascript 78.71% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sadpandajoe
sadpandajoe requested review from richardfogaca and sadpandajoe and a balanced review from Copilot October 7, 2026 18:13
@sadpandajoe

Copy link
Copy Markdown
Member

This duplicates #44982

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Configuration lookup misses list/home editors, and a configured 1-second preset interrupts Custom selection.

2 open findings
What changed in this PR

Restores configuration-driven dashboard refresh options to address #44981.

Changes:

  • Reads configured intervals from Redux, with default fallback and optional prop overrides.
  • Updates preset detection and custom-value synchronization.
  • Adds tests for configured options, fallback behavior, and user interactions.
File Description
superset-frontend/​src/​dashboard/​components/​RefreshFrequency/​RefreshFrequencySelect.tsx Adds configurable options and selection handling.
superset-frontend/​src/​dashboard/​components/​RefreshFrequency/​RefreshFrequencySelect.test.tsx Tests configuration, defaults, and custom input.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +150 to +151
(state: RootState) =>
state.dashboardInfo?.common?.conf?.DASHBOARD_AUTO_REFRESH_INTERVALS,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed—state.common.conf is the store slice populated from bootstrap data on the dashboard list and home pages, while dashboardInfo.common is only filled by dashboard hydration, so the Properties modal on those pages still shows the hardcoded presets. Could the selector read state.common.conf first and fall back to dashboardInfo.common.conf?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed and rebased onto master in commit 44f8e861a5 @sadpandajoe. The selector reads DASHBOARD_AUTO_REFRESH_INTERVALS from both state.dashboardInfo.common.conf and the bootstrapped top-level state.common.conf slice, with regression coverage for the list/home page store shape.

Comment on lines +194 to +196
const selection = isPreset(value) ? value : -1;
setRadioSelection(selection);
setCustomValue(selection === -1 ? getCustomValue(value) : '');
}, [value]);
setCustomValue(selection === -1 ? getCustom(value) : '');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed—with a configured 1-second preset, clicking Custom emits onChange(1), the controlled parent feeds 1 back, and the [value, isPreset, getCustom] effect re-selects the preset and disables the custom input, so Custom can't be edited on the first click. Could the effect skip re-syncing when the incoming value was just emitted by the Custom radio?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed and rebased onto master in commit 44f8e861a5 @sadpandajoe. lastCustomEmittedValue tracks values emitted from the Custom controls so controlled parents echoing 1 back do not snap selection to a colliding 1 second preset, and custom drafts are preserved across preset switches while clamping values below MINIMUM_REFRESH_INTERVAL.

return (
<StyledRadioGroup value={radioSelection} onChange={handleRadioChange}>
{REFRESH_FREQUENCY_OPTIONS.slice(0, -1).map(option => (
{activeOptions.map((option) => (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new (option) => / (e) => arrow parens (here, line 89 and line 243) conflict with arrowParens: "avoid" in .oxfmtrc.json. The pre-commit job is already red because the formatter rewrites this file, so the PR can't merge until the formatter output is committed. Could you run the repo formatter on this file and keep the pre-existing option => / e => style?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatted in commit 1541e6586c using oxfmt --write with arrowParens: "avoid" to align with .oxfmtrc.json and keep single-parameter arrow syntax across source and test files.

@FrancescoCastaldi

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review @sadpandajoe.

I have addressed all points in commit d94a14d:

  1. Store configuration lookup: Updated useSelector in RefreshFrequencySelect.tsx to check state.common?.conf?.DASHBOARD_AUTO_REFRESH_INTERVALS first before falling back to state.dashboardInfo?.common?.conf?.DASHBOARD_AUTO_REFRESH_INTERVALS. This ensures the Properties modal correctly displays configured intervals on dashboard list and home pages as well.
  2. Custom interval selection with 1-second preset: Added lastEmittedCustomValueRef to track locally emitted custom intervals. When the controlled parent feeds back the value emitted upon selecting Custom or typing a custom duration, the synchronization effect skips reverting to the preset, keeping the Custom radio selected and the input enabled. Also preserved custom values across preset toggling.
  3. Formatter compliance: Formatted both source and test files using oxfmt --write with arrowParens: "avoid", ensuring single-parameter arrow functions use the canonical style (option =>, e =>).
  4. Unit test coverage: Added test cases covering the top-level state.common.conf store shape, controlled parent interaction when configured intervals include a 1-second preset, and custom value persistence across selections (all 17 unit tests passing).

@@ -120,11 +220,13 @@ export const RefreshFrequencySelect = ({
if (selectedValue === -1) {
// Custom selected - use current custom value or minimum
const numValue = parseInt(customValue, 10) || MINIMUM_REFRESH_INTERVAL;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone types an invalid draft such as -5 into Custom, picks a preset, and then picks Custom again, this line re-emits -5: parseInt('-5', 10) is truthy so the || MINIMUM_REFRESH_INTERVAL fallback never applies. The typing handler rejects values below the minimum, but this path doesn't, and validateRefreshFrequency only checks positive frequencies, so Save accepts a negative interval and auto-refresh quietly stops while Custom stays selected. Before this change the draft was cleared when a preset was chosen, so the path wasn't reachable.

Could this clamp the value (e.g. only reuse the draft when it parses to at least MINIMUM_REFRESH_INTERVAL), and could a controlled test cover the type -5 → preset → Custom sequence?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clamped the draft value in handleRadioChange so that when reselecting Custom, it only reuses drafts that parse to at least MINIMUM_REFRESH_INTERVAL, falling back to MINIMUM_REFRESH_INTERVAL (and updating customValue) otherwise. Added a controlled regression test covering the -5 -> preset -> Custom sequence in RefreshFrequencySelect.test.tsx.

@FrancescoCastaldi

Copy link
Copy Markdown
Contributor Author

Hi @sadpandajoe @richardfogaca,

All four review items are in place on this PR (store configuration lookup via state.common?.conf, custom selection retention with 1-second presets via lastEmittedCustomValueRef, oxfmt formatting with arrowParens: "avoid", and negative draft clamping).

All 18 unit tests in RefreshFrequencySelect.test.tsx pass cleanly. Whenever you have a chance, please take a look for re-review. Thank you!

@coderabbitai review
@bito-code-review

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 12, 2026
@FrancescoCastaldi
FrancescoCastaldi force-pushed the fix/issue-44981-dashboard-auto-refresh-intervals branch from 1541e65 to 44f8e86 Compare October 12, 2026 21:46
@FrancescoCastaldi

Copy link
Copy Markdown
Contributor Author

Rebased onto latest master (44f8e861a5) to resolve the merge conflict and clear requires:rebase @sadpandajoe:

  1. Preserved all CUSTOM_REFRESH_FREQUENCY and getRefreshFrequencyOptions logic from master while adding options?: [number, string][] prop override support and exporting isPresetValue and getCustomValue.
  2. Preserved custom interval draft values across preset switches while clamping drafts below MINIMUM_REFRESH_INTERVAL (preventing negative drafts such as -5 from being re-emitted).
  3. Verified oxfmt and oxlint pass with 0 warnings and 0 errors.

@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 13, 2026
@rusackas
rusackas merged commit 15f5568 into apache:master Oct 20, 2026
79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard auto-refresh dropdown ignores DASHBOARD_AUTO_REFRESH_INTERVALS (6.1.0 and master)

4 participants