Revert "Update dependency prettier to v3 (#71586)" (#71755)

This reverts commit 2e8cd1c021.
This commit is contained in:
Ashley Harrison 2023-07-17 14:46:15 +01:00 committed by GitHub
parent 8c6cdf51fc
commit 5ca382c88a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
93 changed files with 378 additions and 565 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "prettier", "name": "prettier",
"version": "3.0.0-sdk", "version": "2.8.4-sdk",
"main": "./index.js", "main": "./index.js",
"type": "commonjs" "type": "commonjs"
} }

View File

@ -92,62 +92,26 @@ const addAzureMonitorVariable = (
.type(`${type.replace('Azure', '').trim()}{enter}`); .type(`${type.replace('Azure', '').trim()}{enter}`);
switch (type) { switch (type) {
case AzureQueryType.ResourceGroupsQuery: case AzureQueryType.ResourceGroupsQuery:
e2eSelectors.variableEditor.subscription e2eSelectors.variableEditor.subscription.input().find('input').type(`${options?.subscription}{enter}`);
.input()
.find('input')
.type(`${options?.subscription}{enter}`);
break; break;
case AzureQueryType.LocationsQuery: case AzureQueryType.LocationsQuery:
e2eSelectors.variableEditor.subscription e2eSelectors.variableEditor.subscription.input().find('input').type(`${options?.subscription}{enter}`);
.input()
.find('input')
.type(`${options?.subscription}{enter}`);
break; break;
case AzureQueryType.NamespacesQuery: case AzureQueryType.NamespacesQuery:
e2eSelectors.variableEditor.subscription e2eSelectors.variableEditor.subscription.input().find('input').type(`${options?.subscription}{enter}`);
.input() e2eSelectors.variableEditor.resourceGroup.input().find('input').type(`${options?.resourceGroup}{enter}`);
.find('input')
.type(`${options?.subscription}{enter}`);
e2eSelectors.variableEditor.resourceGroup
.input()
.find('input')
.type(`${options?.resourceGroup}{enter}`);
break; break;
case AzureQueryType.ResourceNamesQuery: case AzureQueryType.ResourceNamesQuery:
e2eSelectors.variableEditor.subscription e2eSelectors.variableEditor.subscription.input().find('input').type(`${options?.subscription}{enter}`);
.input() e2eSelectors.variableEditor.resourceGroup.input().find('input').type(`${options?.resourceGroup}{enter}`);
.find('input') e2eSelectors.variableEditor.namespace.input().find('input').type(`${options?.namespace}{enter}`);
.type(`${options?.subscription}{enter}`); e2eSelectors.variableEditor.region.input().find('input').type(`${options?.region}{enter}`);
e2eSelectors.variableEditor.resourceGroup
.input()
.find('input')
.type(`${options?.resourceGroup}{enter}`);
e2eSelectors.variableEditor.namespace
.input()
.find('input')
.type(`${options?.namespace}{enter}`);
e2eSelectors.variableEditor.region
.input()
.find('input')
.type(`${options?.region}{enter}`);
break; break;
case AzureQueryType.MetricNamesQuery: case AzureQueryType.MetricNamesQuery:
e2eSelectors.variableEditor.subscription e2eSelectors.variableEditor.subscription.input().find('input').type(`${options?.subscription}{enter}`);
.input() e2eSelectors.variableEditor.resourceGroup.input().find('input').type(`${options?.resourceGroup}{enter}`);
.find('input') e2eSelectors.variableEditor.namespace.input().find('input').type(`${options?.namespace}{enter}`);
.type(`${options?.subscription}{enter}`); e2eSelectors.variableEditor.resource.input().find('input').type(`${options?.resource}{enter}`);
e2eSelectors.variableEditor.resourceGroup
.input()
.find('input')
.type(`${options?.resourceGroup}{enter}`);
e2eSelectors.variableEditor.namespace
.input()
.find('input')
.type(`${options?.namespace}{enter}`);
e2eSelectors.variableEditor.resource
.input()
.find('input')
.type(`${options?.resource}{enter}`);
break; break;
} }
e2e.pages.Dashboard.Settings.Variables.Edit.General.submitButton().click(); e2e.pages.Dashboard.Settings.Variables.Edit.General.submitButton().click();

View File

@ -31,8 +31,8 @@
"packages:pack": "mkdir -p ./npm-artifacts && lerna exec --no-private -- yarn pack --out \"../../npm-artifacts/%s-%v.tgz\"", "packages:pack": "mkdir -p ./npm-artifacts && lerna exec --no-private -- yarn pack --out \"../../npm-artifacts/%s-%v.tgz\"",
"packages:typecheck": "lerna run typecheck", "packages:typecheck": "lerna run typecheck",
"precommit": "yarn run lint-staged", "precommit": "yarn run lint-staged",
"prettier:check": "prettier --check --list-different=false --log-level=warn \"**/*.{ts,tsx,scss,md,mdx}\"", "prettier:check": "prettier --check --list-different=false --loglevel=warn \"**/*.{ts,tsx,scss,md,mdx}\"",
"prettier:checkDocs": "prettier --check --list-different=false --log-level=warn \"docs/**/*.md\" \"*.md\" \"packages/**/*.{ts,tsx,scss,md,mdx}\"", "prettier:checkDocs": "prettier --check --list-different=false --loglevel=warn \"docs/**/*.md\" \"*.md\" \"packages/**/*.{ts,tsx,scss,md,mdx}\"",
"prettier:write": "prettier --list-different \"**/*.{js,ts,tsx,scss,md,mdx}\" --write", "prettier:write": "prettier --list-different \"**/*.{js,ts,tsx,scss,md,mdx}\" --write",
"start": "yarn themes:generate && yarn dev --watch", "start": "yarn themes:generate && yarn dev --watch",
"start:noTsCheck": "yarn start --env noTsCheck=1", "start:noTsCheck": "yarn start --env noTsCheck=1",
@ -223,7 +223,7 @@
"postcss-loader": "7.3.3", "postcss-loader": "7.3.3",
"postcss-reporter": "7.0.5", "postcss-reporter": "7.0.5",
"postcss-scss": "4.0.6", "postcss-scss": "4.0.6",
"prettier": "3.0.0", "prettier": "2.8.4",
"react-refresh": "0.14.0", "react-refresh": "0.14.0",
"react-select-event": "5.5.1", "react-select-event": "5.5.1",
"react-simple-compat": "1.2.3", "react-simple-compat": "1.2.3",

View File

@ -113,11 +113,7 @@ class ScopedEventBus implements EventBus {
filterConfig: EventFilterOptions; filterConfig: EventFilterOptions;
// The path is not yet exposed, but can be used to indicate nested groups and support faster filtering // The path is not yet exposed, but can be used to indicate nested groups and support faster filtering
constructor( constructor(public path: string[], private eventBus: EventBus, filter?: EventFilterOptions) {
public path: string[],
private eventBus: EventBus,
filter?: EventFilterOptions
) {
this.filterConfig = filter ?? { onlyLocal: false }; this.filterConfig = filter ?? { onlyLocal: false };
} }

View File

@ -94,7 +94,7 @@ export type PanelOptionsSupplier<TOptions> = (
export class PanelPlugin< export class PanelPlugin<
TOptions = any, TOptions = any,
TFieldConfigOptions extends object = any, TFieldConfigOptions extends object = any
> extends GrafanaPlugin<PanelPluginMeta> { > extends GrafanaPlugin<PanelPluginMeta> {
private _defaults?: TOptions; private _defaults?: TOptions;
private _fieldConfigDefaults: FieldConfigSource<TFieldConfigOptions> = { private _fieldConfigDefaults: FieldConfigSource<TFieldConfigOptions> = {

View File

@ -33,7 +33,7 @@ export interface OptionsEditorItem<TOptions, TSettings, TEditorProps, TValue>
export interface OptionsUIRegistryBuilderAPI< export interface OptionsUIRegistryBuilderAPI<
TOptions, TOptions,
TEditorProps, TEditorProps,
T extends OptionsEditorItem<TOptions, any, TEditorProps, any>, T extends OptionsEditorItem<TOptions, any, TEditorProps, any>
> { > {
addNumberInput?<TSettings extends NumberFieldConfigSettings = NumberFieldConfigSettings>( addNumberInput?<TSettings extends NumberFieldConfigSettings = NumberFieldConfigSettings>(
config: OptionEditorConfig<TOptions, TSettings, number> config: OptionEditorConfig<TOptions, TSettings, number>
@ -80,7 +80,7 @@ export interface OptionsUIRegistryBuilderAPI<
export abstract class OptionsUIRegistryBuilder< export abstract class OptionsUIRegistryBuilder<
TOptions, TOptions,
TEditorProps, TEditorProps,
T extends OptionsEditorItem<TOptions, any, TEditorProps, any>, T extends OptionsEditorItem<TOptions, any, TEditorProps, any>
> implements OptionsUIRegistryBuilderAPI<TOptions, TEditorProps, T> > implements OptionsUIRegistryBuilderAPI<TOptions, TEditorProps, T>
{ {
private properties: T[] = []; private properties: T[] = [];

View File

@ -18,7 +18,7 @@ import { DataSourceRef, WithAccessControlMetadata } from '.';
export interface DataSourcePluginOptionsEditorProps< export interface DataSourcePluginOptionsEditorProps<
JSONData extends DataSourceJsonData = DataSourceJsonData, JSONData extends DataSourceJsonData = DataSourceJsonData,
SecureJSONData = {}, SecureJSONData = {}
> { > {
options: DataSourceSettings<JSONData, SecureJSONData>; options: DataSourceSettings<JSONData, SecureJSONData>;
onOptionsChange: (options: DataSourceSettings<JSONData, SecureJSONData>) => void; onOptionsChange: (options: DataSourceSettings<JSONData, SecureJSONData>) => void;
@ -34,7 +34,7 @@ export class DataSourcePlugin<
DSType extends DataSourceApi<TQuery, TOptions>, DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataSourceQueryType<DSType>, TQuery extends DataQuery = DataSourceQueryType<DSType>,
TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>, TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>,
TSecureOptions = {}, TSecureOptions = {}
> extends GrafanaPlugin<DataSourcePluginMeta<TOptions>> { > extends GrafanaPlugin<DataSourcePluginMeta<TOptions>> {
components: DataSourcePluginComponents<DSType, TQuery, TOptions, TSecureOptions> = {}; components: DataSourcePluginComponents<DSType, TQuery, TOptions, TSecureOptions> = {};
@ -155,7 +155,7 @@ export interface DataSourcePluginComponents<
DSType extends DataSourceApi<TQuery, TOptions>, DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData,
TSecureOptions = {}, TSecureOptions = {}
> { > {
QueryCtrl?: any; QueryCtrl?: any;
AnnotationsQueryCtrl?: any; AnnotationsQueryCtrl?: any;
@ -176,7 +176,7 @@ export interface DataSourcePluginComponents<
export interface DataSourceConstructor< export interface DataSourceConstructor<
DSType extends DataSourceApi<TQuery, TOptions>, DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
> { > {
new (instanceSettings: DataSourceInstanceSettings<TOptions>, ...args: any[]): DSType; new (instanceSettings: DataSourceInstanceSettings<TOptions>, ...args: any[]): DSType;
} }
@ -197,7 +197,7 @@ type VariableSupport<TQuery extends DataQuery, TOptions extends DataSourceJsonDa
abstract class DataSourceApi< abstract class DataSourceApi<
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData,
TQueryImportConfiguration extends Record<string, object> = {}, TQueryImportConfiguration extends Record<string, object> = {}
> { > {
/** /**
* Set in constructor * Set in constructor
@ -375,7 +375,7 @@ abstract class DataSourceApi<
export interface MetadataInspectorProps< export interface MetadataInspectorProps<
DSType extends DataSourceApi<TQuery, TOptions>, DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
> { > {
datasource: DSType; datasource: DSType;
@ -387,7 +387,7 @@ export interface QueryEditorProps<
DSType extends DataSourceApi<TQuery, TOptions>, DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData,
TVQuery extends DataQuery = TQuery, TVQuery extends DataQuery = TQuery
> { > {
datasource: DSType; datasource: DSType;
query: TVQuery; query: TVQuery;
@ -419,7 +419,7 @@ export enum ExploreMode {
export type ExploreQueryFieldProps< export type ExploreQueryFieldProps<
DSType extends DataSourceApi<TQuery, TOptions>, DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
> = QueryEditorProps<DSType, TQuery, TOptions>; > = QueryEditorProps<DSType, TQuery, TOptions>;
export interface QueryEditorHelpProps<TQuery extends DataQuery = DataQuery> { export interface QueryEditorHelpProps<TQuery extends DataQuery = DataQuery> {

View File

@ -32,7 +32,7 @@ export enum VariableSupportType {
export abstract class VariableSupportBase< export abstract class VariableSupportBase<
DSType extends DataSourceApi<TQuery, TOptions>, DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataSourceQueryType<DSType>, TQuery extends DataQuery = DataSourceQueryType<DSType>,
TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>, TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>
> { > {
abstract getType(): VariableSupportType; abstract getType(): VariableSupportType;
@ -50,7 +50,7 @@ export abstract class VariableSupportBase<
export abstract class StandardVariableSupport< export abstract class StandardVariableSupport<
DSType extends DataSourceApi<TQuery, TOptions>, DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataSourceQueryType<DSType>, TQuery extends DataQuery = DataSourceQueryType<DSType>,
TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>, TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>
> extends VariableSupportBase<DSType, TQuery, TOptions> { > extends VariableSupportBase<DSType, TQuery, TOptions> {
getType(): VariableSupportType { getType(): VariableSupportType {
return VariableSupportType.Standard; return VariableSupportType.Standard;
@ -69,7 +69,7 @@ export abstract class CustomVariableSupport<
DSType extends DataSourceApi<TQuery, TOptions>, DSType extends DataSourceApi<TQuery, TOptions>,
VariableQuery extends DataQuery = any, VariableQuery extends DataQuery = any,
TQuery extends DataQuery = DataSourceQueryType<DSType>, TQuery extends DataQuery = DataSourceQueryType<DSType>,
TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>, TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>
> extends VariableSupportBase<DSType, TQuery, TOptions> { > extends VariableSupportBase<DSType, TQuery, TOptions> {
getType(): VariableSupportType { getType(): VariableSupportType {
return VariableSupportType.Custom; return VariableSupportType.Custom;
@ -87,7 +87,7 @@ export abstract class CustomVariableSupport<
export abstract class DataSourceVariableSupport< export abstract class DataSourceVariableSupport<
DSType extends DataSourceApi<TQuery, TOptions>, DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataSourceQueryType<DSType>, TQuery extends DataQuery = DataSourceQueryType<DSType>,
TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>, TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>
> extends VariableSupportBase<DSType, TQuery, TOptions> { > extends VariableSupportBase<DSType, TQuery, TOptions> {
getType(): VariableSupportType { getType(): VariableSupportType {
return VariableSupportType.Datasource; return VariableSupportType.Datasource;

View File

@ -9,10 +9,7 @@ import { vectorToArray } from './vectorToArray';
* @deprecated use a simple Arrays * @deprecated use a simple Arrays
*/ */
export class SortedVector<T = any> extends FunctionalVector<T> { export class SortedVector<T = any> extends FunctionalVector<T> {
constructor( constructor(private source: Vector<T>, private order: number[]) {
private source: Vector<T>,
private order: number[]
) {
super(); super();
return makeArrayIndexableVector(this); return makeArrayIndexableVector(this);
} }

View File

@ -113,7 +113,7 @@ export interface HealthCheckResult {
*/ */
class DataSourceWithBackend< class DataSourceWithBackend<
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
> extends DataSourceApi<TQuery, TOptions> { > extends DataSourceApi<TQuery, TOptions> {
constructor(instanceSettings: DataSourceInstanceSettings<TOptions>) { constructor(instanceSettings: DataSourceInstanceSettings<TOptions>) {
super(instanceSettings); super(instanceSettings);

View File

@ -3,10 +3,7 @@ export type TaskRunner<T> = (options: T) => Promise<any>;
export class Task<TOptions> { export class Task<TOptions> {
options: TOptions = {} as any; options: TOptions = {} as any;
constructor( constructor(public name: string, public runner: TaskRunner<TOptions>) {}
public name: string,
public runner: TaskRunner<TOptions>
) {}
setName = (name: string) => { setName = (name: string) => {
this.name = name; this.name = name;
}; };

View File

@ -164,9 +164,7 @@ const getStyles = stylesFactory((theme: GrafanaTheme2) => {
`, `,
buttonHide: css` buttonHide: css`
opacity: 0; opacity: 0;
transition: transition: opacity 0.1s ease, visibility 0 0.1s;
opacity 0.1s ease,
visibility 0 0.1s;
visibility: hidden; visibility: hidden;
z-index: 0; z-index: 0;
`, `,
@ -180,19 +178,14 @@ const getStyles = stylesFactory((theme: GrafanaTheme2) => {
confirmButtonShow: css` confirmButtonShow: css`
z-index: 1; z-index: 1;
opacity: 1; opacity: 1;
transition: transition: opacity 0.08s ease-out, transform 0.1s ease-out;
opacity 0.08s ease-out,
transform 0.1s ease-out;
transform: translateX(0); transform: translateX(0);
pointer-events: all; pointer-events: all;
`, `,
confirmButtonHide: css` confirmButtonHide: css`
opacity: 0; opacity: 0;
visibility: hidden; visibility: hidden;
transition: transition: opacity 0.12s ease-in, transform 0.14s ease-in, visibility 0s 0.12s;
opacity 0.12s ease-in,
transform 0.14s ease-in,
visibility 0s 0.12s;
transform: translateX(100px); transform: translateX(100px);
`, `,
disabled: css` disabled: css`

View File

@ -11,7 +11,6 @@ $select-input-bg-disabled: $input-bg-disabled;
@mixin select-control-focus() { @mixin select-control-focus() {
border-color: $input-border-focus; border-color: $input-border-focus;
outline: none; outline: none;
// prettier-ignore
$shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px $input-box-shadow-focus; $shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px $input-box-shadow-focus;
@include box-shadow($shadow); @include box-shadow($shadow);
} }

View File

@ -75,9 +75,7 @@ const getStyles = (theme: GrafanaTheme2) => ({
:focus { :focus {
outline: none !important; outline: none !important;
box-shadow: box-shadow: 0 0 0 1px ${theme.colors.background.canvas}, 0 0 0 3px ${theme.colors.primary.main};
0 0 0 1px ${theme.colors.background.canvas},
0 0 0 3px ${theme.colors.primary.main};
} }
`, `,
label: css` label: css`

View File

@ -33,20 +33,15 @@ export const sharedInputStyle = (theme: GrafanaTheme2, invalid = false) => {
&:-webkit-autofill, &:-webkit-autofill,
&:-webkit-autofill:hover { &:-webkit-autofill:hover {
/* Welcome to 2005. This is a HACK to get rid od Chromes default autofill styling */ /* Welcome to 2005. This is a HACK to get rid od Chromes default autofill styling */
box-shadow: box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0), inset 0 0 0 100px ${background}!important;
inset 0 0 0 1px rgba(255, 255, 255, 0),
inset 0 0 0 100px ${background}!important;
-webkit-text-fill-color: ${textColor} !important; -webkit-text-fill-color: ${textColor} !important;
border-color: ${autoFillBorder}; border-color: ${autoFillBorder};
} }
&:-webkit-autofill:focus { &:-webkit-autofill:focus {
/* Welcome to 2005. This is a HACK to get rid od Chromes default autofill styling */ /* Welcome to 2005. This is a HACK to get rid od Chromes default autofill styling */
box-shadow: box-shadow: 0 0 0 2px ${theme.colors.background.primary}, 0 0 0px 4px ${theme.colors.primary.main},
0 0 0 2px ${theme.colors.background.primary}, inset 0 0 0 1px rgba(255, 255, 255, 0), inset 0 0 0 100px ${background}!important;
0 0 0px 4px ${theme.colors.primary.main},
inset 0 0 0 1px rgba(255, 255, 255, 0),
inset 0 0 0 100px ${background}!important;
-webkit-text-fill-color: ${textColor} !important; -webkit-text-fill-color: ${textColor} !important;
} }

View File

@ -100,33 +100,35 @@ export const getInputStyles = stylesFactory(({ theme, invalid = false, width }:
return { return {
// Wraps inputWrapper and addons // Wraps inputWrapper and addons
wrapper: cx(css` wrapper: cx(
label: input-wrapper; css`
display: flex; label: input-wrapper;
width: ${width ? `${theme.spacing(width)}` : '100%'}; display: flex;
height: ${theme.spacing(theme.components.height.md)}; width: ${width ? `${theme.spacing(width)}` : '100%'};
border-radius: ${theme.shape.borderRadius()}; height: ${theme.spacing(theme.components.height.md)};
&:hover { border-radius: ${theme.shape.borderRadius()};
> .prefix, &:hover {
.suffix, > .prefix,
.input { .suffix,
border-color: ${invalid ? theme.colors.error.border : theme.colors.primary.border}; .input {
} border-color: ${invalid ? theme.colors.error.border : theme.colors.primary.border};
}
// only show number buttons on hover // only show number buttons on hover
input[type='number'] { input[type='number'] {
-moz-appearance: number-input; -moz-appearance: number-input;
-webkit-appearance: number-input; -webkit-appearance: number-input;
appearance: textfield; appearance: textfield;
} }
input[type='number']::-webkit-inner-spin-button, input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button { input[type='number']::-webkit-outer-spin-button {
-webkit-appearance: inner-spin-button !important; -webkit-appearance: inner-spin-button !important;
opacity: 1; opacity: 1;
}
} }
} `
`), ),
// Wraps input and prefix/suffix // Wraps input and prefix/suffix
inputWrapper: css` inputWrapper: css`
label: input-inputWrapper; label: input-inputWrapper;

View File

@ -8,7 +8,7 @@ describe('utils', () => {
getBoundingClientRect: () => ({ right }), getBoundingClientRect: () => ({ right }),
}, },
getBoundingClientRect: () => ({ width }), getBoundingClientRect: () => ({ width }),
}) as HTMLElement; } as HTMLElement);
Object.defineProperty(window, 'innerWidth', { value: 1000 }); Object.defineProperty(window, 'innerWidth', { value: 1000 });

View File

@ -16,8 +16,9 @@ export const PanelContainer = ({ children, className, ...props }: Props) => {
); );
}; };
const getStyles = (theme: GrafanaTheme2) => css` const getStyles = (theme: GrafanaTheme2) =>
background-color: ${theme.components.panel.background}; css`
border: 1px solid ${theme.components.panel.borderColor}; background-color: ${theme.components.panel.background};
border-radius: ${theme.shape.radius.default}; border: 1px solid ${theme.components.panel.borderColor};
`; border-radius: ${theme.shape.radius.default};
`;

View File

@ -36,11 +36,8 @@ const getStyles = (theme: GrafanaTheme2) => ({
display: block; display: block;
white-space: nowrap; white-space: nowrap;
cursor: pointer; cursor: pointer;
transition: transition: color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), border-color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1),
color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), background 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), padding 0.15s cubic-bezier(0.645, 0.045, 0.355, 1);
border-color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1),
background 0.3s cubic-bezier(0.645, 0.045, 0.355, 1),
padding 0.15s cubic-bezier(0.645, 0.045, 0.355, 1);
`, `,
typeaheadItemSelected: css` typeaheadItemSelected: css`

View File

@ -15,9 +15,7 @@ const getStyles = stylesFactory((duration: number, measurement: 'width' | 'heigh
label: enterActive; label: enterActive;
${measurement}: ${size}px; ${measurement}: ${size}px;
opacity: 1; opacity: 1;
transition: transition: opacity ${duration}ms ease-out, ${measurement} ${duration}ms ease-out;
opacity ${duration}ms ease-out,
${measurement} ${duration}ms ease-out;
`, `,
exit: css` exit: css`
label: exit; label: exit;
@ -28,9 +26,7 @@ const getStyles = stylesFactory((duration: number, measurement: 'width' | 'heigh
label: exitActive; label: exitActive;
opacity: 0; opacity: 0;
${measurement}: 0; ${measurement}: 0;
transition: transition: opacity ${duration}ms ease-out, ${measurement} ${duration}ms ease-out;
opacity ${duration}ms ease-out,
${measurement} ${duration}ms ease-out;
`, `,
}; };
}); });

View File

@ -17,9 +17,7 @@ const StoryContainer = ({ width, height, showBoundaries, children }: React.Props
css` css`
background-color: white; background-color: white;
background-size: 30px 30px; background-size: 30px 30px;
background-position: background-position: 0 0, 15px 15px;
0 0,
15px 15px;
background-image: linear-gradient( background-image: linear-gradient(
45deg, 45deg,
${checkColor} 25%, ${checkColor} 25%,

View File

@ -52,4 +52,5 @@ export const renderComponentWithTheme = (component: React.ComponentType<any>, pr
export const withTheme = export const withTheme =
(handleSassThemeChange: SassThemeChangeHandler): DecoratorFn => (handleSassThemeChange: SassThemeChangeHandler): DecoratorFn =>
// eslint-disable-next-line react/display-name // eslint-disable-next-line react/display-name
(story) => <ThemeableStory handleSassThemeChange={handleSassThemeChange}>{story()}</ThemeableStory>; (story) =>
<ThemeableStory handleSassThemeChange={handleSassThemeChange}>{story()}</ThemeableStory>;

View File

@ -41,12 +41,7 @@ export class FormDropdownCtrl {
static $inject = ['$scope', '$element', '$sce', 'templateSrv']; static $inject = ['$scope', '$element', '$sce', 'templateSrv'];
constructor( constructor(private $scope: any, $element: JQLite, private $sce: ISCEService, private templateSrv: any) {
private $scope: any,
$element: JQLite,
private $sce: ISCEService,
private templateSrv: any
) {
this.inputElement = $element.find('input').first(); this.inputElement = $element.find('input').first();
this.linkElement = $element.find('a').first(); this.linkElement = $element.find('a').first();
this.linkMode = true; this.linkMode = true;

View File

@ -39,10 +39,7 @@ export class SwitchCtrl {
static $inject = ['$scope', '$timeout']; static $inject = ['$scope', '$timeout'];
constructor( constructor($scope: any, private $timeout: any) {
$scope: any,
private $timeout: any
) {
this.show = true; this.show = true;
this.id = $scope.$id; this.id = $scope.$id;
} }

View File

@ -42,11 +42,7 @@ coreModule.directive('diffDelta', delta);
export class LinkJSONCtrl { export class LinkJSONCtrl {
static $inject = ['$scope', '$rootScope', '$anchorScroll']; static $inject = ['$scope', '$rootScope', '$anchorScroll'];
constructor( constructor(private $scope: any, private $rootScope: GrafanaRootScope, private $anchorScroll: any) {}
private $scope: any,
private $rootScope: GrafanaRootScope,
private $anchorScroll: any
) {}
goToLine(line: number) { goToLine(line: number) {
let unbind: () => void; let unbind: () => void;

View File

@ -10,10 +10,7 @@ export class QueryCtrl<T = any> {
error?: string | null; error?: string | null;
isLastQuery: boolean; isLastQuery: boolean;
constructor( constructor(public $scope: any, public $injector: auto.IInjectorService) {
public $scope: any,
public $injector: auto.IInjectorService
) {
this.panelCtrl = this.panelCtrl ?? $scope.ctrl.panelCtrl; this.panelCtrl = this.panelCtrl ?? $scope.ctrl.panelCtrl;
this.target = this.target ?? $scope.ctrl.target; this.target = this.target ?? $scope.ctrl.target;
this.datasource = this.datasource ?? $scope.ctrl.datasource; this.datasource = this.datasource ?? $scope.ctrl.datasource;

View File

@ -8,10 +8,7 @@ import coreModule from 'app/angular/core_module';
export class AngularLoader implements AngularLoaderInterface { export class AngularLoader implements AngularLoaderInterface {
static $inject = ['$compile', '$rootScope']; static $inject = ['$compile', '$rootScope'];
constructor( constructor(private $compile: any, private $rootScope: GrafanaRootScope) {}
private $compile: any,
private $rootScope: GrafanaRootScope
) {}
load(elem: any, scopeProps: any, template: string): AngularComponent { load(elem: any, scopeProps: any, template: string): AngularComponent {
const scope = this.$rootScope.$new(); const scope = this.$rootScope.$new();

View File

@ -56,7 +56,9 @@ export function SectionNavItem({ item, isSectionRoot = false }: Props) {
{item.text} {item.text}
{item.tabSuffix && <item.tabSuffix className={styles.suffix} />} {item.tabSuffix && <item.tabSuffix className={styles.suffix} />}
</a> </a>
{children?.map((child, index) => <SectionNavItem item={child} key={index} />)} {children?.map((child, index) => (
<SectionNavItem item={child} key={index} />
))}
</> </>
); );
} }

View File

@ -24,8 +24,9 @@ export const CloseButton = ({ onClick, 'aria-label': ariaLabel, style }: Props)
); );
}; };
const getStyles = (theme: GrafanaTheme2) => css` const getStyles = (theme: GrafanaTheme2) =>
position: absolute; css`
right: ${theme.spacing(0.5)}; position: absolute;
top: ${theme.spacing(1)}; right: ${theme.spacing(0.5)};
`; top: ${theme.spacing(1)};
`;

View File

@ -101,7 +101,9 @@ export const RolesLabel = ({ showBuiltInRole, numberOfRoles, appliedRoles }: Rol
<Tooltip <Tooltip
content={ content={
<div className={styles.tooltip}> <div className={styles.tooltip}>
{appliedRoles?.map((role) => <p key={role.uid}>{role.displayName}</p>)} {appliedRoles?.map((role) => (
<p key={role.uid}>{role.displayName}</p>
))}
</div> </div>
} }
> >

View File

@ -140,12 +140,7 @@ function getStyles(theme: GrafanaTheme2) {
text-align: center; text-align: center;
margin-right: ${theme.spacing(0.5)}; margin-right: ${theme.spacing(0.5)};
padding: 3px 5px; padding: 3px 5px;
font: font: 11px Consolas, 'Liberation Mono', Menlo, Courier, monospace;
11px Consolas,
'Liberation Mono',
Menlo,
Courier,
monospace;
line-height: 10px; line-height: 10px;
vertical-align: middle; vertical-align: middle;
border: solid 1px ${theme.colors.border.medium}; border: solid 1px ${theme.colors.border.medium};

View File

@ -57,8 +57,8 @@ function filterQueriesBySearchFilter(queries: RichHistoryQuery[], searchFilter:
const listOfMatchingQueries = query.queries.filter((query) => const listOfMatchingQueries = query.queries.filter((query) =>
// Remove fields in which we don't want to be searching // Remove fields in which we don't want to be searching
Object.values(omit(query, ['datasource', 'key', 'refId', 'hide', 'queryType'])).some( Object.values(omit(query, ['datasource', 'key', 'refId', 'hide', 'queryType'])).some((value) =>
(value) => value?.toString().includes(searchFilter) value?.toString().includes(searchFilter)
) )
); );

View File

@ -29,10 +29,7 @@ import { toggleTheme } from './theme';
import { withFocusedPanel } from './withFocusedPanelId'; import { withFocusedPanel } from './withFocusedPanelId';
export class KeybindingSrv { export class KeybindingSrv {
constructor( constructor(private locationService: LocationService, private chromeService: AppChromeService) {}
private locationService: LocationService,
private chromeService: AppChromeService
) {}
clearAndInitGlobalBindings(route: RouteDescriptor) { clearAndInitGlobalBindings(route: RouteDescriptor) {
Mousetrap.reset(); Mousetrap.reset();

View File

@ -13,17 +13,14 @@ interface Props {
export const AlertGroupHeader = ({ group }: Props) => { export const AlertGroupHeader = ({ group }: Props) => {
const textStyles = useStyles2(getNotificationsTextColors); const textStyles = useStyles2(getNotificationsTextColors);
const total = group.alerts.length; const total = group.alerts.length;
const countByStatus = group.alerts.reduce( const countByStatus = group.alerts.reduce((statusObj, alert) => {
(statusObj, alert) => { if (statusObj[alert.status.state]) {
if (statusObj[alert.status.state]) { statusObj[alert.status.state] += 1;
statusObj[alert.status.state] += 1; } else {
} else { statusObj[alert.status.state] = 1;
statusObj[alert.status.state] = 1; }
} return statusObj;
return statusObj; }, {} as Record<AlertState, number>);
},
{} as Record<AlertState, number>
);
return ( return (
<div> <div>

View File

@ -206,7 +206,7 @@ const useDeletePolicyModal = (handleDelete: (route: RouteWithID) => void, loadin
const useAlertGroupsModal = (): [ const useAlertGroupsModal = (): [
JSX.Element, JSX.Element,
(alertGroups: AlertmanagerGroup[], matchers?: ObjectMatcher[]) => void, (alertGroups: AlertmanagerGroup[], matchers?: ObjectMatcher[]) => void,
() => void, () => void
] => { ] => {
const [showModal, setShowModal] = useState(false); const [showModal, setShowModal] = useState(false);
const [alertGroups, setAlertGroups] = useState<AlertmanagerGroup[]>([]); const [alertGroups, setAlertGroups] = useState<AlertmanagerGroup[]>([]);

View File

@ -63,10 +63,7 @@ function isInsideGoExpression(model: editor.ITextModel, position: Position) {
} }
export class CompletionProvider { export class CompletionProvider {
constructor( constructor(private readonly monaco: Monaco, private readonly range: IRange) {}
private readonly monaco: Monaco,
private readonly range: IRange
) {}
getSnippetsSuggestions = (): languages.ProviderResult<languages.CompletionList> => { getSnippetsSuggestions = (): languages.ProviderResult<languages.CompletionList> => {
return this.getCompletionsFromDefinitions(getSnippetsSuggestions(this.monaco)); return this.getCompletionsFromDefinitions(getSnippetsSuggestions(this.monaco));

View File

@ -59,7 +59,7 @@ export const GrafanaReceiverForm = ({ existing, alertManagerSourceName, config }
// transform receiver DTO to form values // transform receiver DTO to form values
const [existingValue, id2original] = useMemo((): [ const [existingValue, id2original] = useMemo((): [
ReceiverFormValues<GrafanaChannelValues> | undefined, ReceiverFormValues<GrafanaChannelValues> | undefined,
Record<string, GrafanaManagedReceiverConfig>, Record<string, GrafanaManagedReceiverConfig>
] => { ] => {
if (!existing || !grafanaNotifiers.result) { if (!existing || !grafanaNotifiers.result) {
return [undefined, {}]; return [undefined, {}];

View File

@ -62,11 +62,7 @@ export const QueryOptions = ({
</Toggletip> </Toggletip>
<div className={styles.staticValues}> <div className={styles.staticValues}>
<span> <span>{dateTime(timeRange?.from).locale('en').fromNow(true)}</span>
{dateTime(timeRange?.from)
.locale('en')
.fromNow(true)}
</span>
{queryOptions.maxDataPoints && <span>, MD {queryOptions.maxDataPoints}</span>} {queryOptions.maxDataPoints && <span>, MD {queryOptions.maxDataPoints}</span>}
</div> </div>
</> </>

View File

@ -27,19 +27,16 @@ export function RuleDetailsDataSources(props: Props): JSX.Element | null {
if (isGrafanaRulerRule(rule.rulerRule)) { if (isGrafanaRulerRule(rule.rulerRule)) {
const { data } = rule.rulerRule.grafana_alert; const { data } = rule.rulerRule.grafana_alert;
const unique = data.reduce( const unique = data.reduce((dataSources, query) => {
(dataSources, query) => { const ds = getDataSourceSrv().getInstanceSettings(query.datasourceUid);
const ds = getDataSourceSrv().getInstanceSettings(query.datasourceUid);
if (!ds || ds.uid === ExpressionDatasourceUID) { if (!ds || ds.uid === ExpressionDatasourceUID) {
return dataSources;
}
dataSources[ds.name] = { name: ds.name, icon: ds.meta.info.logos.small };
return dataSources; return dataSources;
}, }
{} as Record<string, { name: string; icon?: string }>
); dataSources[ds.name] = { name: ds.name, icon: ds.meta.info.logos.small };
return dataSources;
}, {} as Record<string, { name: string; icon?: string }>);
return Object.values(unique); return Object.values(unique);
} }

View File

@ -181,9 +181,7 @@ const getStyles = (theme: GrafanaTheme2) => ({
background: transparent; background: transparent;
outline: 1px solid transparent; outline: 1px solid transparent;
transition: transition: background 150ms, outline 150ms;
background 150ms,
outline 150ms;
padding: ${theme.spacing(1)} ${theme.spacing(1.5)}; padding: ${theme.spacing(1)} ${theme.spacing(1.5)};
`, `,
}); });

View File

@ -148,15 +148,14 @@ const useFilteredSilences = (silences: Silence[], expired = false) => {
} }
if (queryString) { if (queryString) {
const matchers = parseMatchers(queryString); const matchers = parseMatchers(queryString);
const matchersMatch = matchers.every( const matchersMatch = matchers.every((matcher) =>
(matcher) => silence.matchers?.some(
silence.matchers?.some( ({ name, value, isEqual, isRegex }) =>
({ name, value, isEqual, isRegex }) => matcher.name === name &&
matcher.name === name && matcher.value === value &&
matcher.value === value && matcher.isEqual === isEqual &&
matcher.isEqual === isEqual && matcher.isRegex === isRegex
matcher.isRegex === isRegex )
)
); );
if (!matchersMatch) { if (!matchersMatch) {
return false; return false;

View File

@ -5,7 +5,7 @@ import { locationService } from '@grafana/runtime';
export function useURLSearchParams(): [ export function useURLSearchParams(): [
URLSearchParams, URLSearchParams,
(searchValues: Record<string, string | string[] | undefined>, replace?: boolean) => void, (searchValues: Record<string, string | string[] | undefined>, replace?: boolean) => void
] { ] {
const { search } = useLocation(); const { search } = useLocation();
const queryParams = useMemo(() => new URLSearchParams(search), [search]); const queryParams = useMemo(() => new URLSearchParams(search), [search]);

View File

@ -35,10 +35,7 @@ export class AlertingQueryRunner {
private subscription?: Unsubscribable; private subscription?: Unsubscribable;
private lastResult: Record<string, PanelData>; private lastResult: Record<string, PanelData>;
constructor( constructor(private backendSrv = getBackendSrv(), private dataSourceSrv = getDataSourceSrv()) {
private backendSrv = getBackendSrv(),
private dataSourceSrv = getDataSourceSrv()
) {
this.subject = new ReplaySubject(1); this.subject = new ReplaySubject(1);
this.lastResult = {}; this.lastResult = {};
} }

View File

@ -169,20 +169,17 @@ export function getFirstActiveAt(promRule?: AlertingRule) {
if (!promRule?.alerts) { if (!promRule?.alerts) {
return null; return null;
} }
return promRule.alerts.reduce( return promRule.alerts.reduce((prev, alert) => {
(prev, alert) => { const isNotNormal =
const isNotNormal = mapStateWithReasonToBaseState(alert.state as GrafanaAlertStateWithReason) !== GrafanaAlertState.Normal;
mapStateWithReasonToBaseState(alert.state as GrafanaAlertStateWithReason) !== GrafanaAlertState.Normal; if (alert.activeAt && isNotNormal) {
if (alert.activeAt && isNotNormal) { const activeAt = new Date(alert.activeAt);
const activeAt = new Date(alert.activeAt); if (prev === null || prev.getTime() > activeAt.getTime()) {
if (prev === null || prev.getTime() > activeAt.getTime()) { return activeAt;
return activeAt;
}
} }
return prev; }
}, return prev;
null as Date | null }, null as Date | null);
);
} }
/** /**

View File

@ -26,12 +26,16 @@ export const ErrorContainerUnconnected = ({ error, warning, resetError, resetWar
<div> <div>
{error && ( {error && (
<Alert title={error.message} onRemove={() => resetError()}> <Alert title={error.message} onRemove={() => resetError()}>
{error.errors?.map((e, i) => <div key={i}>{e}</div>)} {error.errors?.map((e, i) => (
<div key={i}>{e}</div>
))}
</Alert> </Alert>
)} )}
{warning && ( {warning && (
<Alert title={warning.message} onRemove={() => resetWarning()} severity="warning"> <Alert title={warning.message} onRemove={() => resetWarning()} severity="warning">
{warning.errors?.map((e, i) => <div key={i}>{e}</div>)} {warning.errors?.map((e, i) => (
<div key={i}>{e}</div>
))}
</Alert> </Alert>
)} )}
</div> </div>

View File

@ -36,11 +36,7 @@ export class ElementState implements LayerElement {
// Calculated // Calculated
data?: any; // depends on the type data?: any; // depends on the type
constructor( constructor(public item: CanvasElementItem, public options: CanvasElementOptions, public parent?: FrameState) {
public item: CanvasElementItem,
public options: CanvasElementOptions,
public parent?: FrameState
) {
const fallbackName = `Element ${Date.now()}`; const fallbackName = `Element ${Date.now()}`;
if (!options) { if (!options) {
this.options = { type: item.id, name: fallbackName }; this.options = { type: item.id, name: fallbackName };

View File

@ -36,11 +36,7 @@ export class FrameState extends ElementState {
elements: ElementState[] = []; elements: ElementState[] = [];
scene: Scene; scene: Scene;
constructor( constructor(public options: CanvasFrameOptions, scene: Scene, public parent?: FrameState) {
public options: CanvasFrameOptions,
scene: Scene,
public parent?: FrameState
) {
super(frameItemDummy, options, parent); super(frameItemDummy, options, parent);
this.scene = scene; this.scene = scene;

View File

@ -6,11 +6,7 @@ import { FrameState } from './frame';
import { Scene } from './scene'; import { Scene } from './scene';
export class RootElement extends FrameState { export class RootElement extends FrameState {
constructor( constructor(public options: CanvasFrameOptions, public scene: Scene, private changeCallback: () => void) {
public options: CanvasFrameOptions,
public scene: Scene,
private changeCallback: () => void
) {
super(options, scene); super(options, scene);
this.sizeStyle = { this.sizeStyle = {

View File

@ -37,9 +37,9 @@ export const ConfigureCorrelationSourceForm = () => {
return ( return (
<> <>
<FieldSet <FieldSet
label={`Configure the data source that will link to ${getDatasourceSrv().getInstanceSettings( label={`Configure the data source that will link to ${
correlation?.targetUID getDatasourceSrv().getInstanceSettings(correlation?.targetUID)?.name
)?.name} (Step 3 of 3)`} } (Step 3 of 3)`}
> >
<p> <p>
Define what data source will display the correlation, and what data will replace previously defined variables. Define what data source will display the correlation, and what data will replace previously defined variables.

View File

@ -232,10 +232,10 @@ const getStyles = (theme: GrafanaTheme2) => {
const pulsate = keyframes` const pulsate = keyframes`
0% {box-shadow: 0 0 0 2px ${theme.colors.background.canvas}, 0 0 0px 4px ${theme.colors.primary.main};} 0% {box-shadow: 0 0 0 2px ${theme.colors.background.canvas}, 0 0 0px 4px ${theme.colors.primary.main};}
50% {box-shadow: 0 0 0 2px ${theme.components.dashboard.background}, 0 0 0px 4px ${tinycolor( 50% {box-shadow: 0 0 0 2px ${theme.components.dashboard.background}, 0 0 0px 4px ${tinycolor(
theme.colors.primary.main theme.colors.primary.main
) )
.darken(20) .darken(20)
.toHexString()};} .toHexString()};}
100% {box-shadow: 0 0 0 2px ${theme.components.dashboard.background}, 0 0 0px 4px ${theme.colors.primary.main};} 100% {box-shadow: 0 0 0 2px ${theme.components.dashboard.background}, 0 0 0px 4px ${theme.colors.primary.main};}
`; `;
@ -249,9 +249,7 @@ const getStyles = (theme: GrafanaTheme2) => {
overflow: hidden; overflow: hidden;
outline: 2px dotted transparent; outline: 2px dotted transparent;
outline-offset: 2px; outline-offset: 2px;
box-shadow: box-shadow: 0 0 0 2px black, 0 0 0px 4px #1f60c4;
0 0 0 2px black,
0 0 0px 4px #1f60c4;
animation: ${pulsate} 2s ease infinite; animation: ${pulsate} 2s ease infinite;
`, `,
actionsWrapper: css` actionsWrapper: css`

View File

@ -100,7 +100,7 @@ describe('getValidIntervals', () => {
getTimeSrv: () => getTimeSrv: () =>
({ ({
getValidIntervals: (intervals: string[]) => intervals, getValidIntervals: (intervals: string[]) => intervals,
}) as unknown as TimeSrv, } as unknown as TimeSrv),
}; };
const result = getValidIntervals(emptyIntervals, dependencies); const result = getValidIntervals(emptyIntervals, dependencies);
@ -116,7 +116,7 @@ describe('getValidIntervals', () => {
getTimeSrv: () => getTimeSrv: () =>
({ ({
getValidIntervals: (intervals: string[]) => intervals, getValidIntervals: (intervals: string[]) => intervals,
}) as unknown as TimeSrv, } as unknown as TimeSrv),
}; };
const result = getValidIntervals(duplicateIntervals, dependencies); const result = getValidIntervals(duplicateIntervals, dependencies);
@ -132,7 +132,7 @@ describe('getValidIntervals', () => {
getTimeSrv: () => getTimeSrv: () =>
({ ({
getValidIntervals: (intervals: string[]) => intervals, getValidIntervals: (intervals: string[]) => intervals,
}) as unknown as TimeSrv, } as unknown as TimeSrv),
}; };
const result = getValidIntervals(duplicateIntervals, dependencies); const result = getValidIntervals(duplicateIntervals, dependencies);
@ -149,7 +149,7 @@ describe('validateIntervals', () => {
getTimeSrv: () => getTimeSrv: () =>
({ ({
getValidIntervals: (intervals: string[]) => intervals, getValidIntervals: (intervals: string[]) => intervals,
}) as unknown as TimeSrv, } as unknown as TimeSrv),
}; };
const result = validateIntervals(defaultIntervals, dependencies); const result = validateIntervals(defaultIntervals, dependencies);
@ -166,7 +166,7 @@ describe('validateIntervals', () => {
getValidIntervals: () => { getValidIntervals: () => {
throw new Error('Some error'); throw new Error('Some error');
}, },
}) as unknown as TimeSrv, } as unknown as TimeSrv),
}; };
const result = validateIntervals(defaultIntervals, dependencies); const result = validateIntervals(defaultIntervals, dependencies);

View File

@ -53,29 +53,30 @@ export const DynamicConfigValueEditor = ({
/* eslint-disable react/display-name */ /* eslint-disable react/display-name */
const renderLabel = const renderLabel =
(includeDescription = true, includeCounter = false) => (includeDescription = true, includeCounter = false) =>
(isExpanded = false) => ( (isExpanded = false) =>
<HorizontalGroup justify="space-between"> (
<Label <HorizontalGroup justify="space-between">
category={labelCategory} <Label
description={includeDescription ? item.description : undefined} category={labelCategory}
htmlFor={componentId} description={includeDescription ? item.description : undefined}
> htmlFor={componentId}
<Highlighter >
textToHighlight={item.name} <Highlighter
searchWords={[searchQuery]} textToHighlight={item.name}
highlightClassName={'search-fragment-highlight'} searchWords={[searchQuery]}
/> highlightClassName={'search-fragment-highlight'}
{!isExpanded && includeCounter && item.getItemsCount && ( />
<Counter value={item.getItemsCount(property.value)} /> {!isExpanded && includeCounter && item.getItemsCount && (
<Counter value={item.getItemsCount(property.value)} />
)}
</Label>
{!isSystemOverride && (
<div>
<IconButton name="times" onClick={onRemove} tooltip="Remove label" />
</div>
)} )}
</Label> </HorizontalGroup>
{!isSystemOverride && ( );
<div>
<IconButton name="times" onClick={onRemove} tooltip="Remove label" />
</div>
)}
</HorizontalGroup>
);
/* eslint-enable react/display-name */ /* eslint-enable react/display-name */
if (isCollapsible) { if (isCollapsible) {

View File

@ -499,7 +499,7 @@ describe('PanelModel', () => {
describe('destroy', () => { describe('destroy', () => {
it('Should still preserve last query result', () => { it('Should still preserve last query result', () => {
model.getQueryRunner().useLastResultFrom({ model.getQueryRunner().useLastResultFrom({
getLastResult: () => ({}) as PanelData, getLastResult: () => ({} as PanelData),
} as PanelQueryRunner); } as PanelQueryRunner);
model.destroy(); model.destroy();

View File

@ -50,7 +50,7 @@ const getBackendSrvMock = () =>
}), }),
}), }),
withNoBackendCache: jest.fn().mockImplementationOnce((cb) => cb()), withNoBackendCache: jest.fn().mockImplementationOnce((cb) => cb()),
}) as any; } as any);
const failDataSourceTest = async (error: object) => { const failDataSourceTest = async (error: object) => {
const dependencies: TestDataSourceDependencies = { const dependencies: TestDataSourceDependencies = {
@ -61,7 +61,7 @@ const failDataSourceTest = async (error: object) => {
throw error; throw error;
}), }),
}), }),
}) as any, } as any),
getBackendSrv: getBackendSrvMock, getBackendSrv: getBackendSrvMock,
}; };
const state = { const state = {
@ -223,7 +223,7 @@ describe('testDataSource', () => {
type: 'cloudwatch', type: 'cloudwatch',
uid: 'CW1234', uid: 'CW1234',
}), }),
}) as any, } as any),
getBackendSrv: getBackendSrvMock, getBackendSrv: getBackendSrvMock,
}; };
const state = { const state = {
@ -258,7 +258,7 @@ describe('testDataSource', () => {
type: 'azure-monitor', type: 'azure-monitor',
uid: 'azM0nit0R', uid: 'azM0nit0R',
}), }),
}) as any, } as any),
getBackendSrv: getBackendSrvMock, getBackendSrv: getBackendSrvMock,
}; };
const result = { const result = {

View File

@ -37,7 +37,7 @@ const mockPlugin = () =>
pinned: true, pinned: true,
type: PluginType.datasource, type: PluginType.datasource,
module: 'path/to/module', module: 'path/to/module',
}) as PluginMeta; } as PluginMeta);
describe('dataSourcesReducer', () => { describe('dataSourcesReducer', () => {
describe('when dataSourcesLoaded is dispatched', () => { describe('when dataSourcesLoaded is dispatched', () => {

View File

@ -7,9 +7,10 @@ import { Page } from 'app/core/components/Page/Page';
export default function FeatureTogglePage() { export default function FeatureTogglePage() {
const styles = useStyles2( const styles = useStyles2(
(theme: GrafanaTheme2) => css` (theme: GrafanaTheme2) =>
margin-top: ${theme.spacing(2)}; css`
` margin-top: ${theme.spacing(2)};
`
); );
return ( return (

View File

@ -403,13 +403,14 @@ const Query = ({ query, showDsInfo = false }: QueryProps) => {
); );
}; };
const getDsInfoStyles = (size: 'sm' | 'md') => (theme: GrafanaTheme2) => css` const getDsInfoStyles = (size: 'sm' | 'md') => (theme: GrafanaTheme2) =>
display: flex; css`
align-items: center; display: flex;
font-size: ${theme.typography[size === 'sm' ? 'bodySmall' : 'body'].fontSize}; align-items: center;
font-weight: ${theme.typography.fontWeightMedium}; font-size: ${theme.typography[size === 'sm' ? 'bodySmall' : 'body'].fontSize};
white-space: nowrap; font-weight: ${theme.typography.fontWeightMedium};
`; white-space: nowrap;
`;
function DatasourceInfo({ dsApi, size }: { dsApi?: DataSourceApi; size: 'sm' | 'md' }) { function DatasourceInfo({ dsApi, size }: { dsApi?: DataSourceApi; size: 'sm' | 'md' }) {
const getStyles = useCallback((theme: GrafanaTheme2) => getDsInfoStyles(size)(theme), [size]); const getStyles = useCallback((theme: GrafanaTheme2) => getDsInfoStyles(size)(theme), [size]);

View File

@ -264,8 +264,8 @@ function useFocusSpanLink(options: {
}) })
); );
const query = useSelector( const query = useSelector((state) =>
(state) => state.explore.panes[options.exploreId]?.queries.find((query) => query.refId === options.refId) state.explore.panes[options.exploreId]?.queries.find((query) => query.refId === options.refId)
); );
const createFocusSpanLink = (traceId: string, spanId: string) => { const createFocusSpanLink = (traceId: string, spanId: string) => {

View File

@ -223,13 +223,10 @@ export const sortPlugins = (plugins: CatalogPlugin[], sortBy: Sorters) => {
}; };
function groupErrorsByPluginId(errors: PluginError[] = []): Record<string, PluginError | undefined> { function groupErrorsByPluginId(errors: PluginError[] = []): Record<string, PluginError | undefined> {
return errors.reduce( return errors.reduce((byId, error) => {
(byId, error) => { byId[error.pluginId] = error;
byId[error.pluginId] = error; return byId;
return byId; }, {} as Record<string, PluginError | undefined>);
},
{} as Record<string, PluginError | undefined>
);
} }
function getPluginSignature(options: { function getPluginSignature(options: {

View File

@ -44,7 +44,7 @@ import { runRequest } from './runRequest';
export interface QueryRunnerOptions< export interface QueryRunnerOptions<
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
> { > {
datasource: DataSourceRef | DataSourceApi<TQuery, TOptions> | null; datasource: DataSourceRef | DataSourceApi<TQuery, TOptions> | null;
queries: TQuery[]; queries: TQuery[];

View File

@ -72,7 +72,9 @@ export function RootView({ root, onPathChange }: Props) {
{s.config.description} {s.config.description}
{s.config.git?.remote && <a href={s.config.git?.remote}>{s.config.git?.remote}</a>} {s.config.git?.remote && <a href={s.config.git?.remote}>{s.config.git?.remote}</a>}
</Card.Meta> </Card.Meta>
{s.notice?.map((notice) => <Alert key={notice.text} severity={notice.severity} title={notice.text} />)} {s.notice?.map((notice) => (
<Alert key={notice.text} severity={notice.severity} title={notice.text} />
))}
<Card.Tags className={styles.clickable}> <Card.Tags className={styles.clickable}>
<HorizontalGroup> <HorizontalGroup>

View File

@ -192,13 +192,10 @@ const reorderToIndex = (fieldNames: string[], startIndex: number, endIndex: numb
const [removed] = result.splice(startIndex, 1); const [removed] = result.splice(startIndex, 1);
result.splice(endIndex, 0, removed); result.splice(endIndex, 0, removed);
return result.reduce( return result.reduce((nameByIndex, fieldName, index) => {
(nameByIndex, fieldName, index) => { nameByIndex[fieldName] = index;
nameByIndex[fieldName] = index; return nameByIndex;
return nameByIndex; }, {} as Record<string, number>);
},
{} as Record<string, number>
);
}; };
const orderFieldNamesByIndex = (fieldNames: string[], indexByName: Record<string, number> = {}): string[] => { const orderFieldNamesByIndex = (fieldNames: string[], indexByName: Record<string, number> = {}): string[] => {

View File

@ -9,20 +9,17 @@ export function useAllFieldNamesFromDataFrames(input: DataFrame[]): string[] {
} }
return Object.keys( return Object.keys(
input.reduce( input.reduce((names, frame) => {
(names, frame) => { if (!frame || !Array.isArray(frame.fields)) {
if (!frame || !Array.isArray(frame.fields)) { return names;
return names; }
}
return frame.fields.reduce((names, field) => { return frame.fields.reduce((names, field) => {
const t = getFieldDisplayName(field, frame, input); const t = getFieldDisplayName(field, frame, input);
names[t] = true; names[t] = true;
return names; return names;
}, names); }, names);
}, }, {} as Record<string, boolean>)
{} as Record<string, boolean>
)
); );
}, [input]); }, [input]);
} }

View File

@ -17,7 +17,7 @@ import { LegacyVariableQueryEditor } from './LegacyVariableQueryEditor';
export async function getVariableQueryEditor< export async function getVariableQueryEditor<
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData,
VariableQuery extends DataQuery = TQuery, VariableQuery extends DataQuery = TQuery
>( >(
datasource: DataSourceApi<TQuery, TOptions>, datasource: DataSourceApi<TQuery, TOptions>,
importDataSourcePluginFunc = importDataSourcePlugin importDataSourcePluginFunc = importDataSourcePlugin
@ -50,7 +50,7 @@ export async function getVariableQueryEditor<
export function StandardVariableQueryEditor< export function StandardVariableQueryEditor<
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
>({ >({
datasource: propsDatasource, datasource: propsDatasource,
query: propsQuery, query: propsQuery,

View File

@ -62,7 +62,7 @@ export function isLegacyAdHocDataSource(datasource: null | DataSourceRef | strin
interface DataSourceWithLegacyVariableSupport< interface DataSourceWithLegacyVariableSupport<
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
> extends DataSourceApi<TQuery, TOptions> { > extends DataSourceApi<TQuery, TOptions> {
metricFindQuery(query: any, options?: any): Promise<MetricFindValue[]>; metricFindQuery(query: any, options?: any): Promise<MetricFindValue[]>;
variables: undefined; variables: undefined;
@ -70,7 +70,7 @@ interface DataSourceWithLegacyVariableSupport<
interface DataSourceWithStandardVariableSupport< interface DataSourceWithStandardVariableSupport<
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
> extends DataSourceApi<TQuery, TOptions> { > extends DataSourceApi<TQuery, TOptions> {
variables: { variables: {
getType(): VariableSupportType; getType(): VariableSupportType;
@ -81,7 +81,7 @@ interface DataSourceWithStandardVariableSupport<
interface DataSourceWithCustomVariableSupport< interface DataSourceWithCustomVariableSupport<
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
> extends DataSourceApi<TQuery, TOptions> { > extends DataSourceApi<TQuery, TOptions> {
variables: { variables: {
getType(): VariableSupportType; getType(): VariableSupportType;
@ -92,7 +92,7 @@ interface DataSourceWithCustomVariableSupport<
interface DataSourceWithDatasourceVariableSupport< interface DataSourceWithDatasourceVariableSupport<
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
> extends DataSourceApi<TQuery, TOptions> { > extends DataSourceApi<TQuery, TOptions> {
variables: { variables: {
getType(): VariableSupportType; getType(): VariableSupportType;
@ -105,7 +105,7 @@ interface DataSourceWithDatasourceVariableSupport<
* */ * */
export const hasLegacyVariableSupport = < export const hasLegacyVariableSupport = <
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
>( >(
datasource: DataSourceApi<TQuery, TOptions> datasource: DataSourceApi<TQuery, TOptions>
): datasource is DataSourceWithLegacyVariableSupport<TQuery, TOptions> => { ): datasource is DataSourceWithLegacyVariableSupport<TQuery, TOptions> => {
@ -114,7 +114,7 @@ export const hasLegacyVariableSupport = <
export const hasStandardVariableSupport = < export const hasStandardVariableSupport = <
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
>( >(
datasource: DataSourceApi<TQuery, TOptions> datasource: DataSourceApi<TQuery, TOptions>
): datasource is DataSourceWithStandardVariableSupport<TQuery, TOptions> => { ): datasource is DataSourceWithStandardVariableSupport<TQuery, TOptions> => {
@ -132,7 +132,7 @@ export const hasStandardVariableSupport = <
export const hasCustomVariableSupport = < export const hasCustomVariableSupport = <
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
>( >(
datasource: DataSourceApi<TQuery, TOptions> datasource: DataSourceApi<TQuery, TOptions>
): datasource is DataSourceWithCustomVariableSupport<TQuery, TOptions> => { ): datasource is DataSourceWithCustomVariableSupport<TQuery, TOptions> => {
@ -155,7 +155,7 @@ export const hasCustomVariableSupport = <
export const hasDatasourceVariableSupport = < export const hasDatasourceVariableSupport = <
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
>( >(
datasource: DataSourceApi<TQuery, TOptions> datasource: DataSourceApi<TQuery, TOptions>
): datasource is DataSourceWithDatasourceVariableSupport<TQuery, TOptions> => { ): datasource is DataSourceWithDatasourceVariableSupport<TQuery, TOptions> => {
@ -168,7 +168,7 @@ export const hasDatasourceVariableSupport = <
export function isLegacyQueryEditor< export function isLegacyQueryEditor<
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
>( >(
component: VariableQueryEditorType, component: VariableQueryEditorType,
datasource: DataSourceApi<TQuery, TOptions> datasource: DataSourceApi<TQuery, TOptions>
@ -182,7 +182,7 @@ export function isLegacyQueryEditor<
export function isQueryEditor< export function isQueryEditor<
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
>( >(
component: VariableQueryEditorType, component: VariableQueryEditorType,
datasource: DataSourceApi<TQuery, TOptions> datasource: DataSourceApi<TQuery, TOptions>

View File

@ -118,58 +118,52 @@ const validVariableNames: Record<string, RegExp[]> = {
}; };
export const getPropsWithVariable = (variableId: string, parent: { key: string; value: any }, result: any) => { export const getPropsWithVariable = (variableId: string, parent: { key: string; value: any }, result: any) => {
const stringValues = Object.keys(parent.value).reduce( const stringValues = Object.keys(parent.value).reduce((all, key) => {
(all, key) => { const value = parent.value[key];
const value = parent.value[key]; if (!value || typeof value !== 'string') {
if (!value || typeof value !== 'string') { return all;
return all; }
const isValidName = validVariableNames[key]
? validVariableNames[key].find((regex: RegExp) => regex.test(variableId))
: undefined;
let hasVariable = containsVariable(value, variableId);
if (key === 'repeat' && value === variableId) {
// repeat stores value without variable format
hasVariable = true;
}
if (!isValidName && hasVariable) {
all = {
...all,
[key]: value,
};
}
return all;
}, {} as Record<string, any>);
const objectValues = Object.keys(parent.value).reduce((all, key) => {
const value = parent.value[key];
if (value && typeof value === 'object' && Object.keys(value).length) {
let id = value.title || value.name || value.id || key;
if (Array.isArray(parent.value) && parent.key === 'panels') {
id = `${id}[${value.id}]`;
} }
const isValidName = validVariableNames[key] const newResult = getPropsWithVariable(variableId, { key, value }, {});
? validVariableNames[key].find((regex: RegExp) => regex.test(variableId))
: undefined;
let hasVariable = containsVariable(value, variableId); if (Object.keys(newResult).length) {
if (key === 'repeat' && value === variableId) {
// repeat stores value without variable format
hasVariable = true;
}
if (!isValidName && hasVariable) {
all = { all = {
...all, ...all,
[key]: value, [id]: newResult,
}; };
} }
}
return all; return all;
}, }, {} as Record<string, any>);
{} as Record<string, any>
);
const objectValues = Object.keys(parent.value).reduce(
(all, key) => {
const value = parent.value[key];
if (value && typeof value === 'object' && Object.keys(value).length) {
let id = value.title || value.name || value.id || key;
if (Array.isArray(parent.value) && parent.key === 'panels') {
id = `${id}[${value.id}]`;
}
const newResult = getPropsWithVariable(variableId, { key, value }, {});
if (Object.keys(newResult).length) {
all = {
...all,
[id]: newResult,
};
}
}
return all;
},
{} as Record<string, any>
);
if (Object.keys(stringValues).length || Object.keys(objectValues).length) { if (Object.keys(stringValues).length || Object.keys(objectValues).length) {
result = { result = {

View File

@ -184,25 +184,22 @@ export function flattenQuery(query: any): any {
} }
const keys = Object.keys(query); const keys = Object.keys(query);
const flattened = keys.reduce( const flattened = keys.reduce((all, key) => {
(all, key) => { const value = query[key];
const value = query[key]; if (typeof value !== 'object' || value === null) {
if (typeof value !== 'object' || value === null) { all[key] = value;
all[key] = value;
return all;
}
const result = flattenQuery(value);
for (let childProp in result) {
if (result.hasOwnProperty(childProp)) {
all[`${key}_${childProp}`] = result[childProp];
}
}
return all; return all;
}, }
{} as Record<string, any>
); const result = flattenQuery(value);
for (let childProp in result) {
if (result.hasOwnProperty(childProp)) {
all[`${key}_${childProp}`] = result[childProp];
}
}
return all;
}, {} as Record<string, any>);
return flattened; return flattened;
} }

View File

@ -3,7 +3,7 @@ import { DataSourceVariableModel, QueryVariableModel, VariableRefresh } from 'ap
import { MultiVariableBuilder } from './multiVariableBuilder'; import { MultiVariableBuilder } from './multiVariableBuilder';
export class DatasourceVariableBuilder< export class DatasourceVariableBuilder<
T extends DataSourceVariableModel | QueryVariableModel, T extends DataSourceVariableModel | QueryVariableModel
> extends MultiVariableBuilder<T> { > extends MultiVariableBuilder<T> {
withRefresh(refresh: VariableRefresh) { withRefresh(refresh: VariableRefresh) {
this.variable.refresh = refresh; this.variable.refresh = refresh;

View File

@ -89,7 +89,7 @@ export interface VariableQueryEditorProps {
export type VariableQueryEditorType< export type VariableQueryEditorType<
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData, TOptions extends DataSourceJsonData = DataSourceJsonData
> = ComponentType<VariableQueryEditorProps> | ComponentType<QueryEditorProps<any, TQuery, TOptions, any>> | null; > = ComponentType<VariableQueryEditorProps> | ComponentType<QueryEditorProps<any, TQuery, TOptions, any>> | null;
export interface VariablesChangedEvent { export interface VariablesChangedEvent {

View File

@ -218,7 +218,7 @@ export type AlertmanagerAlert = {
receivers: [ receivers: [
{ {
name: string; name: string;
}, }
]; ];
fingerprint: string; fingerprint: string;
status: { status: {

View File

@ -20,10 +20,7 @@ export abstract class CloudWatchRequest {
AppNotificationTimeout.Error AppNotificationTimeout.Error
); );
constructor( constructor(public instanceSettings: DataSourceInstanceSettings<CloudWatchJsonData>, templateSrv: TemplateSrv) {
public instanceSettings: DataSourceInstanceSettings<CloudWatchJsonData>,
templateSrv: TemplateSrv
) {
this.templateSrv = templateSrv; this.templateSrv = templateSrv;
this.ref = getDataSourceRef(instanceSettings); this.ref = getDataSourceRef(instanceSettings);
} }

View File

@ -27,10 +27,7 @@ interface TopMetricBucket {
} }
export class ElasticResponse { export class ElasticResponse {
constructor( constructor(private targets: ElasticsearchQuery[], private response: any) {
private targets: ElasticsearchQuery[],
private response: any
) {
this.targets = targets; this.targets = targets;
this.response = response; this.response = response;
} }
@ -787,10 +784,8 @@ const addPreferredVisualisationType = (series: any, type: PreferredVisualisation
const toNameTypePair = const toNameTypePair =
(docs: Array<Record<string, any>>) => (docs: Array<Record<string, any>>) =>
(propName: string): [string, FieldType] => [ (propName: string): [string, FieldType] =>
propName, [propName, guessType(docs.find((doc) => doc[propName] !== undefined)?.[propName])];
guessType(docs.find((doc) => doc[propName] !== undefined)?.[propName]),
];
/** /**
* Trying to guess data type from its value. This is far from perfect, as in order to have accurate guess * Trying to guess data type from its value. This is far from perfect, as in order to have accurate guess

View File

@ -21,10 +21,7 @@ export const intervalMap: IntervalMap = {
export class IndexPattern { export class IndexPattern {
private dateLocale = 'en'; private dateLocale = 'en';
constructor( constructor(private pattern: string, private interval?: keyof typeof intervalMap) {}
private pattern: string,
private interval?: keyof typeof intervalMap
) {}
getIndexForToday() { getIndexForToday() {
if (this.interval) { if (this.interval) {

View File

@ -84,10 +84,7 @@ export class GraphiteDatasource
requestCounter = 100; requestCounter = 100;
private readonly metricMappings: GraphiteLokiMapping[]; private readonly metricMappings: GraphiteLokiMapping[];
constructor( constructor(instanceSettings: any, private readonly templateSrv: TemplateSrv = getTemplateSrv()) {
instanceSettings: any,
private readonly templateSrv: TemplateSrv = getTemplateSrv()
) {
super(instanceSettings); super(instanceSettings);
this.basicAuth = instanceSettings.basicAuth; this.basicAuth = instanceSettings.basicAuth;
this.url = instanceSettings.url; this.url = instanceSettings.url;

View File

@ -13,10 +13,7 @@ interface HistoryRef {
} }
export class CompletionDataProvider { export class CompletionDataProvider {
constructor( constructor(private languageProvider: LanguageProvider, private historyRef: HistoryRef = { current: [] }) {}
private languageProvider: LanguageProvider,
private historyRef: HistoryRef = { current: [] }
) {}
private buildSelector(labels: Label[]): string { private buildSelector(labels: Label[]): string {
const allLabelTexts = labels.map( const allLabelTexts = labels.map(

View File

@ -53,47 +53,48 @@ export const customStatementPlacementProvider: StatementPlacementProvider = () =
]; ];
export const customSuggestionKinds: (getMeta: CompletionProviderGetterArgs['getMeta']) => SuggestionKindProvider = export const customSuggestionKinds: (getMeta: CompletionProviderGetterArgs['getMeta']) => SuggestionKindProvider =
(getMeta) => () => [ (getMeta) => () =>
{ [
id: SuggestionKind.Tables, {
overrideDefault: true, id: SuggestionKind.Tables,
suggestionsResolver: async (ctx) => { overrideDefault: true,
const databaseName = getDatabaseName(ctx.currentToken); suggestionsResolver: async (ctx) => {
const databaseName = getDatabaseName(ctx.currentToken);
const suggestions = await getMeta({ schema: databaseName }); const suggestions = await getMeta({ schema: databaseName });
return suggestions.map(mapToSuggestion(ctx)); return suggestions.map(mapToSuggestion(ctx));
},
}, },
}, {
{ id: SuggestionKind.Columns,
id: SuggestionKind.Columns, overrideDefault: true,
overrideDefault: true, suggestionsResolver: async (ctx) => {
suggestionsResolver: async (ctx) => { const databaseToken = getDatabaseToken(ctx.currentToken);
const databaseToken = getDatabaseToken(ctx.currentToken); const databaseName = getDatabaseName(databaseToken);
const databaseName = getDatabaseName(databaseToken); const tableName = getTableName(databaseToken);
const tableName = getTableName(databaseToken);
if (!databaseName || !tableName) { if (!databaseName || !tableName) {
return []; return [];
} }
const suggestions = await getMeta({ schema: databaseName, table: tableName }); const suggestions = await getMeta({ schema: databaseName, table: tableName });
return suggestions.map(mapToSuggestion(ctx)); return suggestions.map(mapToSuggestion(ctx));
},
}, },
}, {
{ id: customSuggestionKind.tablesWithinDatabase,
id: customSuggestionKind.tablesWithinDatabase, applyTo: [customStatementPlacement.afterDatabase],
applyTo: [customStatementPlacement.afterDatabase], suggestionsResolver: async (ctx) => {
suggestionsResolver: async (ctx) => { const databaseName = getDatabaseName(ctx.currentToken);
const databaseName = getDatabaseName(ctx.currentToken);
const suggestions = await getMeta({ schema: databaseName }); const suggestions = await getMeta({ schema: databaseName });
return suggestions.map(mapToSuggestion(ctx)); return suggestions.map(mapToSuggestion(ctx));
},
}, },
}, ];
];
function mapToSuggestion(ctx: PositionContext) { function mapToSuggestion(ctx: PositionContext) {
return function (tableDefinition: TableDefinition) { return function (tableDefinition: TableDefinition) {

View File

@ -46,10 +46,7 @@ export default class OpenTsDatasource extends DataSourceApi<OpenTsdbQuery, OpenT
aggregatorsPromise: any; aggregatorsPromise: any;
filterTypesPromise: any; filterTypesPromise: any;
constructor( constructor(instanceSettings: any, private readonly templateSrv: TemplateSrv = getTemplateSrv()) {
instanceSettings: any,
private readonly templateSrv: TemplateSrv = getTemplateSrv()
) {
super(instanceSettings); super(instanceSettings);
this.type = 'opentsdb'; this.type = 'opentsdb';
this.url = instanceSettings.url; this.url = instanceSettings.url;

View File

@ -18,10 +18,7 @@ import { PromQueryRequest } from './types';
export default class PrometheusMetricFindQuery { export default class PrometheusMetricFindQuery {
range: TimeRange; range: TimeRange;
constructor( constructor(private datasource: PrometheusDatasource, private query: string) {
private datasource: PrometheusDatasource,
private query: string
) {
this.datasource = datasource; this.datasource = datasource;
this.query = query; this.query = query;
this.range = getTimeSrv().timeRange(); this.range = getTimeSrv().timeRange();

View File

@ -71,16 +71,13 @@ export const binaryScalarDefs = [
}, },
]; ];
export const binaryScalarOperatorToOperatorName = binaryScalarDefs.reduce( export const binaryScalarOperatorToOperatorName = binaryScalarDefs.reduce((acc, def) => {
(acc, def) => { acc[def.sign] = {
acc[def.sign] = { id: def.id,
id: def.id, comparison: def.comparison,
comparison: def.comparison, };
}; return acc;
return acc; }, {} as Record<string, { id: string; comparison?: boolean }>);
},
{} as Record<string, { id: string; comparison?: boolean }>
);
// Not sure about this one. It could also be a more generic 'Simple math operation' where user specifies // Not sure about this one. It could also be a more generic 'Simple math operation' where user specifies
// both the operator and the operand in a single input // both the operator and the operand in a single input

View File

@ -85,9 +85,11 @@ export function LabelFilters({
{variableEditor ? ( {variableEditor ? (
<InlineFieldRow> <InlineFieldRow>
<div <div
className={cx(css` className={cx(
display: flex; css`
`)} display: flex;
`
)}
> >
<InlineLabel <InlineLabel
width={20} width={20}

View File

@ -67,7 +67,7 @@ async function setupTestContext({
getStream: () => getStream: () =>
({ ({
subscribe: jest.fn(), subscribe: jest.fn(),
}) as any, } as any),
publish: jest.fn(), publish: jest.fn(),
removeAllListeners: jest.fn(), removeAllListeners: jest.fn(),
newScopedBus: jest.fn(), newScopedBus: jest.fn(),

View File

@ -50,13 +50,7 @@ export class Quadtree {
o: Rect[]; o: Rect[];
q: Quads | null; q: Quads | null;
constructor( constructor(public x: number, public y: number, public w: number, public h: number, public l: number = 0) {
public x: number,
public y: number,
public w: number,
public h: number,
public l: number = 0
) {
this.o = []; this.o = [];
this.q = null; this.q = null;
} }

View File

@ -15,10 +15,7 @@ export class TablePanelEditorCtrl {
static $inject = ['$scope', 'uiSegmentSrv']; static $inject = ['$scope', 'uiSegmentSrv'];
constructor( constructor($scope: any, private uiSegmentSrv: any) {
$scope: any,
private uiSegmentSrv: any
) {
$scope.editor = this; $scope.editor = this;
this.panelCtrl = $scope.ctrl; this.panelCtrl = $scope.ctrl;
this.panel = this.panelCtrl.panel; this.panel = this.panelCtrl.panel;

View File

@ -56,12 +56,7 @@ export class TablePanelCtrl extends MetricsPanelCtrl {
static $inject = ['$scope', '$injector', 'annotationsSrv', '$sanitize']; static $inject = ['$scope', '$injector', 'annotationsSrv', '$sanitize'];
constructor( constructor($scope: any, $injector: any, private annotationsSrv: any, private $sanitize: any) {
$scope: any,
$injector: any,
private annotationsSrv: any,
private $sanitize: any
) {
super($scope, $injector); super($scope, $injector);
this.pageIndex = 0; this.pageIndex = 0;

View File

@ -82,7 +82,9 @@ export const AnnotationTooltip = ({
{alertText} {alertText}
<> <>
<HorizontalGroup spacing="xs" wrap> <HorizontalGroup spacing="xs" wrap>
{tags?.map((t, i) => <Tag name={t} key={`${t}-${i}`} />)} {tags?.map((t, i) => (
<Tag name={t} key={`${t}-${i}`} />
))}
</HorizontalGroup> </HorizontalGroup>
</> </>
</div> </div>

View File

@ -1,8 +1,7 @@
@font-face { @font-face {
font-family: 'grafana-icons'; font-family: 'grafana-icons';
src: url('../fonts/grafana-icons.eot?okx5td'); src: url('../fonts/grafana-icons.eot?okx5td');
src: src: url('../fonts/grafana-icons.eot?okx5td#iefix') format('embedded-opentype'),
url('../fonts/grafana-icons.eot?okx5td#iefix') format('embedded-opentype'),
url('../fonts/grafana-icons.ttf?okx5td') format('truetype'), url('../fonts/grafana-icons.ttf?okx5td') format('truetype'),
url('../fonts/grafana-icons.woff?okx5td') format('woff'), url('../fonts/grafana-icons.woff?okx5td') format('woff'),
url('../fonts/grafana-icons.svg?okx5td#grafana-icons') format('svg'); url('../fonts/grafana-icons.svg?okx5td#grafana-icons') format('svg');

View File

@ -4,8 +4,7 @@
@font-face { @font-face {
font-family: 'FontAwesome'; font-family: 'FontAwesome';
src: url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}'); src: url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}');
src: src: url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'),
url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'),
url('#{$fa-font-path}/fontawesome-webfont.woff2?v=#{$fa-version}') format('woff2'), url('#{$fa-font-path}/fontawesome-webfont.woff2?v=#{$fa-version}') format('woff2'),
url('#{$fa-font-path}/fontawesome-webfont.woff?v=#{$fa-version}') format('woff'), url('#{$fa-font-path}/fontawesome-webfont.woff?v=#{$fa-version}') format('woff'),
url('#{$fa-font-path}/fontawesome-webfont.ttf?v=#{$fa-version}') format('truetype'), url('#{$fa-font-path}/fontawesome-webfont.ttf?v=#{$fa-version}') format('truetype'),

View File

@ -20,12 +20,8 @@
.ps__rail-x { .ps__rail-x {
display: none; display: none;
opacity: 0; opacity: 0;
transition: transition: background-color 0.2s linear, opacity 0.2s linear;
background-color 0.2s linear, -webkit-transition: background-color 0.2s linear, opacity 0.2s linear;
opacity 0.2s linear;
-webkit-transition:
background-color 0.2s linear,
opacity 0.2s linear;
height: 15px; height: 15px;
/* there must be 'bottom' or 'top' for ps__rail-x */ /* there must be 'bottom' or 'top' for ps__rail-x */
bottom: 0px; bottom: 0px;
@ -36,12 +32,8 @@
.ps__rail-y { .ps__rail-y {
display: none; display: none;
opacity: 0; opacity: 0;
transition: transition: background-color 0.2s linear, opacity 0.2s linear;
background-color 0.2s linear, -webkit-transition: background-color 0.2s linear, opacity 0.2s linear;
opacity 0.2s linear;
-webkit-transition:
background-color 0.2s linear,
opacity 0.2s linear;
width: 15px; width: 15px;
/* there must be 'right' or 'left' for ps__rail-y */ /* there must be 'right' or 'left' for ps__rail-y */
right: 0; right: 0;
@ -250,9 +242,7 @@
// height: 15px; // height: 15px;
width: 15px; width: 15px;
transition: transition: background-color 0.2s linear, opacity 0.2s linear;
background-color 0.2s linear,
opacity 0.2s linear;
opacity: 0; opacity: 0;
} }

View File

@ -61,11 +61,8 @@
display: block; display: block;
white-space: nowrap; white-space: nowrap;
cursor: pointer; cursor: pointer;
transition: transition: color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), border-color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1),
color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), background 0.3s cubic-bezier(0.645, 0.045, 0.355, 1), padding 0.15s cubic-bezier(0.645, 0.045, 0.355, 1);
border-color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1),
background 0.3s cubic-bezier(0.645, 0.045, 0.355, 1),
padding 0.15s cubic-bezier(0.645, 0.045, 0.355, 1);
} }
.typeahead-item__selected { .typeahead-item__selected {

View File

@ -36,9 +36,7 @@
} }
&:hover { &:hover {
box-shadow: box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
inset 0 1px 0 rgba(255, 255, 255, 0.2),
0 1px 2px rgba(0, 0, 0, 0.05);
&:active { &:active {
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);

View File

@ -15,8 +15,8 @@ export function forceObservableCompletion(subscription: Subscription, resolve: (
`${matcherHint('.toEmitValues')} `${matcherHint('.toEmitValues')}
Expected ${printReceived('Observable')} to be ${printExpected( Expected ${printReceived('Observable')} to be ${printExpected(
`completed within ${OBSERVABLE_TEST_TIMEOUT_IN_MS}ms` `completed within ${OBSERVABLE_TEST_TIMEOUT_IN_MS}ms`
)} but it did not.`, )} but it did not.`,
}); });
}) })
); );

View File

@ -12,10 +12,7 @@ import {
} from '@grafana/data'; } from '@grafana/data';
export class DatasourceSrvMock { export class DatasourceSrvMock {
constructor( constructor(private defaultDS: DataSourceApi, private datasources: { [name: string]: DataSourceApi }) {
private defaultDS: DataSourceApi,
private datasources: { [name: string]: DataSourceApi }
) {
// //
} }

View File

@ -19502,7 +19502,7 @@ __metadata:
postcss-loader: 7.3.3 postcss-loader: 7.3.3
postcss-reporter: 7.0.5 postcss-reporter: 7.0.5
postcss-scss: 4.0.6 postcss-scss: 4.0.6
prettier: 3.0.0 prettier: 2.8.4
prismjs: 1.29.0 prismjs: 1.29.0
prop-types: 15.8.1 prop-types: 15.8.1
pseudoizer: ^0.1.0 pseudoizer: ^0.1.0
@ -26332,12 +26332,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"prettier@npm:3.0.0": "prettier@npm:2.8.4":
version: 3.0.0 version: 2.8.4
resolution: "prettier@npm:3.0.0" resolution: "prettier@npm:2.8.4"
bin: bin:
prettier: bin/prettier.cjs prettier: bin-prettier.js
checksum: 6a832876a1552dc58330d2467874e5a0b46b9ccbfc5d3531eb69d15684743e7f83dc9fbd202db6270446deba9c82b79d24383d09924c462b457136a759425e33 checksum: c173064bf3df57b6d93d19aa98753b9b9dd7657212e33b41ada8e2e9f9884066bb9ca0b4005b89b3ab137efffdf8fbe0b462785aba20364798ff4303aadda57e
languageName: node languageName: node
linkType: hard linkType: hard