Update dependency prettier to v2.5.1 (#43473)
* Update dependency prettier to v2.5.1 * prettier fixes * chore(toolkit): bump prettier to 2.5.1 * style(eslint): bump grafana config to 2.5.2 in core and toolkit * style(mssql-datasource): fix no-inferrable-types eslint errors Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com> Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
This commit is contained in:
co-authored by
Renovate Bot
Ashley Harrison
Jack Westbrook
parent
3b4e812449
commit
d87cd6f26c
@@ -19,7 +19,7 @@ export class DataFrameView<T = any> extends FunctionalVector<T> {
|
||||
|
||||
constructor(private data: DataFrame) {
|
||||
super();
|
||||
const obj = ({} as unknown) as T;
|
||||
const obj = {} as unknown as T;
|
||||
|
||||
for (let i = 0; i < data.fields.length; i++) {
|
||||
const field = data.fields[i];
|
||||
|
||||
@@ -169,6 +169,6 @@ function toStringProcessor(value: any): DisplayValue {
|
||||
export function getRawDisplayProcessor(): DisplayProcessor {
|
||||
return (value: any) => ({
|
||||
text: `${value}`,
|
||||
numeric: (null as unknown) as number,
|
||||
numeric: null as unknown as number,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ describe('applyFieldOverrides', () => {
|
||||
const data = applyFieldOverrides({
|
||||
data: [f0], // the frame
|
||||
fieldConfig: src as FieldConfigSource, // defaults + overrides
|
||||
replaceVariables: (undefined as any) as InterpolateFunction,
|
||||
replaceVariables: undefined as any as InterpolateFunction,
|
||||
theme: createTheme(),
|
||||
fieldConfigRegistry: customFieldRegistry,
|
||||
})[0];
|
||||
@@ -284,7 +284,7 @@ describe('applyFieldOverrides', () => {
|
||||
const data = applyFieldOverrides({
|
||||
data: [f0], // the frame
|
||||
fieldConfig: src as FieldConfigSource, // defaults + overrides
|
||||
replaceVariables: (undefined as any) as InterpolateFunction,
|
||||
replaceVariables: undefined as any as InterpolateFunction,
|
||||
theme: createTheme(),
|
||||
})[0];
|
||||
const valueColumn = data.fields[1];
|
||||
@@ -321,7 +321,7 @@ describe('applyFieldOverrides', () => {
|
||||
const data = applyFieldOverrides({
|
||||
data: [f0], // the frame
|
||||
fieldConfig: src as FieldConfigSource, // defaults + overrides
|
||||
replaceVariables: (undefined as any) as InterpolateFunction,
|
||||
replaceVariables: undefined as any as InterpolateFunction,
|
||||
theme: createTheme(),
|
||||
})[0];
|
||||
|
||||
@@ -659,7 +659,7 @@ describe('applyRawFieldOverrides', () => {
|
||||
steps: [
|
||||
{
|
||||
color: 'green',
|
||||
value: (null as unknown) as number,
|
||||
value: null as unknown as number,
|
||||
},
|
||||
{
|
||||
color: 'red',
|
||||
|
||||
@@ -338,117 +338,119 @@ export function validateFieldConfig(config: FieldConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
export const getLinksSupplier = (
|
||||
frame: DataFrame,
|
||||
field: Field,
|
||||
fieldScopedVars: ScopedVars,
|
||||
replaceVariables: InterpolateFunction,
|
||||
timeZone?: TimeZone
|
||||
) => (config: ValueLinkConfig): Array<LinkModel<Field>> => {
|
||||
if (!field.config.links || field.config.links.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const timeRangeUrl = locationUtil.getTimeRangeUrlParams();
|
||||
const { timeField } = getTimeField(frame);
|
||||
export const getLinksSupplier =
|
||||
(
|
||||
frame: DataFrame,
|
||||
field: Field,
|
||||
fieldScopedVars: ScopedVars,
|
||||
replaceVariables: InterpolateFunction,
|
||||
timeZone?: TimeZone
|
||||
) =>
|
||||
(config: ValueLinkConfig): Array<LinkModel<Field>> => {
|
||||
if (!field.config.links || field.config.links.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const timeRangeUrl = locationUtil.getTimeRangeUrlParams();
|
||||
const { timeField } = getTimeField(frame);
|
||||
|
||||
return field.config.links.map((link: DataLink) => {
|
||||
const variablesQuery = locationUtil.getVariablesUrlParams();
|
||||
let dataFrameVars = {};
|
||||
let valueVars = {};
|
||||
return field.config.links.map((link: DataLink) => {
|
||||
const variablesQuery = locationUtil.getVariablesUrlParams();
|
||||
let dataFrameVars = {};
|
||||
let valueVars = {};
|
||||
|
||||
// We are not displaying reduction result
|
||||
if (config.valueRowIndex !== undefined && !isNaN(config.valueRowIndex)) {
|
||||
const fieldsProxy = getFieldDisplayValuesProxy({
|
||||
frame,
|
||||
rowIndex: config.valueRowIndex,
|
||||
timeZone: timeZone,
|
||||
});
|
||||
// We are not displaying reduction result
|
||||
if (config.valueRowIndex !== undefined && !isNaN(config.valueRowIndex)) {
|
||||
const fieldsProxy = getFieldDisplayValuesProxy({
|
||||
frame,
|
||||
rowIndex: config.valueRowIndex,
|
||||
timeZone: timeZone,
|
||||
});
|
||||
|
||||
valueVars = {
|
||||
raw: field.values.get(config.valueRowIndex),
|
||||
numeric: fieldsProxy[field.name].numeric,
|
||||
text: fieldsProxy[field.name].text,
|
||||
time: timeField ? timeField.values.get(config.valueRowIndex) : undefined,
|
||||
};
|
||||
valueVars = {
|
||||
raw: field.values.get(config.valueRowIndex),
|
||||
numeric: fieldsProxy[field.name].numeric,
|
||||
text: fieldsProxy[field.name].text,
|
||||
time: timeField ? timeField.values.get(config.valueRowIndex) : undefined,
|
||||
};
|
||||
|
||||
dataFrameVars = {
|
||||
__data: {
|
||||
value: {
|
||||
name: frame.name,
|
||||
refId: frame.refId,
|
||||
fields: fieldsProxy,
|
||||
dataFrameVars = {
|
||||
__data: {
|
||||
value: {
|
||||
name: frame.name,
|
||||
refId: frame.refId,
|
||||
fields: fieldsProxy,
|
||||
},
|
||||
text: 'Data',
|
||||
},
|
||||
text: 'Data',
|
||||
};
|
||||
} else {
|
||||
if (config.calculatedValue) {
|
||||
valueVars = {
|
||||
raw: config.calculatedValue.numeric,
|
||||
numeric: config.calculatedValue.numeric,
|
||||
text: formattedValueToString(config.calculatedValue),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const variables = {
|
||||
...fieldScopedVars,
|
||||
__value: {
|
||||
text: 'Value',
|
||||
value: valueVars,
|
||||
},
|
||||
...dataFrameVars,
|
||||
[DataLinkBuiltInVars.keepTime]: {
|
||||
text: timeRangeUrl,
|
||||
value: timeRangeUrl,
|
||||
},
|
||||
[DataLinkBuiltInVars.includeVars]: {
|
||||
text: variablesQuery,
|
||||
value: variablesQuery,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
if (config.calculatedValue) {
|
||||
valueVars = {
|
||||
raw: config.calculatedValue.numeric,
|
||||
numeric: config.calculatedValue.numeric,
|
||||
text: formattedValueToString(config.calculatedValue),
|
||||
|
||||
if (link.onClick) {
|
||||
return {
|
||||
href: link.url,
|
||||
title: replaceVariables(link.title || '', variables),
|
||||
target: link.targetBlank ? '_blank' : undefined,
|
||||
onClick: (evt, origin) => {
|
||||
link.onClick!({
|
||||
origin: origin ?? field,
|
||||
e: evt,
|
||||
replaceVariables: (v) => replaceVariables(v, variables),
|
||||
});
|
||||
},
|
||||
origin: field,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const variables = {
|
||||
...fieldScopedVars,
|
||||
__value: {
|
||||
text: 'Value',
|
||||
value: valueVars,
|
||||
},
|
||||
...dataFrameVars,
|
||||
[DataLinkBuiltInVars.keepTime]: {
|
||||
text: timeRangeUrl,
|
||||
value: timeRangeUrl,
|
||||
},
|
||||
[DataLinkBuiltInVars.includeVars]: {
|
||||
text: variablesQuery,
|
||||
value: variablesQuery,
|
||||
},
|
||||
};
|
||||
if (link.internal) {
|
||||
// For internal links at the moment only destination is Explore.
|
||||
return mapInternalLinkToExplore({
|
||||
link,
|
||||
internalLink: link.internal,
|
||||
scopedVars: variables,
|
||||
field,
|
||||
range: {} as any,
|
||||
replaceVariables,
|
||||
});
|
||||
}
|
||||
|
||||
if (link.onClick) {
|
||||
return {
|
||||
href: link.url,
|
||||
let href = locationUtil.assureBaseUrl(link.url.replace(/\n/g, ''));
|
||||
href = replaceVariables(href, variables);
|
||||
href = locationUtil.processUrl(href);
|
||||
|
||||
const info: LinkModel<Field> = {
|
||||
href,
|
||||
title: replaceVariables(link.title || '', variables),
|
||||
target: link.targetBlank ? '_blank' : undefined,
|
||||
onClick: (evt, origin) => {
|
||||
link.onClick!({
|
||||
origin: origin ?? field,
|
||||
e: evt,
|
||||
replaceVariables: (v) => replaceVariables(v, variables),
|
||||
});
|
||||
},
|
||||
origin: field,
|
||||
};
|
||||
}
|
||||
|
||||
if (link.internal) {
|
||||
// For internal links at the moment only destination is Explore.
|
||||
return mapInternalLinkToExplore({
|
||||
link,
|
||||
internalLink: link.internal,
|
||||
scopedVars: variables,
|
||||
field,
|
||||
range: {} as any,
|
||||
replaceVariables,
|
||||
});
|
||||
}
|
||||
|
||||
let href = locationUtil.assureBaseUrl(link.url.replace(/\n/g, ''));
|
||||
href = replaceVariables(href, variables);
|
||||
href = locationUtil.processUrl(href);
|
||||
|
||||
const info: LinkModel<Field> = {
|
||||
href,
|
||||
title: replaceVariables(link.title || '', variables),
|
||||
target: link.targetBlank ? '_blank' : undefined,
|
||||
origin: field,
|
||||
};
|
||||
return info;
|
||||
});
|
||||
};
|
||||
return info;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a copy of the DataFrame with raw data
|
||||
|
||||
@@ -47,13 +47,13 @@ function getBooleanScaleCalculator(field: Field, theme: GrafanaTheme2): ScaleCal
|
||||
const trueValue: ColorScaleValue = {
|
||||
color: theme.visualization.getColorByName('green'),
|
||||
percent: 1,
|
||||
threshold: (undefined as unknown) as Threshold,
|
||||
threshold: undefined as unknown as Threshold,
|
||||
};
|
||||
|
||||
const falseValue: ColorScaleValue = {
|
||||
color: theme.visualization.getColorByName('red'),
|
||||
percent: 0,
|
||||
threshold: (undefined as unknown) as Threshold,
|
||||
threshold: undefined as unknown as Threshold,
|
||||
};
|
||||
|
||||
const mode = getFieldColorModeForField(field);
|
||||
|
||||
@@ -4,47 +4,48 @@ import { map, mergeMap } from 'rxjs/operators';
|
||||
import { DataFrame, DataTransformerConfig } from '../types';
|
||||
import { standardTransformersRegistry, TransformerRegistryItem } from './standardTransformersRegistry';
|
||||
|
||||
const getOperator = (config: DataTransformerConfig): MonoTypeOperatorFunction<DataFrame[]> => (source) => {
|
||||
const info = standardTransformersRegistry.get(config.id);
|
||||
const getOperator =
|
||||
(config: DataTransformerConfig): MonoTypeOperatorFunction<DataFrame[]> =>
|
||||
(source) => {
|
||||
const info = standardTransformersRegistry.get(config.id);
|
||||
|
||||
if (!info) {
|
||||
return source;
|
||||
}
|
||||
if (!info) {
|
||||
return source;
|
||||
}
|
||||
|
||||
const defaultOptions = info.transformation.defaultOptions ?? {};
|
||||
const options = { ...defaultOptions, ...config.options };
|
||||
const defaultOptions = info.transformation.defaultOptions ?? {};
|
||||
const options = { ...defaultOptions, ...config.options };
|
||||
|
||||
return source.pipe(
|
||||
mergeMap((before) => of(before).pipe(info.transformation.operator(options), postProcessTransform(before, info)))
|
||||
);
|
||||
};
|
||||
return source.pipe(
|
||||
mergeMap((before) => of(before).pipe(info.transformation.operator(options), postProcessTransform(before, info)))
|
||||
);
|
||||
};
|
||||
|
||||
const postProcessTransform =
|
||||
(before: DataFrame[], info: TransformerRegistryItem<any>): MonoTypeOperatorFunction<DataFrame[]> =>
|
||||
(source) =>
|
||||
source.pipe(
|
||||
map((after) => {
|
||||
if (after === before) {
|
||||
return after;
|
||||
}
|
||||
|
||||
// Add a key to the metadata if the data changed
|
||||
for (const series of after) {
|
||||
if (!series.meta) {
|
||||
series.meta = {};
|
||||
}
|
||||
|
||||
if (!series.meta.transformations) {
|
||||
series.meta.transformations = [info.id];
|
||||
} else {
|
||||
series.meta.transformations = [...series.meta.transformations, info.id];
|
||||
}
|
||||
}
|
||||
|
||||
const postProcessTransform = (
|
||||
before: DataFrame[],
|
||||
info: TransformerRegistryItem<any>
|
||||
): MonoTypeOperatorFunction<DataFrame[]> => (source) =>
|
||||
source.pipe(
|
||||
map((after) => {
|
||||
if (after === before) {
|
||||
return after;
|
||||
}
|
||||
|
||||
// Add a key to the metadata if the data changed
|
||||
for (const series of after) {
|
||||
if (!series.meta) {
|
||||
series.meta = {};
|
||||
}
|
||||
|
||||
if (!series.meta.transformations) {
|
||||
series.meta.transformations = [info.id];
|
||||
} else {
|
||||
series.meta.transformations = [...series.meta.transformations, info.id];
|
||||
}
|
||||
}
|
||||
|
||||
return after;
|
||||
})
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* Apply configured transformations to the input data
|
||||
|
||||
@@ -210,7 +210,7 @@ function getBinaryCreator(options: BinaryOptions, allFrames: DataFrame[]): Value
|
||||
const left = findFieldValuesWithNameOrConstant(frame, options.left, allFrames);
|
||||
const right = findFieldValuesWithNameOrConstant(frame, options.right, allFrames);
|
||||
if (!left || !right || !operator) {
|
||||
return (undefined as unknown) as Vector;
|
||||
return undefined as unknown as Vector;
|
||||
}
|
||||
|
||||
return new BinaryOperationVector(left, right, operator.operation);
|
||||
|
||||
@@ -41,20 +41,17 @@ export const createOrderFieldsComparer = (indexByName: Record<string, number>) =
|
||||
return indexOfField(a, indexByName) - indexOfField(b, indexByName);
|
||||
};
|
||||
|
||||
const createFieldsOrderer = (indexByName: Record<string, number>) => (
|
||||
fields: Field[],
|
||||
data: DataFrame[],
|
||||
frame: DataFrame
|
||||
) => {
|
||||
if (!Array.isArray(fields) || fields.length === 0) {
|
||||
return fields;
|
||||
}
|
||||
if (!indexByName || Object.keys(indexByName).length === 0) {
|
||||
return fields;
|
||||
}
|
||||
const comparer = createOrderFieldsComparer(indexByName);
|
||||
return fields.sort((a, b) => comparer(getFieldDisplayName(a, frame, data), getFieldDisplayName(b, frame, data)));
|
||||
};
|
||||
const createFieldsOrderer =
|
||||
(indexByName: Record<string, number>) => (fields: Field[], data: DataFrame[], frame: DataFrame) => {
|
||||
if (!Array.isArray(fields) || fields.length === 0) {
|
||||
return fields;
|
||||
}
|
||||
if (!indexByName || Object.keys(indexByName).length === 0) {
|
||||
return fields;
|
||||
}
|
||||
const comparer = createOrderFieldsComparer(indexByName);
|
||||
return fields.sort((a, b) => comparer(getFieldDisplayName(a, frame, data), getFieldDisplayName(b, frame, data)));
|
||||
};
|
||||
|
||||
const indexOfField = (fieldName: string, indexByName: Record<string, number>) => {
|
||||
if (Number.isInteger(indexByName[fieldName])) {
|
||||
|
||||
@@ -192,7 +192,7 @@ export function mergeResults(data: DataFrame[]): DataFrame | undefined {
|
||||
if (isFirstField || isSameField) {
|
||||
const baseValues: any[] = baseField.values.toArray();
|
||||
const values: any[] = field.values.toArray();
|
||||
((baseField.values as unknown) as ArrayVector).buffer = baseValues.concat(values);
|
||||
(baseField.values as unknown as ArrayVector).buffer = baseValues.concat(values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,29 +37,31 @@ export const renameFieldsTransformer: DataTransformerInfo<RenameFieldsTransforme
|
||||
),
|
||||
};
|
||||
|
||||
const createRenamer = (renameByName: Record<string, string>) => (frame: DataFrame): Field[] => {
|
||||
if (!renameByName || Object.keys(renameByName).length === 0) {
|
||||
return frame.fields;
|
||||
}
|
||||
|
||||
return frame.fields.map((field) => {
|
||||
const displayName = getFieldDisplayName(field, frame);
|
||||
const renameTo = renameByName[displayName];
|
||||
|
||||
if (typeof renameTo !== 'string' || renameTo.length === 0) {
|
||||
return field;
|
||||
const createRenamer =
|
||||
(renameByName: Record<string, string>) =>
|
||||
(frame: DataFrame): Field[] => {
|
||||
if (!renameByName || Object.keys(renameByName).length === 0) {
|
||||
return frame.fields;
|
||||
}
|
||||
|
||||
return {
|
||||
...field,
|
||||
config: {
|
||||
...field.config,
|
||||
displayName: renameTo,
|
||||
},
|
||||
state: {
|
||||
...field.state,
|
||||
displayName: renameTo,
|
||||
},
|
||||
};
|
||||
});
|
||||
};
|
||||
return frame.fields.map((field) => {
|
||||
const displayName = getFieldDisplayName(field, frame);
|
||||
const renameTo = renameByName[displayName];
|
||||
|
||||
if (typeof renameTo !== 'string' || renameTo.length === 0) {
|
||||
return field;
|
||||
}
|
||||
|
||||
return {
|
||||
...field,
|
||||
config: {
|
||||
...field.config,
|
||||
displayName: renameTo,
|
||||
},
|
||||
state: {
|
||||
...field.state,
|
||||
displayName: renameTo,
|
||||
},
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -79,7 +79,8 @@ export abstract class OptionsUIRegistryBuilder<
|
||||
TOptions,
|
||||
TEditorProps,
|
||||
T extends OptionsEditorItem<TOptions, any, TEditorProps, any>
|
||||
> implements OptionsUIRegistryBuilderAPI<TOptions, TEditorProps, T> {
|
||||
> implements OptionsUIRegistryBuilderAPI<TOptions, TEditorProps, T>
|
||||
{
|
||||
private properties: T[] = [];
|
||||
|
||||
addCustomEditor<TSettings, TValue>(config: T & OptionsEditorItem<TOptions, TSettings, TEditorProps, TValue>): this {
|
||||
|
||||
@@ -41,52 +41,47 @@ export function getDataSourceUID(ref: DataSourceRef | string | null): string | u
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export const onUpdateDatasourceOption = (props: DataSourcePluginOptionsEditorProps, key: keyof DataSourceSettings) => (
|
||||
event: React.SyntheticEvent<HTMLInputElement | HTMLSelectElement>
|
||||
) => {
|
||||
updateDatasourcePluginOption(props, key, event.currentTarget.value);
|
||||
};
|
||||
export const onUpdateDatasourceOption =
|
||||
(props: DataSourcePluginOptionsEditorProps, key: keyof DataSourceSettings) =>
|
||||
(event: React.SyntheticEvent<HTMLInputElement | HTMLSelectElement>) => {
|
||||
updateDatasourcePluginOption(props, key, event.currentTarget.value);
|
||||
};
|
||||
|
||||
export const onUpdateDatasourceJsonDataOption = <J, S, K extends keyof J>(
|
||||
props: DataSourcePluginOptionsEditorProps<J, S>,
|
||||
key: K
|
||||
) => (event: React.SyntheticEvent<HTMLInputElement | HTMLSelectElement>) => {
|
||||
updateDatasourcePluginJsonDataOption(props, key, event.currentTarget.value);
|
||||
};
|
||||
export const onUpdateDatasourceJsonDataOption =
|
||||
<J, S, K extends keyof J>(props: DataSourcePluginOptionsEditorProps<J, S>, key: K) =>
|
||||
(event: React.SyntheticEvent<HTMLInputElement | HTMLSelectElement>) => {
|
||||
updateDatasourcePluginJsonDataOption(props, key, event.currentTarget.value);
|
||||
};
|
||||
|
||||
export const onUpdateDatasourceSecureJsonDataOption = <J, S extends {} = KeyValue>(
|
||||
props: DataSourcePluginOptionsEditorProps<J, S>,
|
||||
key: string
|
||||
) => (event: React.SyntheticEvent<HTMLInputElement | HTMLSelectElement>) => {
|
||||
updateDatasourcePluginSecureJsonDataOption(props, key, event.currentTarget.value);
|
||||
};
|
||||
export const onUpdateDatasourceSecureJsonDataOption =
|
||||
<J, S extends {} = KeyValue>(props: DataSourcePluginOptionsEditorProps<J, S>, key: string) =>
|
||||
(event: React.SyntheticEvent<HTMLInputElement | HTMLSelectElement>) => {
|
||||
updateDatasourcePluginSecureJsonDataOption(props, key, event.currentTarget.value);
|
||||
};
|
||||
|
||||
export const onUpdateDatasourceJsonDataOptionSelect = <J, S, K extends keyof J>(
|
||||
props: DataSourcePluginOptionsEditorProps<J, S>,
|
||||
key: K
|
||||
) => (selected: SelectableValue) => {
|
||||
updateDatasourcePluginJsonDataOption(props, key, selected.value);
|
||||
};
|
||||
export const onUpdateDatasourceJsonDataOptionSelect =
|
||||
<J, S, K extends keyof J>(props: DataSourcePluginOptionsEditorProps<J, S>, key: K) =>
|
||||
(selected: SelectableValue) => {
|
||||
updateDatasourcePluginJsonDataOption(props, key, selected.value);
|
||||
};
|
||||
|
||||
export const onUpdateDatasourceJsonDataOptionChecked = <J, S, K extends keyof J>(
|
||||
props: DataSourcePluginOptionsEditorProps<J, S>,
|
||||
key: K
|
||||
) => (event: React.SyntheticEvent<HTMLInputElement>) => {
|
||||
updateDatasourcePluginJsonDataOption(props, key, event.currentTarget.checked);
|
||||
};
|
||||
export const onUpdateDatasourceJsonDataOptionChecked =
|
||||
<J, S, K extends keyof J>(props: DataSourcePluginOptionsEditorProps<J, S>, key: K) =>
|
||||
(event: React.SyntheticEvent<HTMLInputElement>) => {
|
||||
updateDatasourcePluginJsonDataOption(props, key, event.currentTarget.checked);
|
||||
};
|
||||
|
||||
export const onUpdateDatasourceSecureJsonDataOptionSelect = <J, S extends {} = KeyValue>(
|
||||
props: DataSourcePluginOptionsEditorProps<J, S>,
|
||||
key: string
|
||||
) => (selected: SelectableValue) => {
|
||||
updateDatasourcePluginSecureJsonDataOption(props, key, selected.value);
|
||||
};
|
||||
export const onUpdateDatasourceSecureJsonDataOptionSelect =
|
||||
<J, S extends {} = KeyValue>(props: DataSourcePluginOptionsEditorProps<J, S>, key: string) =>
|
||||
(selected: SelectableValue) => {
|
||||
updateDatasourcePluginSecureJsonDataOption(props, key, selected.value);
|
||||
};
|
||||
|
||||
export const onUpdateDatasourceResetOption = (props: DataSourcePluginOptionsEditorProps, key: string) => (
|
||||
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
|
||||
) => {
|
||||
updateDatasourcePluginResetOption(props, key);
|
||||
};
|
||||
export const onUpdateDatasourceResetOption =
|
||||
(props: DataSourcePluginOptionsEditorProps, key: string) =>
|
||||
(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
|
||||
updateDatasourcePluginResetOption(props, key);
|
||||
};
|
||||
|
||||
export function updateDatasourcePluginOption<J, S extends {} = KeyValue>(
|
||||
props: DataSourcePluginOptionsEditorProps<J, S>,
|
||||
|
||||
@@ -73,6 +73,6 @@ describe('matchAllLabels()', () => {
|
||||
});
|
||||
|
||||
it('be graceful with null values (match)', () => {
|
||||
expect(matchAllLabels((undefined as unknown) as Labels, { foo: 'bar' })).toBeTruthy();
|
||||
expect(matchAllLabels(undefined as unknown as Labels, { foo: 'bar' })).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -45,7 +45,7 @@ export function findCommonLabels(labelsSets: Labels[]): Labels {
|
||||
});
|
||||
}
|
||||
return acc;
|
||||
}, (undefined as unknown) as Labels);
|
||||
}, undefined as unknown as Labels);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -358,12 +358,12 @@ describe('sortLogsResult', () => {
|
||||
});
|
||||
|
||||
describe('checkLogsError()', () => {
|
||||
const log = ({
|
||||
const log = {
|
||||
labels: {
|
||||
__error__: 'Error Message',
|
||||
foo: 'boo',
|
||||
},
|
||||
} as any) as LogRowModel;
|
||||
} as any as LogRowModel;
|
||||
test('should return correct error if error is present', () => {
|
||||
expect(checkLogsError(log)).toStrictEqual({ hasError: true, errorMessage: 'Error Message' });
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Proxies a ES6 class so that it can be used as a base class for an ES5 class
|
||||
*/
|
||||
export function makeClassES5Compatible<T>(ES6Class: T): T {
|
||||
return (new Proxy(ES6Class as any, {
|
||||
return new Proxy(ES6Class as any, {
|
||||
// ES5 code will call it like a function using super
|
||||
apply(target, self, argumentsList) {
|
||||
if (typeof Reflect === 'undefined' || !Reflect.construct) {
|
||||
@@ -12,5 +12,5 @@ export function makeClassES5Compatible<T>(ES6Class: T): T {
|
||||
|
||||
return Reflect.construct(target, argumentsList, self.constructor);
|
||||
},
|
||||
}) as unknown) as T;
|
||||
}) as unknown as T;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
import { GrafanaTheme, GrafanaThemeType } from '../../types/theme';
|
||||
|
||||
export function getTestTheme(type: GrafanaThemeType = GrafanaThemeType.Dark): GrafanaTheme {
|
||||
return ({
|
||||
return {
|
||||
type,
|
||||
isDark: type === GrafanaThemeType.Dark,
|
||||
isLight: type === GrafanaThemeType.Light,
|
||||
colors: {
|
||||
panelBg: 'white',
|
||||
},
|
||||
} as unknown) as GrafanaTheme;
|
||||
} as unknown as GrafanaTheme;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export class AppendedVectors<T = any> implements Vector<T> {
|
||||
return src.values.get(index - src.start);
|
||||
}
|
||||
}
|
||||
return (undefined as unknown) as T;
|
||||
return undefined as unknown as T;
|
||||
}
|
||||
|
||||
toArray(): T[] {
|
||||
|
||||
@@ -80,7 +80,7 @@ const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, sele
|
||||
e2eObjects[key] = function (textOrOptions?: string | CypressOptions, options?: CypressOptions) {
|
||||
// the input can only be ()
|
||||
if (arguments.length === 0) {
|
||||
const selector = value((undefined as unknown) as string);
|
||||
const selector = value(undefined as unknown as string);
|
||||
|
||||
logOutput(selector);
|
||||
return e2e().get(selector);
|
||||
@@ -97,7 +97,7 @@ const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, sele
|
||||
logOutput(selector);
|
||||
return e2e().get(selector);
|
||||
}
|
||||
const selector = value((undefined as unknown) as string);
|
||||
const selector = value(undefined as unknown as string);
|
||||
|
||||
logOutput(selector);
|
||||
return e2e().get(selector, textOrOptions);
|
||||
|
||||
@@ -19,11 +19,11 @@ class MyDataSource extends DataSourceWithBackend<DataQuery, DataSourceJsonData>
|
||||
|
||||
const mockDatasourceRequest = jest.fn();
|
||||
|
||||
const backendSrv = ({
|
||||
const backendSrv = {
|
||||
fetch: (options: BackendSrvRequest) => {
|
||||
return of(mockDatasourceRequest(options));
|
||||
},
|
||||
} as unknown) as BackendSrv;
|
||||
} as unknown as BackendSrv;
|
||||
|
||||
jest.mock('../services', () => ({
|
||||
...(jest.requireActual('../services') as any),
|
||||
|
||||
@@ -2,7 +2,7 @@ import { DataQuery, toDataFrameDTO, DataFrame } from '@grafana/data';
|
||||
import { FetchError, FetchResponse } from 'src/services';
|
||||
import { BackendDataSourceResponse, toDataQueryResponse, toTestingStatus } from './queryResponse';
|
||||
|
||||
const resp = ({
|
||||
const resp = {
|
||||
data: {
|
||||
results: {
|
||||
A: {
|
||||
@@ -45,9 +45,9 @@ const resp = ({
|
||||
},
|
||||
},
|
||||
},
|
||||
} as any) as FetchResponse<BackendDataSourceResponse>;
|
||||
} as any as FetchResponse<BackendDataSourceResponse>;
|
||||
|
||||
const resWithError = ({
|
||||
const resWithError = {
|
||||
data: {
|
||||
results: {
|
||||
A: {
|
||||
@@ -73,7 +73,7 @@ const resWithError = ({
|
||||
},
|
||||
},
|
||||
},
|
||||
} as any) as FetchResponse<BackendDataSourceResponse>;
|
||||
} as any as FetchResponse<BackendDataSourceResponse>;
|
||||
|
||||
const emptyResults = {
|
||||
data: { results: { '': { refId: '' } } },
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
"@babel/core": "7.13.14",
|
||||
"@babel/preset-env": "7.13.12",
|
||||
"@grafana/data": "8.4.0-pre",
|
||||
"@grafana/eslint-config": "2.5.1",
|
||||
"@grafana/eslint-config": "2.5.2",
|
||||
"@grafana/tsconfig": "^1.0.0-rc1",
|
||||
"@grafana/ui": "8.4.0-pre",
|
||||
"@jest/core": "26.6.3",
|
||||
@@ -85,7 +85,7 @@
|
||||
"postcss-flexbugs-fixes": "4.2.0",
|
||||
"postcss-loader": "3.0.0",
|
||||
"postcss-preset-env": "6.7.0",
|
||||
"prettier": "^2.2.1",
|
||||
"prettier": "2.5.1",
|
||||
"react-dev-utils": "^11.0.4",
|
||||
"replace-in-file": "^4.1.0",
|
||||
"replace-in-file-webpack-plugin": "^1.0.6",
|
||||
|
||||
@@ -7,17 +7,19 @@ interface TaskBasicOptions {
|
||||
silent?: boolean;
|
||||
}
|
||||
|
||||
export const execTask = <TOptions>(task: Task<TOptions>) => async (options: TOptions & TaskBasicOptions) => {
|
||||
if (!options.silent) {
|
||||
console.log(chalk.yellow(`Running ${chalk.bold(task.name)} task`));
|
||||
}
|
||||
task.setOptions(options);
|
||||
try {
|
||||
console.group();
|
||||
await task.exec();
|
||||
console.groupEnd();
|
||||
} catch (e) {
|
||||
console.trace(e);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
export const execTask =
|
||||
<TOptions>(task: Task<TOptions>) =>
|
||||
async (options: TOptions & TaskBasicOptions) => {
|
||||
if (!options.silent) {
|
||||
console.log(chalk.yellow(`Running ${chalk.bold(task.name)} task`));
|
||||
}
|
||||
task.setOptions(options);
|
||||
try {
|
||||
console.group();
|
||||
await task.exec();
|
||||
console.groupEnd();
|
||||
} catch (e) {
|
||||
console.trace(e);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -87,7 +87,7 @@ describe('BarGauge', () => {
|
||||
|
||||
it('does not show as lit if the value is null (somehow)', () => {
|
||||
const props = getProps();
|
||||
expect(getCellColor(1, (null as unknown) as DisplayValue, props.display)).toEqual(
|
||||
expect(getCellColor(1, null as unknown as DisplayValue, props.display)).toEqual(
|
||||
expect.objectContaining({
|
||||
isLit: false,
|
||||
})
|
||||
|
||||
@@ -126,14 +126,8 @@ export class BarGauge extends PureComponent<Props> {
|
||||
|
||||
renderRetroBars(): ReactNode {
|
||||
const { display, field, value, itemSpacing, alignmentFactors, orientation, lcdCellWidth, text } = this.props;
|
||||
const {
|
||||
valueHeight,
|
||||
valueWidth,
|
||||
maxBarHeight,
|
||||
maxBarWidth,
|
||||
wrapperWidth,
|
||||
wrapperHeight,
|
||||
} = calculateBarAndValueDimensions(this.props);
|
||||
const { valueHeight, valueWidth, maxBarHeight, maxBarWidth, wrapperWidth, wrapperHeight } =
|
||||
calculateBarAndValueDimensions(this.props);
|
||||
const minValue = field.min ?? GAUGE_DEFAULT_MINIMUM;
|
||||
const maxValue = field.max ?? GAUGE_DEFAULT_MAXIMUM;
|
||||
|
||||
|
||||
@@ -28,6 +28,6 @@ const fromRCOptions = (options: RCCascaderOption[]): CascaderOption[] => {
|
||||
const fromRCOption = (option: RCCascaderOption): CascaderOption => {
|
||||
return {
|
||||
value: option.value ?? '',
|
||||
label: (option.label as unknown) as string,
|
||||
label: option.label as unknown as string,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -87,9 +87,10 @@ export const DataLinkInput: React.FC<DataLinkInputProps> = memo(
|
||||
|
||||
// Used to get the height of the suggestion elements in order to scroll to them.
|
||||
const activeRef = useRef<HTMLDivElement>(null);
|
||||
const activeIndexPosition = useMemo(() => getElementPosition(activeRef.current, suggestionsIndex), [
|
||||
suggestionsIndex,
|
||||
]);
|
||||
const activeIndexPosition = useMemo(
|
||||
() => getElementPosition(activeRef.current, suggestionsIndex),
|
||||
[suggestionsIndex]
|
||||
);
|
||||
|
||||
// SelectionReference is used to position the variables suggestion relatively to current DOM selection
|
||||
const selectionRef = useMemo(() => new SelectionReference(), []);
|
||||
|
||||
+2
-2
@@ -55,7 +55,7 @@ describe('DataLinksListItem', () => {
|
||||
it('then the link title should be replaced by [Data link title not provided]', () => {
|
||||
const link = {
|
||||
...baseLink,
|
||||
title: (undefined as unknown) as string,
|
||||
title: undefined as unknown as string,
|
||||
};
|
||||
setupTestContext({ link });
|
||||
|
||||
@@ -67,7 +67,7 @@ describe('DataLinksListItem', () => {
|
||||
it('then the link url should be replaced by [Data link url not provided]', () => {
|
||||
const link = {
|
||||
...baseLink,
|
||||
url: (undefined as unknown) as string,
|
||||
url: undefined as unknown as string,
|
||||
};
|
||||
setupTestContext({ link });
|
||||
|
||||
|
||||
@@ -232,11 +232,13 @@ Consider this function that simulates a call to some service. Remember, if you w
|
||||
```jsx
|
||||
validateAsync = (newValue: string) => {
|
||||
try {
|
||||
await new Promise<ValidateResult>((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
reject('Something went wrong...');
|
||||
}, 2000);
|
||||
});
|
||||
(await new Promise()) <
|
||||
ValidateResult >
|
||||
((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
reject('Something went wrong...');
|
||||
}, 2000);
|
||||
});
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
|
||||
@@ -5,7 +5,8 @@ import { isObject, getObjectName, getType, getValuePreview, cssClass, createElem
|
||||
|
||||
import { isNumber } from 'lodash';
|
||||
|
||||
const DATE_STRING_REGEX = /(^\d{1,4}[\.|\\/|-]\d{1,2}[\.|\\/|-]\d{1,4})(\s*(?:0?[1-9]:[0-5]|1(?=[012])\d:[0-5])\d\s*[ap]m)?$/;
|
||||
const DATE_STRING_REGEX =
|
||||
/(^\d{1,4}[\.|\\/|-]\d{1,2}[\.|\\/|-]\d{1,4})(\s*(?:0?[1-9]:[0-5]|1(?=[012])\d:[0-5])\d\s*[ap]m)?$/;
|
||||
const PARTIAL_DATE_REGEX = /\d{2}:\d{2}:\d{2} GMT-\d{4}/;
|
||||
const JSON_DATE_REGEX = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/;
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ const row: LogRowModel = {
|
||||
rowIndex: 0,
|
||||
dataFrame: new MutableDataFrame(),
|
||||
entry: '4',
|
||||
labels: (null as any) as Labels,
|
||||
labels: null as any as Labels,
|
||||
hasAnsi: false,
|
||||
hasUnescapedContent: false,
|
||||
raw: '4',
|
||||
|
||||
@@ -143,7 +143,7 @@ export const LogRowContextProvider: React.FunctionComponent<LogRowContextProvide
|
||||
// React Hook that creates an object state value called result to component state and a setter function called setResult
|
||||
// The initial value for result is null
|
||||
// Used for sorting the response from backend
|
||||
const [result, setResult] = useState<ResultType>((null as any) as ResultType);
|
||||
const [result, setResult] = useState<ResultType>(null as any as ResultType);
|
||||
|
||||
// React Hook that creates an object state value called hasMoreContextRows to component state and a setter function called setHasMoreContextRows
|
||||
// The initial value for hasMoreContextRows is {before: true, after: true}
|
||||
|
||||
@@ -231,7 +231,7 @@ describe('sharedSingleStatMigrationHandler', () => {
|
||||
});
|
||||
|
||||
it('auto set min/max for percent units before 8.0', () => {
|
||||
const panel = ({
|
||||
const panel = {
|
||||
options: {
|
||||
fieldOptions: {
|
||||
defaults: {
|
||||
@@ -241,7 +241,7 @@ describe('sharedSingleStatMigrationHandler', () => {
|
||||
},
|
||||
title: 'Usage',
|
||||
type: 'bargauge',
|
||||
} as unknown) as PanelModel;
|
||||
} as unknown as PanelModel;
|
||||
sharedSingleStatMigrationHandler(panel as any);
|
||||
expect(panel.fieldConfig.defaults.unit).toBe('percentunit');
|
||||
expect(panel.fieldConfig.defaults.min).toBe(0);
|
||||
|
||||
@@ -165,12 +165,10 @@ export const Table: FC<Props> = memo((props: Props) => {
|
||||
}, [data]);
|
||||
|
||||
// React-table column definitions
|
||||
const memoizedColumns = useMemo(() => getColumns(data, width, columnMinWidth, footerValues), [
|
||||
data,
|
||||
width,
|
||||
columnMinWidth,
|
||||
footerValues,
|
||||
]);
|
||||
const memoizedColumns = useMemo(
|
||||
() => getColumns(data, width, columnMinWidth, footerValues),
|
||||
[data, width, columnMinWidth, footerValues]
|
||||
);
|
||||
|
||||
// Internal react table state reducer
|
||||
const stateReducer = useTableStateReducer(props);
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface Props {
|
||||
|
||||
export const TableCell: FC<Props> = ({ cell, tableStyles, onCellFilterAdded, columnIndex, columnCount }) => {
|
||||
const cellProps = cell.getCellProps();
|
||||
const field = ((cell.column as any) as GrafanaTableColumn).field;
|
||||
const field = (cell.column as any as GrafanaTableColumn).field;
|
||||
|
||||
if (!field.display) {
|
||||
return null;
|
||||
|
||||
@@ -175,7 +175,7 @@ export class UPlotConfigBuilder {
|
||||
mode: this.mode,
|
||||
series: [
|
||||
this.mode === 2
|
||||
? ((null as unknown) as Series)
|
||||
? (null as unknown as Series)
|
||||
: {
|
||||
value: () => '',
|
||||
},
|
||||
@@ -191,18 +191,20 @@ export class UPlotConfigBuilder {
|
||||
|
||||
config.select = this.select;
|
||||
|
||||
const pointColorFn = (alphaHex = '') => (u: uPlot, seriesIdx: number) => {
|
||||
/*@ts-ignore*/
|
||||
let s = u.series[seriesIdx].points._stroke;
|
||||
const pointColorFn =
|
||||
(alphaHex = '') =>
|
||||
(u: uPlot, seriesIdx: number) => {
|
||||
/*@ts-ignore*/
|
||||
let s = u.series[seriesIdx].points._stroke;
|
||||
|
||||
// interpolate for gradients/thresholds
|
||||
if (typeof s !== 'string') {
|
||||
let field = this.frames![0].fields[seriesIdx];
|
||||
s = field.display!(field.values.get(u.cursor.idxs![seriesIdx]!)).color!;
|
||||
}
|
||||
// interpolate for gradients/thresholds
|
||||
if (typeof s !== 'string') {
|
||||
let field = this.frames![0].fields[seriesIdx];
|
||||
s = field.display!(field.values.get(u.cursor.idxs![seriesIdx]!)).color!;
|
||||
}
|
||||
|
||||
return s + alphaHex;
|
||||
};
|
||||
return s + alphaHex;
|
||||
};
|
||||
|
||||
config.cursor = merge(
|
||||
{},
|
||||
|
||||
@@ -54,7 +54,8 @@ class Options
|
||||
getSyntax: defaultGetSyntax,
|
||||
renderDecoration: defaultRenderDecoration,
|
||||
})
|
||||
implements OptionsFormat {
|
||||
implements OptionsFormat
|
||||
{
|
||||
declare readonly onlyIn: (node: Node) => boolean;
|
||||
declare readonly getSyntax: (node: Node) => string;
|
||||
declare readonly renderDecoration: (
|
||||
|
||||
@@ -48,6 +48,5 @@ export const renderComponentWithTheme = (component: React.ComponentType<any>, pr
|
||||
};
|
||||
|
||||
// eslint-disable-next-line react/display-name
|
||||
export const withTheme = (handleSassThemeChange: SassThemeChangeHandler) => (story: RenderFunction) => (
|
||||
<ThemeableStory handleSassThemeChange={handleSassThemeChange}>{story()}</ThemeableStory>
|
||||
);
|
||||
export const withTheme = (handleSassThemeChange: SassThemeChangeHandler) => (story: RenderFunction) =>
|
||||
<ThemeableStory handleSassThemeChange={handleSassThemeChange}>{story()}</ThemeableStory>;
|
||||
|
||||
Reference in New Issue
Block a user