fix: add explicit GET method to API requests and make refresh interval reactive

- Add explicit method: 'GET' to ApiProxy.request() calls in polaris.ts and PolarisSettings.tsx
  for compatibility with Headlamp SDK
- Make refresh interval reactive by polling localStorage every second in PolarisDataContext
  so settings changes take effect immediately without page reload

Fixes connection test button and data refresh issues.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
2026-02-12 12:23:33 -05:00
parent 8fab7828f4
commit 0e5ff9b7b7
3 changed files with 20 additions and 4 deletions
+14 -2
View File
@@ -35,8 +35,20 @@ const PolarisDataContext = React.createContext<PolarisDataContextValue | null>(n
* ```
*/
export function PolarisDataProvider(props: { children: React.ReactNode }) {
const interval = getRefreshInterval();
const state = usePolarisData(interval);
// Re-read interval on every render to pick up changes from settings
const [refreshInterval, setRefreshInterval] = React.useState(getRefreshInterval());
// Poll for interval changes (localStorage changes from settings)
React.useEffect(() => {
const intervalId = window.setInterval(() => {
const newInterval = getRefreshInterval();
setRefreshInterval(prev => (prev !== newInterval ? newInterval : prev));
}, 1000); // Check every second
return () => window.clearInterval(intervalId);
}, []);
const state = usePolarisData(refreshInterval);
// Rename triggerRefresh to refresh for consistency
const value = React.useMemo(
+3 -1
View File
@@ -373,7 +373,9 @@ export function usePolarisData(refreshIntervalSeconds: number): PolarisDataState
result = await response.json();
} else {
// Kubernetes proxy for relative URLs
result = await ApiProxy.request(apiPath);
result = await ApiProxy.request(apiPath, {
method: 'GET',
});
}
if (!cancelled) {
+3 -1
View File
@@ -58,7 +58,9 @@ export default function PolarisSettings(props: PluginSettingsProps) {
}
result = await response.json();
} else {
result = await ApiProxy.request(apiPath);
result = await ApiProxy.request(apiPath, {
method: 'GET',
});
}
setTestResult({