Chore: Bumps prettier version for new typescript syntax support (#20463)

* Chore: Bumps prettier version for new typescript syntax support

* Ran new version of prettier against the codebase
This commit is contained in:
kay delaney
2019-11-19 13:59:39 +00:00
committed by GitHub
parent af35e081c2
commit ca3dff99e8
141 changed files with 2277 additions and 867 deletions

View File

@@ -116,7 +116,7 @@
"postcss-browser-reporter": "0.5.0",
"postcss-loader": "3.0.0",
"postcss-reporter": "6.0.1",
"prettier": "1.16.4",
"prettier": "1.19.1",
"puppeteer-core": "1.15.0",
"react-hooks-testing-library": "0.3.7",
"react-hot-loader": "4.8.0",

View File

@@ -15,7 +15,10 @@ describe('toDataFrame', () => {
it('converts timeseries to series', () => {
const input1 = {
target: 'Field Name',
datapoints: [[100, 1], [200, 2]],
datapoints: [
[100, 1],
[200, 2],
],
};
let series = toDataFrame(input1);
expect(series.fields[0].name).toBe(input1.target);
@@ -33,7 +36,10 @@ describe('toDataFrame', () => {
const input2 = {
// without target
target: '',
datapoints: [[100, 1], [200, 2]],
datapoints: [
[100, 1],
[200, 2],
],
};
series = toDataFrame(input2);
expect(series.fields[0].name).toEqual('Value');
@@ -42,7 +48,10 @@ describe('toDataFrame', () => {
it('assumes TimeSeries values are numbers', () => {
const input1 = {
target: 'time',
datapoints: [[100, 1], [200, 2]],
datapoints: [
[100, 1],
[200, 2],
],
};
const data = toDataFrame(input1);
expect(data.fields[0].type).toBe(FieldType.number);
@@ -50,7 +59,10 @@ describe('toDataFrame', () => {
it('keeps dataFrame unchanged', () => {
const input = toDataFrame({
datapoints: [[100, 1], [200, 2]],
datapoints: [
[100, 1],
[200, 2],
],
});
expect(input.length).toEqual(2);
@@ -71,7 +83,11 @@ describe('toDataFrame', () => {
it('migrate from 6.3 style rows', () => {
const oldDataFrame = {
fields: [{ name: 'A' }, { name: 'B' }, { name: 'C' }],
rows: [[100, 'A', 1], [200, 'B', 2], [300, 'C', 3]],
rows: [
[100, 'A', 1],
[200, 'B', 2],
[300, 'C', 3],
],
};
const data = toDataFrame(oldDataFrame);
expect(data.length).toBe(oldDataFrame.rows.length);
@@ -149,7 +165,10 @@ describe('SerisData backwards compatibility', () => {
it('can convert TimeSeries to series and back again', () => {
const timeseries = {
target: 'Field Name',
datapoints: [[100, 1], [200, 2]],
datapoints: [
[100, 1],
[200, 2],
],
};
const series = toDataFrame(timeseries);
expect(isDataFrame(timeseries)).toBeFalsy();
@@ -175,8 +194,15 @@ describe('SerisData backwards compatibility', () => {
it('converts TableData to series and back again', () => {
const table = {
columns: [{ text: 'a', unit: 'ms' }, { text: 'b', unit: 'zz' }, { text: 'c', unit: 'yy' }],
rows: [[100, 1, 'a'], [200, 2, 'a']],
columns: [
{ text: 'a', unit: 'ms' },
{ text: 'b', unit: 'zz' },
{ text: 'c', unit: 'yy' },
],
rows: [
[100, 1, 'a'],
[200, 2, 'a'],
],
};
const series = toDataFrame(table);
expect(isTableData(table)).toBeTruthy();

View File

@@ -26,7 +26,11 @@ function createField<T>(name: string, values?: T[], type?: FieldType): Field<T>
describe('Stats Calculators', () => {
const basicTable = new MutableDataFrame({
fields: [{ name: 'a', values: [10, 20] }, { name: 'b', values: [20, 30] }, { name: 'c', values: [30, 40] }],
fields: [
{ name: 'a', values: [10, 20] },
{ name: 'b', values: [20, 30] },
{ name: 'c', values: [30, 40] },
],
});
it('should load all standard stats', () => {

View File

@@ -56,7 +56,16 @@ describe('getFlotPairsConstant', () => {
it('should return an constant series for range', () => {
const range: TimeRange = makeRange(0, 1);
const pairs = getFlotPairsConstant([[2, 123], [4, 456]], range);
expect(pairs).toMatchObject([[0, 123], [1, 123]]);
const pairs = getFlotPairsConstant(
[
[2, 123],
[4, 456],
],
range
);
expect(pairs).toMatchObject([
[0, 123],
[1, 123],
]);
});
});

View File

@@ -61,5 +61,8 @@ export function getFlotPairsConstant(seriesData: GraphSeriesValue[][], range: Ti
const from = range.from.valueOf();
const to = range.to.valueOf();
const value = seriesData[0][1];
return [[from, value], [to, value]];
return [
[from, value],
[to, value],
];
}

View File

@@ -23,32 +23,29 @@ export function parseLabels(labels: string): Labels {
* Returns a map labels that are common to the given label sets.
*/
export function findCommonLabels(labelsSets: Labels[]): Labels {
return labelsSets.reduce(
(acc, labels) => {
if (!labels) {
throw new Error('Need parsed labels to find common labels.');
}
if (!acc) {
// Initial set
acc = { ...labels };
} else {
// Remove incoming labels that are missing or not matching in value
Object.keys(labels).forEach(key => {
if (acc[key] === undefined || acc[key] !== labels[key]) {
delete acc[key];
}
});
// Remove common labels that are missing from incoming label set
Object.keys(acc).forEach(key => {
if (labels[key] === undefined) {
delete acc[key];
}
});
}
return acc;
},
(undefined as unknown) as Labels
);
return labelsSets.reduce((acc, labels) => {
if (!labels) {
throw new Error('Need parsed labels to find common labels.');
}
if (!acc) {
// Initial set
acc = { ...labels };
} else {
// Remove incoming labels that are missing or not matching in value
Object.keys(labels).forEach(key => {
if (acc[key] === undefined || acc[key] !== labels[key]) {
delete acc[key];
}
});
// Remove common labels that are missing from incoming label set
Object.keys(acc).forEach(key => {
if (labels[key] === undefined) {
delete acc[key];
}
});
}
return acc;
}, (undefined as unknown) as Labels);
}
/**

View File

@@ -64,18 +64,15 @@ const addRangeToTextMappingText = (
};
const getAllFormattedValueMappings = (valueMappings: ValueMapping[], value: TimeSeriesValue) => {
const allFormattedValueMappings = valueMappings.reduce(
(allValueMappings, valueMapping) => {
if (valueMapping.type === MappingType.ValueToText) {
allValueMappings = addValueToTextMappingText(allValueMappings, valueMapping as ValueMap, value);
} else if (valueMapping.type === MappingType.RangeToText) {
allValueMappings = addRangeToTextMappingText(allValueMappings, valueMapping as RangeMap, value);
}
const allFormattedValueMappings = valueMappings.reduce((allValueMappings, valueMapping) => {
if (valueMapping.type === MappingType.ValueToText) {
allValueMappings = addValueToTextMappingText(allValueMappings, valueMapping as ValueMap, value);
} else if (valueMapping.type === MappingType.RangeToText) {
allValueMappings = addRangeToTextMappingText(allValueMappings, valueMapping as RangeMap, value);
}
return allValueMappings;
},
[] as ValueMapping[]
);
return allValueMappings;
}, [] as ValueMapping[]);
allFormattedValueMappings.sort((t1, t2) => {
return t1.id - t2.id;

View File

@@ -27,9 +27,12 @@ const startTaskRunner: TaskRunner<StartTaskOptions> = async ({ watchThemes, noTs
];
try {
await concurrently(jobs.filter(job => !!job), {
killOthers: ['failure', 'failure'],
});
await concurrently(
jobs.filter(job => !!job),
{
killOthers: ['failure', 'failure'],
}
);
} catch (e) {
console.error(e);
process.exit(1);

View File

@@ -26,7 +26,11 @@ function getProps(propOverrides?: Partial<Props>): Props {
maxValue: 100,
minValue: 0,
displayMode: 'basic',
thresholds: [{ value: -Infinity, color: 'green' }, { value: 70, color: 'orange' }, { value: 90, color: 'red' }],
thresholds: [
{ value: -Infinity, color: 'green' },
{ value: 70, color: 'orange' },
{ value: 90, color: 'red' },
],
height: 300,
width: 300,
value: {

View File

@@ -39,7 +39,14 @@ function addStoryForMode(options: StoryOptions) {
sparkline: {
minX: 0,
maxX: 5,
data: [[0, 10], [1, 20], [2, 15], [3, 25], [4, 5], [5, 10]],
data: [
[0, 10],
[1, 20],
[2, 15],
[3, 25],
[4, 5],
[5, 10],
],
},
});
});

View File

@@ -9,7 +9,14 @@ const getKnobs = () => {
disabled: boolean('Disabled', false),
text: text('Button Text', 'Click me!'),
options: object('Options', [
{ label: 'A', value: 'A', children: [{ label: 'B', value: 'B' }, { label: 'C', value: 'C' }] },
{
label: 'A',
value: 'A',
children: [
{ label: 'B', value: 'B' },
{ label: 'C', value: 'C' },
],
},
{ label: 'D', value: 'D' },
]),
};

View File

@@ -71,10 +71,11 @@ const getPropertiesForVariant = (theme: GrafanaTheme, variant: ButtonVariant) =>
return {
borderColor: selectThemeVariant({ light: theme.colors.gray70, dark: theme.colors.gray33 }, theme.type),
background: buttonVariantStyles(from, to, selectThemeVariant(
{ light: theme.colors.gray25, dark: theme.colors.gray4 },
theme.type
) as string),
background: buttonVariantStyles(
from,
to,
selectThemeVariant({ light: theme.colors.gray25, dark: theme.colors.gray4 }, theme.type) as string
),
};
case 'destructive':

View File

@@ -28,7 +28,11 @@ const getKnobs = () => {
const series: GraphSeriesXY[] = [
{
data: [[1546372800000, 10], [1546376400000, 20], [1546380000000, 10]],
data: [
[1546372800000, 10],
[1546376400000, 20],
[1546380000000, 10],
],
color: 'red',
isVisible: true,
label: 'A-series',
@@ -51,7 +55,11 @@ const series: GraphSeriesXY[] = [
},
},
{
data: [[1546372800000, 20], [1546376400000, 30], [1546380000000, 40]],
data: [
[1546372800000, 20],
[1546376400000, 30],
[1546380000000, 40],
],
color: 'blue',
isVisible: true,
label:

View File

@@ -6,7 +6,11 @@ import { GraphSeriesXY, FieldType, ArrayVector, dateTime } from '@grafana/data';
const series: GraphSeriesXY[] = [
{
data: [[1546372800000, 10], [1546376400000, 20], [1546380000000, 10]],
data: [
[1546372800000, 10],
[1546376400000, 20],
[1546380000000, 10],
],
color: 'red',
isVisible: true,
label: 'A-series',
@@ -29,7 +33,11 @@ const series: GraphSeriesXY[] = [
},
},
{
data: [[1546372800000, 20], [1546376400000, 30], [1546380000000, 40]],
data: [
[1546372800000, 20],
[1546376400000, 30],
[1546380000000, 40],
],
color: 'blue',
isVisible: true,
label: 'B-series',

View File

@@ -157,8 +157,14 @@ export class Graph extends PureComponent<GraphProps, GraphState> {
const tooltipContentProps: TooltipContentProps<GraphDimensions> = {
dimensions: {
// time/value dimension columns are index-aligned - see getGraphSeriesModel
xAxis: createDimension('xAxis', series.map(s => s.timeField)),
yAxis: createDimension('yAxis', series.map(s => s.valueField)),
xAxis: createDimension(
'xAxis',
series.map(s => s.timeField)
),
yAxis: createDimension(
'yAxis',
series.map(s => s.valueField)
),
},
activeDimensions,
pos,

View File

@@ -43,7 +43,10 @@ export const GraphLegend: React.FunctionComponent<GraphLegendProps> = ({
})
.reduce(
(acc, current) => {
return union(acc, current.filter(item => !!item));
return union(
acc,
current.filter(item => !!item)
);
},
['']
) as string[];

View File

@@ -5,12 +5,10 @@ import { getMultiSeriesGraphHoverInfo } from '../utils';
import { FlotPosition } from '../types';
import { getValueFromDimension } from '@grafana/data';
export const MultiModeGraphTooltip: React.FC<
GraphTooltipContentProps & {
// We expect position to figure out correct values when not hovering over a datapoint
pos: FlotPosition;
}
> = ({ dimensions, activeDimensions, pos }) => {
export const MultiModeGraphTooltip: React.FC<GraphTooltipContentProps & {
// We expect position to figure out correct values when not hovering over a datapoint
pos: FlotPosition;
}> = ({ dimensions, activeDimensions, pos }) => {
let activeSeriesIndex: number | null = null;
// when no x-axis provided, skip rendering
if (activeDimensions.xAxis === null) {

View File

@@ -12,7 +12,11 @@ GraphWithLegendStories.addDecorator(withHorizontallyCenteredStory);
const series: GraphSeriesXY[] = [
{
data: [[1546372800000, 10], [1546376400000, 20], [1546380000000, 10]],
data: [
[1546372800000, 10],
[1546376400000, 20],
[1546380000000, 10],
],
color: 'red',
isVisible: true,
label: 'A-series',
@@ -35,7 +39,11 @@ const series: GraphSeriesXY[] = [
},
},
{
data: [[1546372800000, 20], [1546376400000, 30], [1546380000000, 40]],
data: [
[1546372800000, 20],
[1546376400000, 30],
[1546380000000, 40],
],
color: 'blue',
isVisible: true,
label: 'B-series',

View File

@@ -4,7 +4,11 @@ import { AbstractList } from './AbstractList';
describe('AbstractList', () => {
it('renders items using renderItem prop function', () => {
const items = [{ name: 'Item 1', id: 'item1' }, { name: 'Item 2', id: 'item2' }, { name: 'Item 3', id: 'item3' }];
const items = [
{ name: 'Item 1', id: 'item1' },
{ name: 'Item 2', id: 'item2' },
{ name: 'Item 3', id: 'item3' },
];
const list = shallow(
<AbstractList
@@ -22,7 +26,11 @@ describe('AbstractList', () => {
});
it('allows custom item key', () => {
const items = [{ name: 'Item 1', id: 'item1' }, { name: 'Item 2', id: 'item2' }, { name: 'Item 3', id: 'item3' }];
const items = [
{ name: 'Item 1', id: 'item1' },
{ name: 'Item 2', id: 'item2' },
{ name: 'Item 3', id: 'item3' },
];
const list = shallow(
<AbstractList

View File

@@ -35,71 +35,64 @@ export interface Props extends Themeable {
class UnThemedLogDetails extends PureComponent<Props> {
getParser = memoizeOne(getParser);
parseMessage = memoizeOne(
(rowEntry): FieldDef[] => {
const parser = this.getParser(rowEntry);
if (!parser) {
return [];
}
// Use parser to highlight detected fields
const parsedFields = parser.getFields(rowEntry);
const fields = parsedFields.map(field => {
const key = parser.getLabelFromField(field);
const value = parser.getValueFromField(field);
return { key, value };
});
return fields;
parseMessage = memoizeOne((rowEntry): FieldDef[] => {
const parser = this.getParser(rowEntry);
if (!parser) {
return [];
}
);
// Use parser to highlight detected fields
const parsedFields = parser.getFields(rowEntry);
const fields = parsedFields.map(field => {
const key = parser.getLabelFromField(field);
const value = parser.getValueFromField(field);
return { key, value };
});
getDerivedFields = memoizeOne(
(row: LogRowModel): FieldDef[] => {
return (
row.dataFrame.fields
.map((field, index) => ({ ...field, index }))
// Remove Id which we use for react key and entry field which we are showing as the log message.
.filter((field, index) => 'id' !== field.name && row.entryFieldIndex !== index)
// Filter out fields without values. For example in elastic the fields are parsed from the document which can
// have different structure per row and so the dataframe is pretty sparse.
.filter(field => {
const value = field.values.get(row.rowIndex);
// Not sure exactly what will be the empty value here. And we want to keep 0 as some values can be non
// string.
return value !== null && value !== undefined;
})
.map(field => {
const { getFieldLinks } = this.props;
const links = getFieldLinks ? getFieldLinks(field, row.rowIndex) : [];
return {
key: field.name,
value: field.values.get(row.rowIndex).toString(),
links: links.map(link => link.href),
fieldIndex: field.index,
};
})
);
}
);
return fields;
});
getDerivedFields = memoizeOne((row: LogRowModel): FieldDef[] => {
return (
row.dataFrame.fields
.map((field, index) => ({ ...field, index }))
// Remove Id which we use for react key and entry field which we are showing as the log message.
.filter((field, index) => 'id' !== field.name && row.entryFieldIndex !== index)
// Filter out fields without values. For example in elastic the fields are parsed from the document which can
// have different structure per row and so the dataframe is pretty sparse.
.filter(field => {
const value = field.values.get(row.rowIndex);
// Not sure exactly what will be the empty value here. And we want to keep 0 as some values can be non
// string.
return value !== null && value !== undefined;
})
.map(field => {
const { getFieldLinks } = this.props;
const links = getFieldLinks ? getFieldLinks(field, row.rowIndex) : [];
return {
key: field.name,
value: field.values.get(row.rowIndex).toString(),
links: links.map(link => link.href),
fieldIndex: field.index,
};
})
);
});
getAllFields = memoizeOne((row: LogRowModel) => {
const fields = this.parseMessage(row.entry);
const derivedFields = this.getDerivedFields(row);
const fieldsMap = [...derivedFields, ...fields].reduce(
(acc, field) => {
// Strip enclosing quotes for hashing. When values are parsed from log line the quotes are kept, but if same
// value is in the dataFrame it will be without the quotes. We treat them here as the same value.
const value = field.value.replace(/(^")|("$)/g, '');
const fieldHash = `${field.key}=${value}`;
if (acc[fieldHash]) {
acc[fieldHash].links = [...(acc[fieldHash].links || []), ...(field.links || [])];
} else {
acc[fieldHash] = field;
}
return acc;
},
{} as { [key: string]: FieldDef }
);
const fieldsMap = [...derivedFields, ...fields].reduce((acc, field) => {
// Strip enclosing quotes for hashing. When values are parsed from log line the quotes are kept, but if same
// value is in the dataFrame it will be without the quotes. We treat them here as the same value.
const value = field.value.replace(/(^")|("$)/g, '');
const fieldHash = `${field.key}=${value}`;
if (acc[fieldHash]) {
acc[fieldHash].links = [...(acc[fieldHash].links || []), ...(field.links || [])];
} else {
acc[fieldHash] = field;
}
return acc;
}, {} as { [key: string]: FieldDef });
return Object.values(fieldsMap);
});

View File

@@ -161,5 +161,9 @@ export const migratedTestStyles: ColumnStyle[] = [
export const simpleTable = {
type: 'table',
fields: [{ name: 'First' }, { name: 'Second' }, { name: 'Third' }],
rows: [[701, 205, 305], [702, 206, 301], [703, 207, 304]],
rows: [
[701, 205, 305],
[702, 206, 301],
[703, 207, 304],
],
};

View File

@@ -5,7 +5,10 @@ import { action } from '@storybook/addon-actions';
import { ThresholdsEditor } from './ThresholdsEditor';
const ThresholdsEditorStories = storiesOf('UI/ThresholdsEditor', module);
const thresholds = [{ index: 0, value: -Infinity, color: 'green' }, { index: 1, value: 50, color: 'red' }];
const thresholds = [
{ index: 0, value: -Infinity, color: 'green' },
{ index: 1, value: 50, color: 'red' },
];
ThresholdsEditorStories.add('default', () => {
return <ThresholdsEditor thresholds={[]} onChange={action('Thresholds changed')} />;

View File

@@ -159,9 +159,7 @@ const FilterPill: React.FC<FilterPillProps> = ({ label, selected, onClick }) =>
);
};
export const filterFramesByRefIdTransformRegistryItem: TransformerUIRegistyItem<
FilterFramesByRefIdTransformerOptions
> = {
export const filterFramesByRefIdTransformRegistryItem: TransformerUIRegistyItem<FilterFramesByRefIdTransformerOptions> = {
id: DataTransformerID.filterByRefId,
component: FilterByRefIdTransformerEditor,
transformer: transformersRegistry.get(DataTransformerID.filterByRefId),

View File

@@ -28,7 +28,12 @@ export class ValueMappingsEditor extends PureComponent<Props, State> {
}
getMaxIdFromValueMappings(mappings: ValueMapping[]) {
return Math.max.apply(null, mappings.map(mapping => mapping.id).map(m => m)) + 1;
return (
Math.max.apply(
null,
mappings.map(mapping => mapping.id).map(m => m)
) + 1
);
}
onAddMapping = () =>

View File

@@ -7,15 +7,12 @@ export enum EventsWithValidation {
}
export const validate = (value: string, validationRules: ValidationRule[]) => {
const errors = validationRules.reduce(
(acc, currRule) => {
if (!currRule.rule(value)) {
return acc.concat(currRule.errorMessage);
}
return acc;
},
[] as string[]
);
const errors = validationRules.reduce((acc, currRule) => {
if (!currRule.rule(value)) {
return acc.concat(currRule.errorMessage);
}
return acc;
}, [] as string[]);
return errors.length > 0 ? errors : null;
};

View File

@@ -145,9 +145,4 @@ export const mapStateToProps = (state: StoreState) => ({
const mapDispatchToProps = { updateLocation };
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(LoginCtrl)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(LoginCtrl));

View File

@@ -16,7 +16,11 @@ export interface State {
dashboards: DashboardSearchHit[];
}
const themes = [{ value: '', label: 'Default' }, { value: 'dark', label: 'Dark' }, { value: 'light', label: 'Light' }];
const themes = [
{ value: '', label: 'Default' },
{ value: 'dark', label: 'Dark' },
{ value: 'light', label: 'Light' },
];
const timezones = [
{ value: '', label: 'Default' },

View File

@@ -20,7 +20,12 @@ describe('file_export', () => {
},
{
alias: 'series_2',
datapoints: [[11, 1500026100000], [12, 1500026200000], [13, 1500026300000], [15, 1500026500000]],
datapoints: [
[11, 1500026100000],
[12, 1500026200000],
[13, 1500026300000],
[15, 1500026500000],
],
},
];

View File

@@ -56,7 +56,10 @@ describe('SearchCtrl', () => {
{
id: 0,
title: 'General',
items: [{ id: 3, selected: false }, { id: 5, selected: false }],
items: [
{ id: 3, selected: false },
{ id: 5, selected: false },
],
selected: false,
expanded: true,
toggle: (i: any) => (i.expanded = !i.expanded),
@@ -145,7 +148,10 @@ describe('SearchCtrl', () => {
{
id: 1,
title: 'folder',
items: [{ id: 2, selected: false }, { id: 4, selected: false }],
items: [
{ id: 2, selected: false },
{ id: 4, selected: false },
],
selected: true,
expanded: false,
toggle: (i: any) => (i.expanded = !i.expanded),
@@ -153,7 +159,10 @@ describe('SearchCtrl', () => {
{
id: 0,
title: 'General',
items: [{ id: 3, selected: false }, { id: 5, selected: false }],
items: [
{ id: 3, selected: false },
{ id: 5, selected: false },
],
selected: false,
expanded: true,
toggle: (i: any) => (i.expanded = !i.expanded),
@@ -249,7 +258,10 @@ describe('SearchCtrl', () => {
ctrl.results = [
{
hideHeader: true,
items: [{ id: 3, selected: true }, { id: 5, selected: false }],
items: [
{ id: 3, selected: true },
{ id: 5, selected: false },
],
selected: false,
expanded: true,
toggle: (i: any) => (i.expanded = !i.expanded),

View File

@@ -39,7 +39,10 @@ describe('SearchSrv', () => {
backendSrvMock.search = jest
.fn()
.mockReturnValueOnce(
Promise.resolve([{ id: 2, title: 'second but first' }, { id: 1, title: 'first but second' }])
Promise.resolve([
{ id: 2, title: 'second but first' },
{ id: 1, title: 'first but second' },
])
)
.mockReturnValue(Promise.resolve([]));
@@ -65,7 +68,12 @@ describe('SearchSrv', () => {
beforeEach(() => {
backendSrvMock.search = jest
.fn()
.mockReturnValueOnce(Promise.resolve([{ id: 2, title: 'two' }, { id: 1, title: 'one' }]))
.mockReturnValueOnce(
Promise.resolve([
{ id: 2, title: 'two' },
{ id: 1, title: 'one' },
])
)
.mockReturnValue(Promise.resolve([]));
impressionSrv.getDashboardOpened = jest.fn().mockReturnValue([4, 5, 1, 2, 3]);
@@ -107,7 +115,10 @@ describe('SearchSrv', () => {
backendSrvMock.search = jest
.fn()
.mockReturnValueOnce(
Promise.resolve([{ id: 1, title: 'starred and recent', isStarred: true }, { id: 2, title: 'recent' }])
Promise.resolve([
{ id: 1, title: 'starred and recent', isStarred: true },
{ id: 2, title: 'recent' },
])
)
.mockReturnValue(Promise.resolve([{ id: 1, title: 'starred and recent' }]));

View File

@@ -10,7 +10,11 @@ describe('when sorting table desc', () => {
table = new TableModel();
// @ts-ignore
table.columns = [{}, {}];
table.rows = [[100, 12], [105, 10], [103, 11]];
table.rows = [
[100, 12],
[105, 10],
[103, 11],
];
table.sort(panel.sort);
});
@@ -36,7 +40,11 @@ describe('when sorting table asc', () => {
table = new TableModel();
// @ts-ignore
table.columns = [{}, {}];
table.rows = [[100, 11], [105, 15], [103, 10]];
table.rows = [
[100, 11],
[105, 15],
[103, 10],
];
table.sort(panel.sort);
});
@@ -55,7 +63,16 @@ describe('when sorting with nulls', () => {
table = new TableModel();
// @ts-ignore
table.columns = [{}, {}];
table.rows = [[42, ''], [19, 'a'], [null, 'b'], [0, 'd'], [null, null], [2, 'c'], [0, null], [-8, '']];
table.rows = [
[42, ''],
[19, 'a'],
[null, 'b'],
[0, 'd'],
[null, null],
[2, 'c'],
[0, null],
[-8, ''],
];
});
it('numbers with nulls at end with asc sort', () => {
@@ -141,7 +158,10 @@ describe('mergeTables', () => {
}),
({
target: 'series1',
datapoints: [[12.12, time], [14.44, time + 1]],
datapoints: [
[12.12, time],
[14.44, time + 1],
],
} as any) as TableModel,
];

View File

@@ -9,7 +9,12 @@ describe('TimeSeries', () => {
beforeEach(() => {
testData = {
alias: 'test',
datapoints: [[1, 2], [null, 3], [10, 4], [8, 5]],
datapoints: [
[1, 2],
[null, 3],
[10, 4],
[8, 5],
],
};
});
@@ -29,7 +34,10 @@ describe('TimeSeries', () => {
it('if last is null current should pick next to last', () => {
series = new TimeSeries({
datapoints: [[10, 1], [null, 2]],
datapoints: [
[10, 1],
[null, 2],
],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.current).toBe(10);
@@ -37,7 +45,10 @@ describe('TimeSeries', () => {
it('max value should work for negative values', () => {
series = new TimeSeries({
datapoints: [[-10, 1], [-4, 2]],
datapoints: [
[-10, 1],
[-4, 2],
],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.max).toBe(-4);
@@ -51,7 +62,13 @@ describe('TimeSeries', () => {
it('the delta value should account for nulls', () => {
series = new TimeSeries({
datapoints: [[1, 2], [3, 3], [null, 4], [10, 5], [15, 6]],
datapoints: [
[1, 2],
[3, 3],
[null, 4],
[10, 5],
[15, 6],
],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(14);
@@ -59,7 +76,12 @@ describe('TimeSeries', () => {
it('the delta value should account for nulls on first', () => {
series = new TimeSeries({
datapoints: [[null, 2], [1, 3], [10, 4], [15, 5]],
datapoints: [
[null, 2],
[1, 3],
[10, 4],
[15, 5],
],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(14);
@@ -67,7 +89,12 @@ describe('TimeSeries', () => {
it('the delta value should account for nulls on last', () => {
series = new TimeSeries({
datapoints: [[1, 2], [5, 3], [10, 4], [null, 5]],
datapoints: [
[1, 2],
[5, 3],
[10, 4],
[null, 5],
],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(9);
@@ -75,7 +102,13 @@ describe('TimeSeries', () => {
it('the delta value should account for resets', () => {
series = new TimeSeries({
datapoints: [[1, 2], [5, 3], [10, 4], [0, 5], [10, 6]],
datapoints: [
[1, 2],
[5, 3],
[10, 4],
[0, 5],
[10, 6],
],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(19);
@@ -83,7 +116,12 @@ describe('TimeSeries', () => {
it('the delta value should account for resets on last', () => {
series = new TimeSeries({
datapoints: [[1, 2], [2, 3], [10, 4], [8, 5]],
datapoints: [
[1, 2],
[2, 3],
[10, 4],
[8, 5],
],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.delta).toBe(17);
@@ -100,7 +138,12 @@ describe('TimeSeries', () => {
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.first).toBe(1);
series = new TimeSeries({
datapoints: [[null, 2], [1, 3], [10, 4], [8, 5]],
datapoints: [
[null, 2],
[1, 3],
[10, 4],
[8, 5],
],
});
series.getFlotPairs('null', yAxisFormats);
expect(series.stats.first).toBe(1);
@@ -114,7 +157,12 @@ describe('TimeSeries', () => {
it('average value should be null if all values is null', () => {
series = new TimeSeries({
datapoints: [[null, 2], [null, 3], [null, 4], [null, 5]],
datapoints: [
[null, 2],
[null, 3],
[null, 4],
[null, 5],
],
});
series.getFlotPairs('null');
expect(series.stats.avg).toBe(null);
@@ -122,13 +170,21 @@ describe('TimeSeries', () => {
it('calculates timeStep', () => {
series = new TimeSeries({
datapoints: [[null, 1], [null, 2], [null, 3]],
datapoints: [
[null, 1],
[null, 2],
[null, 3],
],
});
series.getFlotPairs('null');
expect(series.stats.timeStep).toBe(1);
series = new TimeSeries({
datapoints: [[0, 1530529290], [0, 1530529305], [0, 1530529320]],
datapoints: [
[0, 1530529290],
[0, 1530529305],
[0, 1530529320],
],
});
series.getFlotPairs('null');
expect(series.stats.timeStep).toBe(15);
@@ -139,7 +195,10 @@ describe('TimeSeries', () => {
describe('msResolution with second resolution timestamps', () => {
beforeEach(() => {
series = new TimeSeries({
datapoints: [[45, 1234567890], [60, 1234567899]],
datapoints: [
[45, 1234567890],
[60, 1234567899],
],
});
});
@@ -151,7 +210,10 @@ describe('TimeSeries', () => {
describe('msResolution with millisecond resolution timestamps', () => {
beforeEach(() => {
series = new TimeSeries({
datapoints: [[55, 1236547890001], [90, 1234456709000]],
datapoints: [
[55, 1236547890001],
[90, 1234456709000],
],
});
});
@@ -163,7 +225,10 @@ describe('TimeSeries', () => {
describe('msResolution with millisecond resolution timestamps but with trailing zeroes', () => {
beforeEach(() => {
series = new TimeSeries({
datapoints: [[45, 1234567890000], [60, 1234567899000]],
datapoints: [
[45, 1234567890000],
[60, 1234567899000],
],
});
});
@@ -333,7 +398,12 @@ describe('TimeSeries', () => {
beforeEach(() => {
testData = {
alias: 'test',
datapoints: [[1, 2], [0, 3], [10, 4], [8, 5]],
datapoints: [
[1, 2],
[0, 3],
[10, 4],
[8, 5],
],
};
series = new TimeSeries(testData);
series.getFlotPairs();
@@ -355,7 +425,12 @@ describe('TimeSeries', () => {
});
it('should set decimals based on Y axis to 0 if calculated decimals = 0)', () => {
testData.datapoints = [[10, 2], [0, 3], [100, 4], [80, 5]];
testData.datapoints = [
[10, 2],
[0, 3],
[100, 4],
[80, 5],
];
series = new TimeSeries(testData);
series.getFlotPairs();
const data = [series];

View File

@@ -107,19 +107,16 @@ export function mergeTablesIntoModel(dst?: TableModel, ...tables: TableModel[]):
const columnNames: { [key: string]: any } = {};
// Union of all non-value columns
const columnsUnion = tableDataTables.slice().reduce(
(acc, series) => {
series.columns.forEach(col => {
const { text } = col;
if (columnNames[text] === undefined) {
columnNames[text] = acc.length;
acc.push(col);
}
});
return acc;
},
[] as MutableColumn[]
);
const columnsUnion = tableDataTables.slice().reduce((acc, series) => {
series.columns.forEach(col => {
const { text } = col;
if (columnNames[text] === undefined) {
columnNames[text] = acc.length;
acc.push(col);
}
});
return acc;
}, [] as MutableColumn[]);
// Map old column index to union index per series, e.g.,
// given columnNames {A: 0, B: 1} and
@@ -127,57 +124,51 @@ export function mergeTablesIntoModel(dst?: TableModel, ...tables: TableModel[]):
const columnIndexMapper = tableDataTables.map(series => series.columns.map(col => columnNames[col.text]));
// Flatten rows of all series and adjust new column indexes
const flattenedRows = tableDataTables.reduce(
(acc, series, seriesIndex) => {
const mapper = columnIndexMapper[seriesIndex];
series.rows.forEach(row => {
const alteredRow: MutableColumn[] = [];
// Shifting entries according to index mapper
mapper.forEach((to, from) => {
alteredRow[to] = row[from];
});
acc.push(alteredRow);
const flattenedRows = tableDataTables.reduce((acc, series, seriesIndex) => {
const mapper = columnIndexMapper[seriesIndex];
series.rows.forEach(row => {
const alteredRow: MutableColumn[] = [];
// Shifting entries according to index mapper
mapper.forEach((to, from) => {
alteredRow[to] = row[from];
});
return acc;
},
[] as MutableColumn[][]
);
acc.push(alteredRow);
});
return acc;
}, [] as MutableColumn[][]);
// Merge rows that have same values for columns
const mergedRows: { [key: string]: any } = {};
const compactedRows = flattenedRows.reduce(
(acc, row, rowIndex) => {
if (!mergedRows[rowIndex]) {
// Look from current row onwards
let offset = rowIndex + 1;
// More than one row can be merged into current row
while (offset < flattenedRows.length) {
// Find next row that could be merged
const match = _.findIndex(flattenedRows, otherRow => areRowsMatching(columnsUnion, row, otherRow), offset);
if (match > -1) {
const matchedRow = flattenedRows[match];
// Merge values from match into current row if there is a gap in the current row
for (let columnIndex = 0; columnIndex < columnsUnion.length; columnIndex++) {
if (row[columnIndex] === undefined && matchedRow[columnIndex] !== undefined) {
row[columnIndex] = matchedRow[columnIndex];
}
const compactedRows = flattenedRows.reduce((acc, row, rowIndex) => {
if (!mergedRows[rowIndex]) {
// Look from current row onwards
let offset = rowIndex + 1;
// More than one row can be merged into current row
while (offset < flattenedRows.length) {
// Find next row that could be merged
const match = _.findIndex(flattenedRows, otherRow => areRowsMatching(columnsUnion, row, otherRow), offset);
if (match > -1) {
const matchedRow = flattenedRows[match];
// Merge values from match into current row if there is a gap in the current row
for (let columnIndex = 0; columnIndex < columnsUnion.length; columnIndex++) {
if (row[columnIndex] === undefined && matchedRow[columnIndex] !== undefined) {
row[columnIndex] = matchedRow[columnIndex];
}
// Don't visit this row again
mergedRows[match] = matchedRow;
// Keep looking for more rows to merge
offset = match + 1;
} else {
// No match found, stop looking
break;
}
// Don't visit this row again
mergedRows[match] = matchedRow;
// Keep looking for more rows to merge
offset = match + 1;
} else {
// No match found, stop looking
break;
}
acc.push(row);
}
return acc;
},
[] as MutableColumn[][]
);
acc.push(row);
}
return acc;
}, [] as MutableColumn[][]);
model.columns = columnsUnion;
model.rows = compactedRows;

View File

@@ -8,7 +8,10 @@ import { ServerStat } from './state/apis';
describe('ServerStats', () => {
it('Should render table with stats', done => {
const navModel = createNavModel('Admin', 'stats');
const stats: ServerStat[] = [{ name: 'Total dashboards', value: 10 }, { name: 'Total Users', value: 1 }];
const stats: ServerStat[] = [
{ name: 'Total dashboards', value: 10 },
{ name: 'Total Users', value: 1 },
];
const getServerStats = () => {
return Promise.resolve(stats);

View File

@@ -132,9 +132,4 @@ const mapDispatchToProps = {
clearUserMappingInfo,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(LdapPage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(LdapPage));

View File

@@ -158,9 +158,4 @@ const mapDispatchToProps = {
clearUserError,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(LdapUserPage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(LdapUserPage));

View File

@@ -150,9 +150,4 @@ const mapDispatchToProps = {
togglePauseAlertRule,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(AlertRuleList)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(AlertRuleList));

View File

@@ -217,9 +217,4 @@ export const mapStateToProps = (state: StoreState) => ({});
const mapDispatchToProps = { changePanelEditorTab };
export const AlertTab = hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(UnConnectedAlertTab)
);
export const AlertTab = hot(module)(connect(mapStateToProps, mapDispatchToProps)(UnConnectedAlertTab));

View File

@@ -33,7 +33,10 @@ const evalFunctions = [
{ text: 'HAS NO VALUE', value: 'no_value' },
];
const evalOperators = [{ text: 'OR', value: 'or' }, { text: 'AND', value: 'and' }];
const evalOperators = [
{ text: 'OR', value: 'or' },
{ text: 'AND', value: 'and' },
];
const reducerTypes = [
{ text: 'avg()', value: 'avg' },
@@ -55,7 +58,10 @@ const noDataModes = [
{ text: 'Ok', value: 'ok' },
];
const executionErrorModes = [{ text: 'Alerting', value: 'alerting' }, { text: 'Keep Last State', value: 'keep_state' }];
const executionErrorModes = [
{ text: 'Alerting', value: 'alerting' },
{ text: 'Keep Last State', value: 'keep_state' },
];
function createReducerPart(model: any) {
const def = new QueryPartDef({ type: model.type, defaultParams: [] });

View File

@@ -51,9 +51,7 @@ export function annotationTooltipDirective(
let header = `<div class="graph-annotation__header">`;
if (event.login) {
header += `<div class="graph-annotation__user" bs-tooltip="'Created by ${event.login}'"><img src="${
event.avatarUrl
}" /></div>`;
header += `<div class="graph-annotation__user" bs-tooltip="'Created by ${event.login}'"><img src="${event.avatarUrl}" /></div>`;
}
header += `
<span class="graph-annotation__title ${titleStateClass}">${sanitizeString(title)}</span>

View File

@@ -44,7 +44,10 @@ export class AnnotationsEditorCtrl {
infoBoxTitle: 'What are annotations?',
};
showOptions: any = [{ text: 'All Panels', value: 0 }, { text: 'Specific Panels', value: 1 }];
showOptions: any = [
{ text: 'All Panels', value: 0 },
{ text: 'Specific Panels', value: 1 },
];
/** @ngInject */
constructor(private $scope: any, private datasourceSrv: DatasourceSrv) {

View File

@@ -9,7 +9,11 @@ describe('Annotations deduplication', () => {
{ id: 5, time: 5 },
{ id: 5, time: 5 },
];
const expectedAnnotations = [{ id: 1, time: 1 }, { id: 2, time: 2 }, { id: 5, time: 5 }];
const expectedAnnotations = [
{ id: 1, time: 1 },
{ id: 2, time: 2 },
{ id: 5, time: 5 },
];
const deduplicated = dedupAnnotations(testAnnotations);
expect(deduplicated).toEqual(expectedAnnotations);
@@ -23,7 +27,11 @@ describe('Annotations deduplication', () => {
{ id: 5, time: 5 },
{ id: 5, time: 5 },
];
const expectedAnnotations = [{ id: 1, time: 1 }, { id: 2, time: 2 }, { id: 5, time: 5 }];
const expectedAnnotations = [
{ id: 1, time: 1 },
{ id: 2, time: 2 },
{ id: 5, time: 5 },
];
const deduplicated = dedupAnnotations(testAnnotations);
expect(deduplicated).toEqual(expectedAnnotations);

View File

@@ -316,9 +316,4 @@ const mapDispatchToProps = {
addApiKey,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(ApiKeysPage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(ApiKeysPage));

View File

@@ -284,7 +284,4 @@ const mapDispatchToProps = {
updateLocation,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(DashNav);
export default connect(mapStateToProps, mapDispatchToProps)(DashNav);

View File

@@ -341,9 +341,4 @@ const mapDispatchToProps = {
updateLocation,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(DashboardPage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(DashboardPage));

View File

@@ -107,9 +107,4 @@ const mapDispatchToProps = {
initDashboard,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(SoloPanelPage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(SoloPanelPage));

View File

@@ -114,12 +114,7 @@ export const mapStateToProps = (state: StoreState) => getActiveTabAndTabs(state.
const mapDispatchToProps = { refreshPanelEditor, panelEditorCleanUp, changePanelEditorTab };
export const PanelEditor = hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(UnConnectedPanelEditor)
);
export const PanelEditor = hot(module)(connect(mapStateToProps, mapDispatchToProps)(UnConnectedPanelEditor));
interface TabItemParams {
tab: PanelEditorTab;

View File

@@ -175,7 +175,10 @@ describe('DashboardModel', () => {
model.rows = [createRow({ collapse: false, height: 8 }, [[6], [6]])];
const dashboard = new DashboardModel(model);
const panelGridPos = getGridPositions(dashboard);
const expectedGrid = [{ x: 0, y: 0, w: 12, h: 8 }, { x: 12, y: 0, w: 12, h: 8 }];
const expectedGrid = [
{ x: 0, y: 0, w: 12, h: 8 },
{ x: 12, y: 0, w: 12, h: 8 },
];
expect(panelGridPos).toEqual(expectedGrid);
});

View File

@@ -246,7 +246,10 @@ describe('given dashboard with row repeat and panel repeat in horizontal directi
text: 'reg1, reg2',
value: ['reg1', 'reg2'],
},
options: [{ text: 'reg1', value: 'reg1', selected: true }, { text: 'reg2', value: 'reg2', selected: true }],
options: [
{ text: 'reg1', value: 'reg1', selected: true },
{ text: 'reg2', value: 'reg2', selected: true },
],
},
{
name: 'app',

View File

@@ -255,16 +255,11 @@ export class PanelModel {
if (plugin.angularConfigCtrl) {
return;
}
this.options = _.mergeWith(
{},
plugin.defaults,
this.options || {},
(objValue: any, srcValue: any): any => {
if (_.isArray(srcValue)) {
return srcValue;
}
this.options = _.mergeWith({}, plugin.defaults, this.options || {}, (objValue: any, srcValue: any): any => {
if (_.isArray(srcValue)) {
return srcValue;
}
);
});
}
pluginLoaded(plugin: PanelPlugin) {

View File

@@ -56,7 +56,15 @@ function describeQueryRunnerScenario(description: string, scenarioFn: ScenarioFn
};
const response: any = {
data: [{ target: 'hello', datapoints: [[1, 1000], [2, 2000]] }],
data: [
{
target: 'hello',
datapoints: [
[1, 1000],
[2, 2000],
],
},
],
};
beforeEach(async () => {

View File

@@ -129,13 +129,7 @@ export function runRequest(datasource: DataSourceApi, request: DataQueryRequest)
// If 50ms without a response emit a loading state
// mapTo will translate the timer event into state.panelData (which has state set to loading)
// takeUntil will cancel the timer emit when first response packet is received on the dataObservable
return merge(
timer(200).pipe(
mapTo(state.panelData),
takeUntil(dataObservable)
),
dataObservable
);
return merge(timer(200).pipe(mapTo(state.panelData), takeUntil(dataObservable)), dataObservable);
}
function cancelNetworkRequestsOnUnsubscribe(req: DataQueryRequest) {

View File

@@ -99,9 +99,4 @@ const mapDispatchToProps = {
removeDashboard,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(DataSourceDashboards)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(DataSourceDashboards));

View File

@@ -116,9 +116,4 @@ const mapDispatchToProps = {
setDataSourcesLayoutMode,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(DataSourcesListPage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(DataSourcesListPage));

View File

@@ -105,16 +105,13 @@ class NewDataSourcePage extends PureComponent<Props> {
return null;
}
const categories = dataSourceTypes.reduce(
(accumulator, item) => {
const category = item.category || 'other';
const list = accumulator[category] || [];
list.push(item);
accumulator[category] = list;
return accumulator;
},
{} as DataSourceCategories
);
const categories = dataSourceTypes.reduce((accumulator, item) => {
const category = item.category || 'other';
const list = accumulator[category] || [];
list.push(item);
accumulator[category] = list;
return accumulator;
}, {} as DataSourceCategories);
categories['cloud'].push(getGrafanaCloudPhantomPlugin());
@@ -265,9 +262,4 @@ const mapDispatchToProps = {
setDataSourceTypeSearchQuery,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(NewDataSourcePage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(NewDataSourcePage));

View File

@@ -344,9 +344,4 @@ const mapDispatchToProps = {
dataSourceLoaded,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(DataSourceSettingsPage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(DataSourceSettingsPage));

View File

@@ -436,8 +436,5 @@ const mapDispatchToProps: Partial<ExploreProps> = {
export default hot(module)(
// @ts-ignore
connect(
mapStateToProps,
mapDispatchToProps
)(Explore)
connect(mapStateToProps, mapDispatchToProps)(Explore)
) as React.ComponentType<{ exploreId: ExploreId }>;

View File

@@ -158,9 +158,10 @@ class UnThemedExploreGraphPanel extends PureComponent<Props, State> {
<div className={cx([style.timeSeriesDisclaimer])}>
<i className={cx(['fa fa-fw fa-warning', style.disclaimerIcon])} />
{`Showing only ${MAX_NUMBER_OF_TIME_SERIES} time series. `}
<span className={cx([style.showAllTimeSeries])} onClick={this.onShowAllTimeSeries}>{`Show all ${
series.length
}`}</span>
<span
className={cx([style.showAllTimeSeries])}
onClick={this.onShowAllTimeSeries}
>{`Show all ${series.length}`}</span>
</div>
)}

View File

@@ -386,9 +386,4 @@ const mapDispatchToProps: DispatchProps = {
clearOrigin,
};
export const ExploreToolbar = hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(UnConnectedExploreToolbar)
);
export const ExploreToolbar = hot(module)(connect(mapStateToProps, mapDispatchToProps)(UnConnectedExploreToolbar));

View File

@@ -201,9 +201,4 @@ const mapDispatchToProps = {
updateTimeRange,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(LogsContainer)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(LogsContainer));

View File

@@ -213,7 +213,6 @@ const mapDispatchToProps = {
runQueries,
};
export default hot(module)(connect(
mapStateToProps,
mapDispatchToProps
)(QueryRow) as React.ComponentType<PropsFromParent>);
export default hot(module)(
connect(mapStateToProps, mapDispatchToProps)(QueryRow) as React.ComponentType<PropsFromParent>
);

View File

@@ -48,9 +48,4 @@ const mapDispatchToProps = {
toggleTable,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(TableContainer)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(TableContainer));

View File

@@ -50,9 +50,4 @@ const mapDispatchToProps = {
resetExploreAction,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(Wrapper)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(Wrapper));

View File

@@ -8,7 +8,11 @@ export const mockData = () => {
job: 'prometheus',
le: '+Inf',
},
values: [[1537858100, '16'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '16'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -18,7 +22,11 @@ export const mockData = () => {
job: 'prometheus',
le: '0.1',
},
values: [[1537858100, '16'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '16'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -28,7 +36,11 @@ export const mockData = () => {
job: 'prometheus',
le: '0.2',
},
values: [[1537858100, '16'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '16'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -38,7 +50,11 @@ export const mockData = () => {
job: 'prometheus',
le: '0.4',
},
values: [[1537858100, '16'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '16'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -48,7 +64,11 @@ export const mockData = () => {
job: 'prometheus',
le: '1',
},
values: [[1537858100, '16'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '16'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -58,7 +78,11 @@ export const mockData = () => {
job: 'prometheus',
le: '120',
},
values: [[1537858100, '16'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '16'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -68,7 +92,11 @@ export const mockData = () => {
job: 'prometheus',
le: '20',
},
values: [[1537858100, '16'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '16'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -78,7 +106,11 @@ export const mockData = () => {
job: 'prometheus',
le: '3',
},
values: [[1537858100, '16'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '16'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -88,7 +120,11 @@ export const mockData = () => {
job: 'prometheus',
le: '60',
},
values: [[1537858100, '16'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '16'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -98,7 +134,11 @@ export const mockData = () => {
job: 'prometheus',
le: '8',
},
values: [[1537858100, '16'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '16'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -108,7 +148,11 @@ export const mockData = () => {
job: 'prometheus',
le: '+Inf',
},
values: [[1537858060, '1195'], [1537858080, '1195'], [1537858100, '1195']],
values: [
[1537858060, '1195'],
[1537858080, '1195'],
[1537858100, '1195'],
],
},
{
metric: {
@@ -118,7 +162,11 @@ export const mockData = () => {
job: 'prometheus',
le: '0.1',
},
values: [[1537858060, '1195'], [1537858080, '1195'], [1537858100, '1195']],
values: [
[1537858060, '1195'],
[1537858080, '1195'],
[1537858100, '1195'],
],
},
{
metric: {
@@ -128,7 +176,11 @@ export const mockData = () => {
job: 'prometheus',
le: '0.4',
},
values: [[1537858060, '1195'], [1537858080, '1195'], [1537858100, '1195']],
values: [
[1537858060, '1195'],
[1537858080, '1195'],
[1537858100, '1195'],
],
},
{
metric: {
@@ -138,7 +190,11 @@ export const mockData = () => {
job: 'prometheus',
le: '1',
},
values: [[1537847900, '953'], [1537858080, '1195'], [1537858100, '1195']],
values: [
[1537847900, '953'],
[1537858080, '1195'],
[1537858100, '1195'],
],
},
{
metric: {
@@ -148,7 +204,11 @@ export const mockData = () => {
job: 'prometheus',
le: '120',
},
values: [[1537858060, '1195'], [1537858080, '1195'], [1537858100, '1195']],
values: [
[1537858060, '1195'],
[1537858080, '1195'],
[1537858100, '1195'],
],
},
{
metric: {
@@ -158,7 +218,11 @@ export const mockData = () => {
job: 'prometheus',
le: '20',
},
values: [[1537858060, '1195'], [1537858080, '1195'], [1537858100, '1195']],
values: [
[1537858060, '1195'],
[1537858080, '1195'],
[1537858100, '1195'],
],
},
{
metric: {
@@ -168,7 +232,11 @@ export const mockData = () => {
job: 'prometheus',
le: '3',
},
values: [[1537858060, '1195'], [1537858080, '1195'], [1537858100, '1195']],
values: [
[1537858060, '1195'],
[1537858080, '1195'],
[1537858100, '1195'],
],
},
{
metric: {
@@ -178,7 +246,11 @@ export const mockData = () => {
job: 'prometheus',
le: '60',
},
values: [[1537858060, '1195'], [1537858080, '1195'], [1537858100, '1195']],
values: [
[1537858060, '1195'],
[1537858080, '1195'],
[1537858100, '1195'],
],
},
{
metric: {
@@ -188,7 +260,11 @@ export const mockData = () => {
job: 'prometheus',
le: '8',
},
values: [[1537858060, '1195'], [1537858080, '1195'], [1537858100, '1195']],
values: [
[1537858060, '1195'],
[1537858080, '1195'],
[1537858100, '1195'],
],
},
{
metric: {
@@ -198,7 +274,11 @@ export const mockData = () => {
job: 'prometheus',
le: '+Inf',
},
values: [[1537858100, '55'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '55'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -208,7 +288,11 @@ export const mockData = () => {
job: 'prometheus',
le: '0.1',
},
values: [[1537858100, '55'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '55'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -218,7 +302,11 @@ export const mockData = () => {
job: 'prometheus',
le: '0.2',
},
values: [[1537858100, '55'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '55'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -228,7 +316,11 @@ export const mockData = () => {
job: 'prometheus',
le: '0.4',
},
values: [[1537858100, '55'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '55'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -238,7 +330,11 @@ export const mockData = () => {
job: 'prometheus',
le: '1',
},
values: [[1537858100, '55'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '55'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -248,7 +344,11 @@ export const mockData = () => {
job: 'prometheus',
le: '120',
},
values: [[1537858100, '55'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '55'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -258,7 +358,11 @@ export const mockData = () => {
job: 'prometheus',
le: '20',
},
values: [[1537858100, '55'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537858100, '55'],
[1537861960, '1'],
[1537861980, '1'],
],
},
{
metric: {
@@ -268,7 +372,11 @@ export const mockData = () => {
job: 'prometheus',
le: '3',
},
values: [[1537857260, '55'], [1537861960, '1'], [1537861980, '1']],
values: [
[1537857260, '55'],
[1537861960, '1'],
[1537861980, '1'],
],
},
];
};

View File

@@ -108,7 +108,11 @@ describe('ResultProcessor', () => {
{
label: 'A-series',
color: '#7EB26D',
data: [[100, 4], [200, 5], [300, 6]],
data: [
[100, 4],
[200, 5],
[300, 6],
],
info: undefined,
isVisible: true,
yAxis: {
@@ -135,7 +139,11 @@ describe('ResultProcessor', () => {
{ text: 'time', type: 'time', filterable: undefined },
{ text: 'message', type: 'string', filterable: undefined },
],
rows: [[4, 100, 'this is a message'], [5, 200, 'second message'], [6, 300, 'third']],
rows: [
[4, 100, 'this is a message'],
[5, 200, 'second message'],
[6, 300, 'third'],
],
type: 'table',
});
});
@@ -212,7 +220,11 @@ describe('ResultProcessor', () => {
{
label: 'A-series',
color: '#7EB26D',
data: [[100, 4], [200, 5], [300, 6]],
data: [
[100, 4],
[200, 5],
[300, 6],
],
info: undefined,
isVisible: true,
yAxis: {

View File

@@ -133,9 +133,4 @@ const mapDispatchToProps = {
addFolderPermission,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(FolderPermissions)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(FolderPermissions));

View File

@@ -115,9 +115,4 @@ const mapDispatchToProps = {
deleteFolder,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(FolderSettingsPage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(FolderSettingsPage));

View File

@@ -151,9 +151,7 @@ export class DashboardImportCtrl {
.then((res: any) => {
this.uidExists = true;
this.hasUidValidationError = true;
this.uidValidationError = `Dashboard named '${res.dashboard.title}' in folder '${
res.meta.folderTitle
}' has the same uid`;
this.uidValidationError = `Dashboard named '${res.dashboard.title}' in folder '${res.meta.folderTitle}' has the same uid`;
})
.catch((err: any) => {
err.isHandled = true;

View File

@@ -66,9 +66,4 @@ const mapDispatchToProps = {
updateOrganization,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(OrgDetailsPage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(OrgDetailsPage));

View File

@@ -12,9 +12,15 @@ describe('PlaylistEditCtrl', () => {
ctx = new PlaylistEditCtrl(null, null, null, { current: { params: {} } }, navModelSrv);
ctx.dashboardresult = [{ id: 2, title: 'dashboard: 2' }, { id: 3, title: 'dashboard: 3' }];
ctx.dashboardresult = [
{ id: 2, title: 'dashboard: 2' },
{ id: 3, title: 'dashboard: 3' },
];
ctx.tagresult = [{ term: 'graphite', count: 1 }, { term: 'nyc', count: 2 }];
ctx.tagresult = [
{ term: 'graphite', count: 1 },
{ term: 'nyc', count: 2 },
];
});
describe('searchresult returns 2 dashboards, ', () => {

View File

@@ -5,9 +5,11 @@ import { setStore } from 'app/store/store';
const mockStore = configureMockStore<any, any>();
setStore(mockStore({
location: {},
}) as any);
setStore(
mockStore({
location: {},
}) as any
);
const dashboards = [{ url: 'dash1' }, { url: 'dash2' }];
@@ -120,11 +122,13 @@ describe('PlaylistSrv', () => {
srv.next();
setStore(mockStore({
location: {
path: 'dash2',
},
}) as any);
setStore(
mockStore({
location: {
path: 'dash2',
},
}) as any
);
expect((srv as any).validPlaylistUrl).toBe('dash2');

View File

@@ -59,7 +59,7 @@ export class PluginListPage extends PureComponent<Props> {
setSearchQuery={query => setPluginsSearchQuery(query)}
linkButton={linkButton}
/>
{hasFetched && plugins && (plugins && <PluginList plugins={plugins} layoutMode={layoutMode} />)}
{hasFetched && plugins && plugins && <PluginList plugins={plugins} layoutMode={layoutMode} />}
</>
</Page.Contents>
</Page>
@@ -83,9 +83,4 @@ const mapDispatchToProps = {
setPluginsSearchQuery,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(PluginListPage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(PluginListPage));

View File

@@ -30,7 +30,9 @@ const inputDatasourcePlugin = async () =>
const stackdriverPlugin = async () =>
await import(/* webpackChunkName: "stackdriverPlugin" */ 'app/plugins/datasource/stackdriver/module');
const azureMonitorPlugin = async () =>
await import(/* webpackChunkName: "azureMonitorPlugin" */ 'app/plugins/datasource/grafana-azure-monitor-datasource/module');
await import(
/* webpackChunkName: "azureMonitorPlugin" */ 'app/plugins/datasource/grafana-azure-monitor-datasource/module'
);
import * as textPanel from 'app/plugins/panel/text/module';
import * as text2Panel from 'app/plugins/panel/text2/module';

View File

@@ -38,9 +38,4 @@ function mapStateToProps(state: StoreState) {
const mapDispatchToProps = {};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(ChangePasswordPage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(ChangePasswordPage));

View File

@@ -162,7 +162,4 @@ const mapDispatchToProps = {
removeTeamGroup,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(TeamGroupSync);
export default connect(mapStateToProps, mapDispatchToProps)(TeamGroupSync);

View File

@@ -101,7 +101,4 @@ const mapDispatchToProps = {
updateTeamMember,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(TeamMemberRow);
export default connect(mapStateToProps, mapDispatchToProps)(TeamMemberRow);

View File

@@ -156,7 +156,4 @@ const mapDispatchToProps = {
setSearchMemberQuery,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(TeamMembers);
export default connect(mapStateToProps, mapDispatchToProps)(TeamMembers);

View File

@@ -148,9 +148,4 @@ const mapDispatchToProps = {
loadTeamMembers,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(TeamPages)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(TeamPages));

View File

@@ -98,7 +98,4 @@ const mapDispatchToProps = {
updateTeam,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(TeamSettings);
export default connect(mapStateToProps, mapDispatchToProps)(TeamSettings);

View File

@@ -50,7 +50,11 @@ export class VariableEditorCtrl {
{ value: 6, text: 'Alphabetical (case-insensitive, desc)' },
];
$scope.hideOptions = [{ value: 0, text: '' }, { value: 1, text: 'Label' }, { value: 2, text: 'Variable' }];
$scope.hideOptions = [
{ value: 0, text: '' },
{ value: 1, text: 'Label' },
{ value: 2, text: 'Variable' },
];
$scope.init = () => {
$scope.mode = 'list';

View File

@@ -52,9 +52,6 @@ const mapDispatchToProps = {
revokeInvite,
};
export default connect(
() => {
return {};
},
mapDispatchToProps
)(InviteeRow);
export default connect(() => {
return {};
}, mapDispatchToProps)(InviteeRow);

View File

@@ -92,7 +92,4 @@ const mapDispatchToProps = {
setUsersSearchQuery,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(UsersActionBar);
export default connect(mapStateToProps, mapDispatchToProps)(UsersActionBar);

View File

@@ -138,9 +138,4 @@ const mapDispatchToProps = {
removeUser,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(UsersListPage)
);
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(UsersListPage));

View File

@@ -71,7 +71,11 @@ describe('CloudWatchDatasource', () => {
series: [
{
name: 'CPUUtilization_Average',
points: [[1, 1483228800000], [2, 1483229100000], [5, 1483229700000]],
points: [
[1, 1483228800000],
[2, 1483229100000],
[5, 1483229700000],
],
tags: {
InstanceId: 'i-12345678',
},
@@ -382,7 +386,11 @@ describe('CloudWatchDatasource', () => {
series: [
{
name: 'TargetResponseTime_p90.00',
points: [[1, 1483228800000], [2, 1483229100000], [5, 1483229700000]],
points: [
[1, 1483228800000],
[2, 1483229100000],
[5, 1483229700000],
],
tags: {
LoadBalancer: 'lb',
TargetGroup: 'tg',

View File

@@ -84,9 +84,15 @@ export const bucketAggTypes = [
{ text: 'Histogram', value: 'histogram', requiresField: true },
];
export const orderByOptions = [{ text: 'Doc Count', value: '_count' }, { text: 'Term value', value: '_term' }];
export const orderByOptions = [
{ text: 'Doc Count', value: '_count' },
{ text: 'Term value', value: '_term' },
];
export const orderOptions = [{ text: 'Top', value: 'desc' }, { text: 'Bottom', value: 'asc' }];
export const orderOptions = [
{ text: 'Top', value: 'desc' },
{ text: 'Bottom', value: 'asc' },
];
export const sizeOptions = [
{ text: 'No limit', value: '0' },
@@ -144,7 +150,10 @@ export const movingAvgModelSettings: any = {
simple: [],
linear: [],
ewma: [{ text: 'Alpha', value: 'alpha', default: undefined }],
holt: [{ text: 'Alpha', value: 'alpha', default: undefined }, { text: 'Beta', value: 'beta', default: undefined }],
holt: [
{ text: 'Alpha', value: 'alpha', default: undefined },
{ text: 'Beta', value: 'beta', default: undefined },
],
holt_winters: [
{ text: 'Alpha', value: 'alpha', default: undefined },
{ text: 'Beta', value: 'beta', default: undefined },

View File

@@ -55,7 +55,10 @@ describe('ElasticResponse', () => {
targets = [
{
refId: 'A',
metrics: [{ type: 'count', id: '1' }, { type: 'avg', field: 'value', id: '2' }],
metrics: [
{ type: 'count', id: '1' },
{ type: 'avg', field: 'value', id: '2' },
],
bucketAggs: [{ type: 'date_histogram', field: '@timestamp', id: '3' }],
},
];
@@ -119,14 +122,20 @@ describe('ElasticResponse', () => {
buckets: [
{
'3': {
buckets: [{ doc_count: 1, key: 1000 }, { doc_count: 3, key: 2000 }],
buckets: [
{ doc_count: 1, key: 1000 },
{ doc_count: 3, key: 2000 },
],
},
doc_count: 4,
key: 'server1',
},
{
'3': {
buckets: [{ doc_count: 2, key: 1000 }, { doc_count: 8, key: 2000 }],
buckets: [
{ doc_count: 2, key: 1000 },
{ doc_count: 8, key: 2000 },
],
},
doc_count: 10,
key: 'server2',
@@ -156,7 +165,10 @@ describe('ElasticResponse', () => {
targets = [
{
refId: 'A',
metrics: [{ type: 'count', id: '1' }, { type: 'avg', field: '@value', id: '4' }],
metrics: [
{ type: 'count', id: '1' },
{ type: 'avg', field: '@value', id: '4' },
],
bucketAggs: [
{ type: 'terms', field: 'host', id: '2' },
{ type: 'date_histogram', field: '@timestamp', id: '3' },
@@ -271,7 +283,10 @@ describe('ElasticResponse', () => {
id: '1',
},
],
bucketAggs: [{ type: 'terms', field: 'host', id: '3' }, { type: 'date_histogram', id: '4' }],
bucketAggs: [
{ type: 'terms', field: 'host', id: '3' },
{ type: 'date_histogram', id: '4' },
],
},
];
response = {
@@ -356,21 +371,30 @@ describe('ElasticResponse', () => {
buckets: [
{
'3': {
buckets: [{ doc_count: 1, key: 1000 }, { doc_count: 3, key: 2000 }],
buckets: [
{ doc_count: 1, key: 1000 },
{ doc_count: 3, key: 2000 },
],
},
doc_count: 4,
key: 'server1',
},
{
'3': {
buckets: [{ doc_count: 2, key: 1000 }, { doc_count: 8, key: 2000 }],
buckets: [
{ doc_count: 2, key: 1000 },
{ doc_count: 8, key: 2000 },
],
},
doc_count: 10,
key: 'server2',
},
{
'3': {
buckets: [{ doc_count: 2, key: 1000 }, { doc_count: 8, key: 2000 }],
buckets: [
{ doc_count: 2, key: 1000 },
{ doc_count: 8, key: 2000 },
],
},
doc_count: 10,
key: 0,
@@ -410,7 +434,11 @@ describe('ElasticResponse', () => {
{
aggregations: {
'3': {
buckets: [{ doc_count: 1, key: 1000 }, { doc_count: 3, key: 2000 }, { doc_count: 2, key: 1000 }],
buckets: [
{ doc_count: 1, key: 1000 },
{ doc_count: 3, key: 2000 },
{ doc_count: 2, key: 1000 },
],
},
},
},
@@ -454,12 +482,18 @@ describe('ElasticResponse', () => {
buckets: {
'@metric:cpu': {
'3': {
buckets: [{ doc_count: 1, key: 1000 }, { doc_count: 3, key: 2000 }],
buckets: [
{ doc_count: 1, key: 1000 },
{ doc_count: 3, key: 2000 },
],
},
},
'@metric:logins.count': {
'3': {
buckets: [{ doc_count: 2, key: 1000 }, { doc_count: 8, key: 2000 }],
buckets: [
{ doc_count: 2, key: 1000 },
{ doc_count: 8, key: 2000 },
],
},
},
},
@@ -641,7 +675,10 @@ describe('ElasticResponse', () => {
targets = [
{
refId: 'A',
metrics: [{ type: 'avg', id: '1', field: 'test' }, { type: 'avg', id: '2', field: 'test2' }],
metrics: [
{ type: 'avg', id: '1', field: 'test' },
{ type: 'avg', id: '2', field: 'test2' },
],
bucketAggs: [{ id: '2', type: 'terms', field: 'host' }],
},
];
@@ -733,7 +770,10 @@ describe('ElasticResponse', () => {
{
id: '4',
field: 'select field',
pipelineVariables: [{ name: 'var1', pipelineAgg: '1' }, { name: 'var2', pipelineAgg: '3' }],
pipelineVariables: [
{ name: 'var1', pipelineAgg: '1' },
{ name: 'var2', pipelineAgg: '3' },
],
settings: { script: 'params.var1 * params.var2' },
type: 'bucket_script',
},

View File

@@ -65,7 +65,10 @@ describe('ElasticQueryBuilder', () => {
it('with term agg and order by term', () => {
const query = builder.build(
{
metrics: [{ type: 'count', id: '1' }, { type: 'avg', field: '@value', id: '5' }],
metrics: [
{ type: 'count', id: '1' },
{ type: 'avg', field: '@value', id: '5' },
],
bucketAggs: [
{
type: 'terms',
@@ -91,7 +94,10 @@ describe('ElasticQueryBuilder', () => {
});
const query = builder6x.build(
{
metrics: [{ type: 'count', id: '1' }, { type: 'avg', field: '@value', id: '5' }],
metrics: [
{ type: 'count', id: '1' },
{ type: 'avg', field: '@value', id: '5' },
],
bucketAggs: [
{
type: 'terms',
@@ -114,7 +120,10 @@ describe('ElasticQueryBuilder', () => {
it('with term agg and order by metric agg', () => {
const query = builder.build(
{
metrics: [{ type: 'count', id: '1' }, { type: 'avg', field: '@value', id: '5' }],
metrics: [
{ type: 'count', id: '1' },
{ type: 'avg', field: '@value', id: '5' },
],
bucketAggs: [
{
type: 'terms',

View File

@@ -12,7 +12,10 @@ describe('ElasticQueryDef', () => {
describe('with count and sum targets', () => {
const targets = {
metrics: [{ type: 'count', field: '@value' }, { type: 'sum', field: '@value' }],
metrics: [
{ type: 'count', field: '@value' },
{ type: 'sum', field: '@value' },
],
};
const response = queryDef.getPipelineAggOptions(targets);
@@ -24,7 +27,10 @@ describe('ElasticQueryDef', () => {
describe('with count and moving average targets', () => {
const targets = {
metrics: [{ type: 'count', field: '@value' }, { type: 'moving_avg', field: '@value' }],
metrics: [
{ type: 'count', field: '@value' },
{ type: 'moving_avg', field: '@value' },
],
};
const response = queryDef.getPipelineAggOptions(targets);

View File

@@ -290,7 +290,10 @@ describe('AppInsightsDatasource', () => {
series: [
{
name: 'exceptions/server',
points: [[3, 1504108800000], [6, 1504112400000]],
points: [
[3, 1504108800000],
[6, 1504112400000],
],
},
],
tables: null,
@@ -333,11 +336,17 @@ describe('AppInsightsDatasource', () => {
series: [
{
name: 'exceptions/server{client/city="Miami"}',
points: [[10, 1504108800000], [20, 1504112400000]],
points: [
[10, 1504108800000],
[20, 1504112400000],
],
},
{
name: 'exceptions/server{client/city="San Antonio"}',
points: [[1, 1504108800000], [2, 1504112400000]],
points: [
[1, 1504108800000],
[2, 1504112400000],
],
},
],
tables: null,

View File

@@ -343,7 +343,10 @@ describe('AzureLogAnalyticsDatasource', () => {
type: 'string',
},
],
rows: [['2018-06-02T20:20:00Z', 'Computer1', 'tag1,tag2'], ['2018-06-02T20:28:00Z', 'Computer2', 'tag2']],
rows: [
['2018-06-02T20:20:00Z', 'Computer1', 'tag1,tag2'],
['2018-06-02T20:28:00Z', 'Computer2', 'tag2'],
],
},
],
};

View File

@@ -114,7 +114,10 @@ describe('AzureMonitorDatasource', () => {
series: [
{
name: 'Percentage CPU',
points: [[2.2075, 1558278660000], [2.29, 1558278720000]],
points: [
[2.2075, 1558278660000],
[2.29, 1558278720000],
],
},
],
tables: null,

View File

@@ -253,9 +253,7 @@ export default class AzureMonitorDatasource {
}
getMetricDefinitions(subscriptionId: string, resourceGroup: string) {
const url = `${this.baseUrl}/${subscriptionId}/resourceGroups/${resourceGroup}/resources?api-version=${
this.apiVersion
}`;
const url = `${this.baseUrl}/${subscriptionId}/resourceGroups/${resourceGroup}/resources?api-version=${this.apiVersion}`;
return this.doRequest(url)
.then((result: AzureMonitorMetricDefinitionsResponse) => {
return ResponseParser.parseResponseValues(result, 'type', 'type');
@@ -304,9 +302,7 @@ export default class AzureMonitorDatasource {
}
getResourceNames(subscriptionId: string, resourceGroup: string, metricDefinition: string) {
const url = `${this.baseUrl}/${subscriptionId}/resourceGroups/${resourceGroup}/resources?api-version=${
this.apiVersion
}`;
const url = `${this.baseUrl}/${subscriptionId}/resourceGroups/${resourceGroup}/resources?api-version=${this.apiVersion}`;
return this.doRequest(url).then((result: any) => {
if (!_.startsWith(metricDefinition, 'Microsoft.Storage/storageAccounts/')) {

View File

@@ -125,7 +125,8 @@ export class AnalyticsConfig extends PureComponent<Props, State> {
return (
jsonData.logAnalyticsTenantId &&
jsonData.logAnalyticsTenantId.length &&
(jsonData.logAnalyticsClientId && jsonData.logAnalyticsClientId.length) &&
jsonData.logAnalyticsClientId &&
jsonData.logAnalyticsClientId.length &&
jsonData.logAnalyticsSubscriptionId &&
(secureJsonFields.logAnalyticsClientSecret || secureJsonData.logAnalyticsClientSecret)
);

View File

@@ -47,7 +47,10 @@ describe('AzureMonitorQueryCtrl', () => {
describe('when the query type is Azure Monitor', () => {
describe('and getOptions for the Resource Group dropdown is called', () => {
const response = [{ text: 'nodeapp', value: 'nodeapp' }, { text: 'otherapp', value: 'otherapp' }];
const response = [
{ text: 'nodeapp', value: 'nodeapp' },
{ text: 'otherapp', value: 'otherapp' },
];
beforeEach(() => {
queryCtrl.datasource.getResourceGroups = () => {
@@ -105,7 +108,10 @@ describe('AzureMonitorQueryCtrl', () => {
describe('when getOptions for the ResourceNames dropdown is called', () => {
describe('and resourceGroup and metricDefinition have values', () => {
const response = [{ text: 'test1', value: 'test1' }, { text: 'test2', value: 'test2' }];
const response = [
{ text: 'test1', value: 'test1' },
{ text: 'test2', value: 'test2' },
];
beforeEach(() => {
queryCtrl.target.subscription = 'sub1';
@@ -145,7 +151,10 @@ describe('AzureMonitorQueryCtrl', () => {
describe('when getOptions for the Metric Names dropdown is called', () => {
describe('and resourceGroup, metricDefinition, resourceName and metricNamespace have values', () => {
const response = [{ text: 'metric1', value: 'metric1' }, { text: 'metric2', value: 'metric2' }];
const response = [
{ text: 'metric1', value: 'metric1' },
{ text: 'metric2', value: 'metric2' },
];
beforeEach(() => {
queryCtrl.target.subscription = 'sub1';
@@ -195,7 +204,10 @@ describe('AzureMonitorQueryCtrl', () => {
const response: any = {
primaryAggType: 'Average',
supportedAggTypes: ['Average', 'Total'],
supportedTimeGrains: [{ text: 'PT1M', value: 'PT1M' }, { text: 'P1D', value: 'P1D' }],
supportedTimeGrains: [
{ text: 'PT1M', value: 'PT1M' },
{ text: 'P1D', value: 'P1D' },
],
dimensions: [],
};
@@ -269,7 +281,10 @@ describe('AzureMonitorQueryCtrl', () => {
});
describe('when getOptions for the Metric Names dropdown is called', () => {
const response = [{ text: 'metric1', value: 'metric1' }, { text: 'metric2', value: 'metric2' }];
const response = [
{ text: 'metric1', value: 'metric1' },
{ text: 'metric2', value: 'metric2' },
];
beforeEach(() => {
queryCtrl.datasource.appInsightsDatasource.isConfigured = () => true;

View File

@@ -139,7 +139,10 @@ export class AzureMonitorQueryCtrl extends QueryCtrl {
this.panelCtrl.events.on(PanelEvents.dataReceived, this.onDataReceived.bind(this), $scope);
this.panelCtrl.events.on(PanelEvents.dataError, this.onDataError.bind(this), $scope);
this.resultFormats = [{ text: 'Time series', value: 'time_series' }, { text: 'Table', value: 'table' }];
this.resultFormats = [
{ text: 'Time series', value: 'time_series' },
{ text: 'Table', value: 'table' },
];
this.getSubscriptions();
if (this.target.queryType === 'Azure Log Analytics') {
this.getWorkspaces();

View File

@@ -8,7 +8,10 @@ class GrafanaQueryCtrl extends QueryCtrl {
class GrafanaAnnotationsQueryCtrl {
annotation: any;
types = [{ text: 'Dashboard', value: 'dashboard' }, { text: 'Tags', value: 'tags' }];
types = [
{ text: 'Dashboard', value: 'dashboard' },
{ text: 'Tags', value: 'tags' },
];
constructor() {
this.annotation.type = this.annotation.type || 'tags';

View File

@@ -133,7 +133,10 @@ addFuncDef({
addFuncDef({
name: 'percentileOfSeries',
category: 'Combine',
params: [{ name: 'n', type: 'int' }, { name: 'interpolate', type: 'boolean', options: ['true', 'false'] }],
params: [
{ name: 'n', type: 'int' },
{ name: 'interpolate', type: 'boolean', options: ['true', 'false'] },
],
defaultParams: [95, 'false'],
});
@@ -173,7 +176,10 @@ addFuncDef({
addFuncDef({
name: 'aliasSub',
category: 'Alias',
params: [{ name: 'search', type: 'string' }, { name: 'replace', type: 'string' }],
params: [
{ name: 'search', type: 'string' },
{ name: 'replace', type: 'string' },
],
defaultParams: ['', '\\1'],
});
@@ -566,7 +572,10 @@ addFuncDef({
addFuncDef({
name: 'stdev',
category: 'Calculate',
params: [{ name: 'n', type: 'int' }, { name: 'tolerance', type: 'int' }],
params: [
{ name: 'n', type: 'int' },
{ name: 'tolerance', type: 'int' },
],
defaultParams: [5, 0.1],
});
@@ -615,7 +624,11 @@ addFuncDef({
addFuncDef({
name: 'useSeriesAbove',
category: 'Filter Series',
params: [{ name: 'value', type: 'int' }, { name: 'search', type: 'string' }, { name: 'replace', type: 'string' }],
params: [
{ name: 'value', type: 'int' },
{ name: 'search', type: 'string' },
{ name: 'replace', type: 'string' },
],
defaultParams: [0, 'search', 'replace'],
});

View File

@@ -176,11 +176,9 @@ export class GraphiteQueryCtrl extends QueryCtrl {
return altSegments;
}
})
.catch(
(err: any): any[] => {
return [];
}
);
.catch((err: any): any[] => {
return [];
});
}
addAltTagSegments(prefix: string, altSegments: any[]) {

View File

@@ -36,7 +36,15 @@ describe('graphiteDatasource', () => {
ctx.backendSrv.datasourceRequest = (options: any) => {
requestOptions = options;
return ctx.$q.when({
data: [{ target: 'prod1.count', datapoints: [[10, 1], [12, 1]] }],
data: [
{
target: 'prod1.count',
datapoints: [
[10, 1],
[12, 1],
],
},
],
});
};

View File

@@ -40,7 +40,10 @@ describe('Graphite query model', () => {
it('should not hang on circular references', () => {
ctx.target.target = 'asPercent(#A, #B)';
ctx.targets = [{ refId: 'A', target: 'asPercent(#B, #C)' }, { refId: 'B', target: 'asPercent(#A, #C)' }];
ctx.targets = [
{ refId: 'A', target: 'asPercent(#B, #C)' },
{ refId: 'B', target: 'asPercent(#A, #C)' },
];
ctx.queryModel.updateRenderedTarget(ctx.target, ctx.targets);
// Just ensure updateRenderedTarget() is completed and doesn't hang
expect(ctx.queryModel.target.targetFull).toBeDefined();

Some files were not shown because too many files have changed in this diff Show More