/** * Settings Page * * Configuration page for the Sealed Secrets plugin */ import { SectionBox } from '@kinvolk/headlamp-plugin/lib/CommonComponents'; import { Box, Button, Divider, TextField, Typography } from '@mui/material'; import { useSnackbar } from 'notistack'; import React from 'react'; import { getPluginConfig, savePluginConfig } from '../lib/controller'; import { PluginConfig } from '../types'; import { ControllerStatus } from './ControllerStatus'; import { VersionWarning } from './VersionWarning'; interface PluginSettingsProps { data?: { [key: string]: string | number | boolean }; onDataChange?: (data: { [key: string]: string | number | boolean }) => void; } /** * Settings page component */ export function SettingsPage(props: PluginSettingsProps) { const { data, onDataChange } = props; const storedConfig = getPluginConfig(); const [config, setConfig] = React.useState({ controllerName: (data?.controllerName as string) ?? storedConfig.controllerName, controllerNamespace: (data?.controllerNamespace as string) ?? storedConfig.controllerNamespace, controllerPort: (data?.controllerPort as number) ?? storedConfig.controllerPort, }); const { enqueueSnackbar } = useSnackbar(); const handleSave = () => { savePluginConfig(config); onDataChange?.(config as unknown as { [key: string]: string | number | boolean }); enqueueSnackbar('Settings saved successfully', { variant: 'success' }); }; const handleReset = () => { const defaultConfig: PluginConfig = { controllerName: 'sealed-secrets-controller', controllerNamespace: 'kube-system', controllerPort: 8080, }; setConfig(defaultConfig); }; return ( Configure the connection to your Sealed Secrets controller. These settings are stored in your browser's local storage. {/* API Version Detection */} {/* Controller Health Status */} Controller Status
Controller Configuration { const newConfig = { ...config, controllerName: e.target.value }; setConfig(newConfig); onDataChange?.(newConfig as unknown as { [key: string]: string | number | boolean }); }} margin="normal" helperText="Name of the sealed-secrets-controller deployment/service" inputProps={{ 'aria-label': 'Controller name', 'aria-describedby': 'controller-name-help', }} FormHelperTextProps={{ id: 'controller-name-help', }} /> { const newConfig = { ...config, controllerNamespace: e.target.value }; setConfig(newConfig); onDataChange?.(newConfig as unknown as { [key: string]: string | number | boolean }); }} margin="normal" helperText="Namespace where the controller is installed" inputProps={{ 'aria-label': 'Controller namespace', 'aria-describedby': 'controller-namespace-help', }} FormHelperTextProps={{ id: 'controller-namespace-help', }} /> { const newConfig = { ...config, controllerPort: parseInt(e.target.value, 10) }; setConfig(newConfig); onDataChange?.(newConfig as unknown as { [key: string]: string | number | boolean }); }} margin="normal" helperText="HTTP port of the controller service" inputProps={{ 'aria-label': 'Controller port', 'aria-describedby': 'controller-port-help', min: 1, max: 65535, }} FormHelperTextProps={{ id: 'controller-port-help', }} /> Default Values
Controller Name:
{' '}
sealed-secrets-controller

Controller Namespace:
{' '}
kube-system

Controller Port:
{' '}
8080
); }