mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Fix more TypeScript errors (#36918)
* TypeScript: Fix some strict typescript errors * Fix more strict typescript errors * Few more fixes * Better string conversion * update check script to 195
This commit is contained in:
@@ -46,9 +46,9 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
|
||||
});
|
||||
};
|
||||
|
||||
onUpdate = (title: string, repeat: string | undefined) => {
|
||||
onUpdate = (title: string, repeat?: string | null) => {
|
||||
this.props.panel['title'] = title;
|
||||
this.props.panel['repeat'] = repeat;
|
||||
this.props.panel['repeat'] = repeat ?? undefined;
|
||||
this.props.panel.render();
|
||||
this.props.dashboard.processRepeats();
|
||||
this.forceUpdate();
|
||||
|
||||
@@ -43,7 +43,7 @@ export class TimePickerSettings extends PureComponent<Props, State> {
|
||||
this.props.onHideTimePickerChange(!this.props.timePickerHidden);
|
||||
};
|
||||
|
||||
onTimeZoneChange = (timeZone: string) => {
|
||||
onTimeZoneChange = (timeZone?: string) => {
|
||||
if (typeof timeZone !== 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ interface Props {
|
||||
dashboard: DashboardModel;
|
||||
onFieldConfigsChange: (config: FieldConfigSource) => void;
|
||||
onPanelOptionsChanged: (options: any) => void;
|
||||
onPanelConfigChange: (configKey: string, value: any) => void;
|
||||
onPanelConfigChange: (configKey: keyof PanelModel, value: any) => void;
|
||||
}
|
||||
|
||||
export const OptionsPane: React.FC<Props> = ({
|
||||
|
||||
@@ -19,7 +19,7 @@ interface Props {
|
||||
data?: PanelData;
|
||||
onFieldConfigsChange: (config: FieldConfigSource) => void;
|
||||
onPanelOptionsChanged: (options: any) => void;
|
||||
onPanelConfigChange: (configKey: string, value: any) => void;
|
||||
onPanelConfigChange: (configKey: keyof PanelModel, value: any) => void;
|
||||
}
|
||||
|
||||
export const OptionsPaneOptions: React.FC<Props> = (props) => {
|
||||
|
||||
@@ -110,7 +110,7 @@ export function getPanelFrameCategory(props: OptionPaneRenderProps): OptionsPane
|
||||
return (
|
||||
<RepeatRowSelect
|
||||
repeat={panel.repeat}
|
||||
onChange={(value: string | null) => {
|
||||
onChange={(value?: string | null) => {
|
||||
onPanelConfigChange('repeat', value);
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -54,7 +54,7 @@ export interface OptionPaneRenderProps {
|
||||
plugin: PanelPlugin;
|
||||
data?: PanelData;
|
||||
dashboard: DashboardModel;
|
||||
onPanelConfigChange: (configKey: string, value: any) => void;
|
||||
onPanelConfigChange: (configKey: keyof PanelModel, value: any) => void;
|
||||
onPanelOptionsChanged: (options: any) => void;
|
||||
onFieldConfigsChange: (config: FieldConfigSource) => void;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import { getVariables } from '../../../variables/state/selectors';
|
||||
import { StoreState } from '../../../../types';
|
||||
|
||||
export interface Props {
|
||||
repeat: string | undefined | null;
|
||||
onChange: (name: string | null | undefined) => void;
|
||||
repeat?: string | null;
|
||||
onChange: (name: string | null) => void;
|
||||
}
|
||||
|
||||
export const RepeatRowSelect: FC<Props> = ({ repeat, onChange }) => {
|
||||
@@ -34,7 +34,7 @@ export const RepeatRowSelect: FC<Props> = ({ repeat, onChange }) => {
|
||||
return options;
|
||||
}, [variables]);
|
||||
|
||||
const onSelectChange = useCallback((option: SelectableValue<string | null>) => onChange(option.value), [onChange]);
|
||||
const onSelectChange = useCallback((option: SelectableValue<string | null>) => onChange(option.value!), [onChange]);
|
||||
|
||||
return <Select value={repeat} onChange={onSelectChange} options={variableOptions} />;
|
||||
};
|
||||
|
||||
@@ -5,13 +5,13 @@ import { RowOptionsModal } from './RowOptionsModal';
|
||||
import { OnRowOptionsUpdate } from './RowOptionsForm';
|
||||
|
||||
export interface RowOptionsButtonProps {
|
||||
title: string | null;
|
||||
repeat: string | null | undefined;
|
||||
title: string;
|
||||
repeat?: string | null;
|
||||
onUpdate: OnRowOptionsUpdate;
|
||||
}
|
||||
|
||||
export const RowOptionsButton: FC<RowOptionsButtonProps> = ({ repeat, title, onUpdate }) => {
|
||||
const onUpdateChange = (hideModal: () => void) => (title: string | null, repeat: string | null) => {
|
||||
const onUpdateChange = (hideModal: () => void) => (title: string, repeat?: string | null) => {
|
||||
onUpdate(title, repeat);
|
||||
hideModal();
|
||||
};
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Button, Field, Form, Modal, Input } from '@grafana/ui';
|
||||
|
||||
import { RepeatRowSelect } from '../RepeatRowSelect/RepeatRowSelect';
|
||||
|
||||
export type OnRowOptionsUpdate = (title: string | null, repeat: string | null | undefined) => void;
|
||||
export type OnRowOptionsUpdate = (title: string, repeat?: string | null) => void;
|
||||
|
||||
export interface Props {
|
||||
title: string | null;
|
||||
title: string;
|
||||
repeat?: string | null;
|
||||
onUpdate: OnRowOptionsUpdate;
|
||||
onCancel: () => void;
|
||||
@@ -14,12 +14,12 @@ export interface Props {
|
||||
|
||||
export const RowOptionsForm: FC<Props> = ({ repeat, title, onUpdate, onCancel }) => {
|
||||
const [newRepeat, setNewRepeat] = useState<string | null | undefined>(repeat);
|
||||
const onChangeRepeat = useCallback((name: string) => setNewRepeat(name), [setNewRepeat]);
|
||||
const onChangeRepeat = useCallback((name?: string | null) => setNewRepeat(name), [setNewRepeat]);
|
||||
|
||||
return (
|
||||
<Form
|
||||
defaultValues={{ title }}
|
||||
onSubmit={(formData: { title: string | null }) => {
|
||||
onSubmit={(formData: { title: string }) => {
|
||||
onUpdate(formData.title, newRepeat);
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -5,8 +5,8 @@ import { css } from '@emotion/css';
|
||||
import { OnRowOptionsUpdate, RowOptionsForm } from './RowOptionsForm';
|
||||
|
||||
export interface RowOptionsModalProps {
|
||||
title: string | null;
|
||||
repeat: string | null;
|
||||
title: string;
|
||||
repeat?: string | null;
|
||||
onDismiss: () => void;
|
||||
onUpdate: OnRowOptionsUpdate;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { css } from '@emotion/css';
|
||||
|
||||
export interface Props {
|
||||
current: PanelPluginMeta;
|
||||
onTypeChange: (newType: PanelPluginMeta, withModKey?: boolean) => void;
|
||||
onTypeChange: (newType: PanelPluginMeta, withModKey: boolean) => void;
|
||||
searchQuery: string;
|
||||
onClose: () => void;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ export const VizTypePicker: React.FC<Props> = ({ searchQuery, onTypeChange, curr
|
||||
key={plugin.id}
|
||||
isCurrent={isCurrent}
|
||||
plugin={plugin}
|
||||
onClick={(e) => onTypeChange(plugin, e.metaKey || e.ctrlKey || e.altKey)}
|
||||
onClick={(e) => onTypeChange(plugin, Boolean(e.metaKey || e.ctrlKey || e.altKey))}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user