import { NameValueTable, SectionBox } from '@kinvolk/headlamp-plugin/lib/CommonComponents'; import React from 'react'; import { getDashboardUrl, getRefreshInterval, INTERVAL_OPTIONS, setDashboardUrl, setRefreshInterval } from '../api/polaris'; interface PluginSettingsProps { data?: { [key: string]: string | number | boolean }; onDataChange?: (data: { [key: string]: string | number | boolean }) => void; } export default function PolarisSettings(props: PluginSettingsProps) { const { data, onDataChange } = props; const currentInterval = (data?.refreshInterval as number) ?? getRefreshInterval(); const currentUrl = (data?.dashboardUrl as string) ?? getDashboardUrl(); function handleIntervalChange(e: React.ChangeEvent) { const seconds = Number(e.target.value); setRefreshInterval(seconds); onDataChange?.({ ...data, refreshInterval: seconds }); } function handleUrlChange(e: React.ChangeEvent) { const url = e.target.value; setDashboardUrl(url); onDataChange?.({ ...data, dashboardUrl: url }); } return ( {INTERVAL_OPTIONS.map(opt => ( ))} ), }, { name: 'Dashboard URL', value: (
Examples:
• K8s proxy: /api/v1/namespaces/polaris/services/polaris-dashboard:80/proxy/
• Full URL: https://my-polaris.example.com
), }, ]} />
); }