mirror of
https://github.com/grafana/grafana.git
synced 2024-12-27 09:21:35 -06:00
Chore: More TypeScript strict fixes (#39300)
* Chore: More TypeScript strict fixes * Chore: Use filter instead of reduce to fix TypeScript error * Chore: Retype AzureResultFormat as string * Chore: Account for getBlocks() poor typings of reduce * Chore: Need to explicitly check for undefined here since '' is falsey
This commit is contained in:
parent
5eb46281a4
commit
52d7358d83
@ -28,7 +28,7 @@ import {
|
|||||||
import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
|
import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
|
||||||
import { contextSrv } from 'app/core/core';
|
import { contextSrv } from 'app/core/core';
|
||||||
|
|
||||||
interface OwnProps extends GrafanaRouteComponentProps<{}, { username: string }> {
|
interface OwnProps extends GrafanaRouteComponentProps<{}, { username?: string }> {
|
||||||
navModel: NavModel;
|
navModel: NavModel;
|
||||||
ldapConnectionInfo: LdapConnectionInfo;
|
ldapConnectionInfo: LdapConnectionInfo;
|
||||||
ldapUser?: LdapUser;
|
ldapUser?: LdapUser;
|
||||||
|
@ -357,7 +357,7 @@ export default class CloudMonitoringDatasource extends DataSourceWithBackend<
|
|||||||
value,
|
value,
|
||||||
...(condition && { condition }),
|
...(condition && { condition }),
|
||||||
}))
|
}))
|
||||||
.reduce((res, filter) => (filter.value ? [...res, filter] : res), []);
|
.filter((item) => item.value);
|
||||||
|
|
||||||
const filterArray = flatten(
|
const filterArray = flatten(
|
||||||
completeFilter.map(({ key, operator, value, condition }: Filter) => [
|
completeFilter.map(({ key, operator, value, condition }: Filter) => [
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Alert, CodeEditor, Select } from '@grafana/ui';
|
import { Alert, CodeEditor, Select } from '@grafana/ui';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { AzureMonitorOption, AzureMonitorQuery, AzureResultFormat } from '../../types';
|
import { AzureMonitorOption, AzureMonitorQuery } from '../../types';
|
||||||
import { Field } from '../Field';
|
import { Field } from '../Field';
|
||||||
import { Space } from '../Space';
|
import { Space } from '../Space';
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ interface InsightsAnalyticsEditorProps {
|
|||||||
query: AzureMonitorQuery;
|
query: AzureMonitorQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FORMAT_OPTIONS: Array<AzureMonitorOption<AzureResultFormat>> = [
|
const FORMAT_OPTIONS: Array<AzureMonitorOption<string>> = [
|
||||||
{ label: 'Time series', value: 'time_series' },
|
{ label: 'Time series', value: 'time_series' },
|
||||||
{ label: 'Table', value: 'table' },
|
{ label: 'Table', value: 'table' },
|
||||||
];
|
];
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import React, { useCallback, useMemo } from 'react';
|
import React, { useCallback, useMemo } from 'react';
|
||||||
import { SelectableValue } from '@grafana/data';
|
import { SelectableValue } from '@grafana/data';
|
||||||
import { Select } from '@grafana/ui';
|
import { Select } from '@grafana/ui';
|
||||||
import { AzureMonitorOption, AzureQueryEditorFieldProps, AzureResultFormat } from '../../types';
|
import { AzureQueryEditorFieldProps } from '../../types';
|
||||||
import { Field } from '../Field';
|
import { Field } from '../Field';
|
||||||
import { setFormatAs } from './setQueryValue';
|
import { setFormatAs } from './setQueryValue';
|
||||||
|
|
||||||
const FORMAT_OPTIONS: Array<AzureMonitorOption<AzureResultFormat>> = [
|
const FORMAT_OPTIONS: Array<SelectableValue<string>> = [
|
||||||
{ label: 'Time series', value: 'time_series' },
|
{ label: 'Time series', value: 'time_series' },
|
||||||
{ label: 'Table', value: 'table' },
|
{ label: 'Table', value: 'table' },
|
||||||
];
|
];
|
||||||
@ -14,7 +14,7 @@ const FormatAsField: React.FC<AzureQueryEditorFieldProps> = ({ query, variableOp
|
|||||||
const options = useMemo(() => [...FORMAT_OPTIONS, variableOptionGroup], [variableOptionGroup]);
|
const options = useMemo(() => [...FORMAT_OPTIONS, variableOptionGroup], [variableOptionGroup]);
|
||||||
|
|
||||||
const handleChange = useCallback(
|
const handleChange = useCallback(
|
||||||
(change: SelectableValue<AzureResultFormat>) => {
|
(change: SelectableValue<string>) => {
|
||||||
const { value } = change;
|
const { value } = change;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return;
|
return;
|
||||||
|
@ -12,8 +12,6 @@ export interface DatasourceValidationResult {
|
|||||||
title?: string;
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AzureResultFormat = 'time_series' | 'table';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Azure clouds known to Azure Monitor.
|
* Azure clouds known to Azure Monitor.
|
||||||
*/
|
*/
|
||||||
|
@ -267,7 +267,10 @@ export default class PromQlLanguageProvider extends LanguageProvider {
|
|||||||
|
|
||||||
// Stitch all query lines together to support multi-line queries
|
// Stitch all query lines together to support multi-line queries
|
||||||
let queryOffset;
|
let queryOffset;
|
||||||
const queryText = value.document.getBlocks().reduce((text: string, block) => {
|
const queryText = value.document.getBlocks().reduce((text, block) => {
|
||||||
|
if (text === undefined) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
if (!block) {
|
if (!block) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ set -e
|
|||||||
|
|
||||||
echo -e "Collecting code stats (typescript errors & more)"
|
echo -e "Collecting code stats (typescript errors & more)"
|
||||||
|
|
||||||
ERROR_COUNT_LIMIT=46
|
ERROR_COUNT_LIMIT=41
|
||||||
ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --strict true | grep -oP 'Found \K(\d+)')"
|
ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --strict true | grep -oP 'Found \K(\d+)')"
|
||||||
|
|
||||||
if [ "$ERROR_COUNT" -gt $ERROR_COUNT_LIMIT ]; then
|
if [ "$ERROR_COUNT" -gt $ERROR_COUNT_LIMIT ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user