mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CloudWatch: Fix strict Typescript errors (#41160)
* CloudWatch: Fix strict typscript errors * Update public/app/plugins/datasource/cloudwatch/components/ConfigEditor.tsx Co-authored-by: Sarah Zinger <sarahzinger@users.noreply.github.com> * Chore: reduce strict error * Update ci-check-strict.sh Co-authored-by: Sarah Zinger <sarahzinger@users.noreply.github.com> Co-authored-by: Hugo Häggmark <hugo.haggmark@gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { ChangeEvent } from 'react';
|
||||
import { LegacyForms } from '@grafana/ui';
|
||||
const { Switch } = LegacyForms;
|
||||
import { PanelData } from '@grafana/data';
|
||||
import { CloudWatchAnnotationQuery } from '../types';
|
||||
import { CloudWatchAnnotationQuery, CloudWatchQuery } from '../types';
|
||||
import { CloudWatchDatasource } from '../datasource';
|
||||
import { QueryField, PanelQueryEditor } from './';
|
||||
|
||||
@@ -20,7 +20,7 @@ export function AnnotationQueryEditor(props: React.PropsWithChildren<Props>) {
|
||||
<>
|
||||
<PanelQueryEditor
|
||||
{...props}
|
||||
onChange={(editorQuery: CloudWatchAnnotationQuery) => onChange({ ...query, ...editorQuery })}
|
||||
onChange={(editorQuery: CloudWatchQuery) => onChange({ ...query, ...editorQuery })}
|
||||
onRunQuery={() => {}}
|
||||
history={[]}
|
||||
></PanelQueryEditor>
|
||||
|
||||
@@ -71,10 +71,16 @@ function useAuthenticationWarning(jsonData: CloudWatchJsonData) {
|
||||
|
||||
function useDatasource(datasourceName: string) {
|
||||
const [datasource, setDatasource] = useState<CloudWatchDatasource>();
|
||||
|
||||
useEffect(() => {
|
||||
getDatasourceSrv()
|
||||
.loadDatasource(datasourceName)
|
||||
.then((datasource: CloudWatchDatasource) => setDatasource(datasource));
|
||||
.then((datasource) => {
|
||||
// It's really difficult to type .loadDatasource() because it's inherently untyped as it involves two JSON.parse()'s
|
||||
// So a "as" type assertion here is a necessary evil.
|
||||
setDatasource(datasource as CloudWatchDatasource);
|
||||
});
|
||||
}, [datasourceName]);
|
||||
|
||||
return datasource;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,9 @@ export const CloudWatchLogsQueryEditor = memo(function CloudWatchLogsQueryEditor
|
||||
datasource={datasource}
|
||||
query={query}
|
||||
onBlur={() => {}}
|
||||
onChange={(val: CloudWatchLogsQuery) => onChange({ ...val, queryMode: 'Logs' })}
|
||||
onChange={(val: CloudWatchQuery) => {
|
||||
onChange({ ...val, queryMode: 'Logs' });
|
||||
}}
|
||||
onRunQuery={onRunQuery}
|
||||
history={[]}
|
||||
data={data}
|
||||
|
||||
Reference in New Issue
Block a user