mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Fix more strict typescript errors (#35514)
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { QueryEditorHelpProps } from '@grafana/data';
|
||||
import { css } from '@emotion/css';
|
||||
import { CloudMonitoringQuery } from '../types';
|
||||
|
||||
export default class CloudMonitoringCheatSheet extends PureComponent<QueryEditorHelpProps, { userExamples: string[] }> {
|
||||
export default class CloudMonitoringCheatSheet extends PureComponent<
|
||||
QueryEditorHelpProps<CloudMonitoringQuery>,
|
||||
{ userExamples: string[] }
|
||||
> {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
|
||||
@@ -5,7 +5,7 @@ import Prism from 'prismjs';
|
||||
import tokenizer from '../syntax';
|
||||
import { flattenTokens } from '@grafana/ui/src/slate-plugins/slate-prism';
|
||||
import { css, cx } from '@emotion/css';
|
||||
import { CloudWatchLogsQuery } from '../types';
|
||||
import { CloudWatchQuery } from '../types';
|
||||
|
||||
interface QueryExample {
|
||||
category: string;
|
||||
@@ -214,8 +214,11 @@ const exampleCategory = css`
|
||||
margin-top: 5px;
|
||||
`;
|
||||
|
||||
export default class LogsCheatSheet extends PureComponent<QueryEditorHelpProps, { userExamples: string[] }> {
|
||||
onClickExample(query: CloudWatchLogsQuery) {
|
||||
export default class LogsCheatSheet extends PureComponent<
|
||||
QueryEditorHelpProps<CloudWatchQuery>,
|
||||
{ userExamples: string[] }
|
||||
> {
|
||||
onClickExample(query: CloudWatchQuery) {
|
||||
this.props.onClickExample(query);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { shuffle } from 'lodash';
|
||||
import { QueryEditorHelpProps, DataQuery } from '@grafana/data';
|
||||
import { QueryEditorHelpProps } from '@grafana/data';
|
||||
import LokiLanguageProvider from '../language_provider';
|
||||
import { LokiQuery } from '../types';
|
||||
|
||||
const DEFAULT_EXAMPLES = ['{job="default/prometheus"}'];
|
||||
const PREFERRED_LABELS = ['job', 'app', 'k8s_app'];
|
||||
@@ -32,7 +33,7 @@ const LOGQL_EXAMPLES = [
|
||||
},
|
||||
];
|
||||
|
||||
export default class LokiCheatSheet extends PureComponent<QueryEditorHelpProps, { userExamples: string[] }> {
|
||||
export default class LokiCheatSheet extends PureComponent<QueryEditorHelpProps<LokiQuery>, { userExamples: string[] }> {
|
||||
userLabelTimer: NodeJS.Timeout;
|
||||
state = {
|
||||
userExamples: DEFAULT_EXAMPLES,
|
||||
@@ -72,11 +73,7 @@ export default class LokiCheatSheet extends PureComponent<QueryEditorHelpProps,
|
||||
const { onClickExample } = this.props;
|
||||
|
||||
return (
|
||||
<div
|
||||
className="cheat-sheet-item__example"
|
||||
key={expr}
|
||||
onClick={(e) => onClickExample({ refId: 'A', expr } as DataQuery)}
|
||||
>
|
||||
<div className="cheat-sheet-item__example" key={expr} onClick={(e) => onClickExample({ refId: 'A', expr })}>
|
||||
<code>{expr}</code>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import { QueryEditorHelpProps, DataQuery } from '@grafana/data';
|
||||
import { QueryEditorHelpProps } from '@grafana/data';
|
||||
import { PromQuery } from '../types';
|
||||
|
||||
const CHEAT_SHEET_ITEMS = [
|
||||
{
|
||||
@@ -25,7 +26,7 @@ const CHEAT_SHEET_ITEMS = [
|
||||
},
|
||||
];
|
||||
|
||||
const PromCheatSheet = (props: QueryEditorHelpProps) => (
|
||||
const PromCheatSheet = (props: QueryEditorHelpProps<PromQuery>) => (
|
||||
<div>
|
||||
<h2>PromQL Cheat Sheet</h2>
|
||||
{CHEAT_SHEET_ITEMS.map((item, index) => (
|
||||
@@ -34,7 +35,7 @@ const PromCheatSheet = (props: QueryEditorHelpProps) => (
|
||||
{item.expression ? (
|
||||
<div
|
||||
className="cheat-sheet-item__example"
|
||||
onClick={(e) => props.onClickExample({ refId: 'A', expr: item.expression } as DataQuery)}
|
||||
onClick={(e) => props.onClickExample({ refId: 'A', expr: item.expression })}
|
||||
>
|
||||
<code>{item.expression}</code>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user