Chore: Improve typing for onPanelConfigChange (#80710)

This commit is contained in:
kay delaney 2024-01-17 11:13:14 +00:00 committed by GitHub
parent 7c74ab7059
commit 8872a004e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 9 additions and 9 deletions

View File

@ -125,7 +125,7 @@ export function getPanelFrameCategory(props: OptionPaneRenderProps): OptionsPane
<RepeatRowSelect
id="repeat-by-variable-select"
repeat={panel.repeat}
onChange={(value?: string | null) => {
onChange={(value?: string) => {
onPanelConfigChange('repeat', value);
}}
/>

View File

@ -56,7 +56,7 @@ export interface OptionPaneRenderProps {
data?: PanelData;
dashboard: DashboardModel;
instanceState: unknown;
onPanelConfigChange: (configKey: keyof PanelModel, value: unknown) => void;
onPanelConfigChange: <T extends keyof PanelModel>(configKey: T, value: PanelModel[T]) => void;
onPanelOptionsChanged: (options: PanelModel['options']) => void;
onFieldConfigsChange: (config: FieldConfigSource) => void;
}

View File

@ -8,8 +8,8 @@ import { getLastKey, getVariablesByKey } from '../../../variables/state/selector
export interface Props {
id?: string;
repeat?: string | null;
onChange: (name: string | null) => void;
repeat?: string;
onChange: (name?: string) => void;
}
export const RepeatRowSelect = ({ repeat, onChange, id }: Props) => {

View File

@ -7,7 +7,7 @@ import { RowOptionsModal } from './RowOptionsModal';
export interface RowOptionsButtonProps {
title: string;
repeat?: string | null;
repeat?: string;
onUpdate: OnRowOptionsUpdate;
warning?: React.ReactNode;
}

View File

@ -9,15 +9,15 @@ export type OnRowOptionsUpdate = (title: string, repeat?: string | null) => void
export interface Props {
title: string;
repeat?: string | null;
repeat?: string;
onUpdate: OnRowOptionsUpdate;
onCancel: () => void;
warning?: React.ReactNode;
}
export const RowOptionsForm = ({ repeat, title, warning, onUpdate, onCancel }: Props) => {
const [newRepeat, setNewRepeat] = useState<string | null | undefined>(repeat);
const onChangeRepeat = useCallback((name?: string | null) => setNewRepeat(name), [setNewRepeat]);
const [newRepeat, setNewRepeat] = useState<string | undefined>(repeat);
const onChangeRepeat = useCallback((name?: string) => setNewRepeat(name), [setNewRepeat]);
return (
<Form

View File

@ -7,7 +7,7 @@ import { OnRowOptionsUpdate, RowOptionsForm } from './RowOptionsForm';
export interface RowOptionsModalProps {
title: string;
repeat?: string | null;
repeat?: string;
warning?: React.ReactNode;
onDismiss: () => void;
onUpdate: OnRowOptionsUpdate;