mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
Fix: Timeseries migration regex override (#49629)
This commit is contained in:
parent
6554bbd70f
commit
3d3cf74038
@ -141,6 +141,21 @@ Object {
|
||||
},
|
||||
],
|
||||
},
|
||||
Object {
|
||||
"matcher": Object {
|
||||
"id": "byName",
|
||||
"options": "B-series",
|
||||
},
|
||||
"properties": Array [
|
||||
Object {
|
||||
"id": "color",
|
||||
"value": Object {
|
||||
"fixedColor": "rgba(16, 72, 170, 0.77)",
|
||||
"mode": "fixed",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
"options": Object {
|
||||
@ -197,6 +212,21 @@ Object {
|
||||
},
|
||||
],
|
||||
},
|
||||
Object {
|
||||
"matcher": Object {
|
||||
"id": "byRegexp",
|
||||
"options": "/.*Status: 2[0-9]+.*/i",
|
||||
},
|
||||
"properties": Array [
|
||||
Object {
|
||||
"id": "color",
|
||||
"value": Object {
|
||||
"fixedColor": "rgba(16, 72, 170, 0.77)",
|
||||
"mode": "fixed",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
"options": Object {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { cloneDeep } from 'lodash';
|
||||
|
||||
import { PanelModel, FieldConfigSource } from '@grafana/data';
|
||||
import { PanelModel, FieldConfigSource, FieldMatcherID } from '@grafana/data';
|
||||
import { TooltipDisplayMode, SortOrder } from '@grafana/schema';
|
||||
|
||||
import { graphPanelChangedHandler } from './migrations';
|
||||
@ -78,6 +78,8 @@ describe('Graph Migrations', () => {
|
||||
const panel = {} as PanelModel;
|
||||
panel.options = graphPanelChangedHandler(panel, 'graph', old, prevFieldConfig);
|
||||
expect(panel).toMatchSnapshot();
|
||||
expect(panel.fieldConfig.overrides[0].matcher.id).toBe(FieldMatcherID.byRegexp);
|
||||
expect(panel.fieldConfig.overrides[1].matcher.id).toBe(FieldMatcherID.byRegexp);
|
||||
});
|
||||
|
||||
describe('legend', () => {
|
||||
@ -479,6 +481,11 @@ const customColor = {
|
||||
alias: 'A-series',
|
||||
color: 'rgba(165, 72, 170, 0.77)',
|
||||
},
|
||||
{
|
||||
$$hashKey: 'object:13',
|
||||
alias: 'B-series',
|
||||
color: 'rgba(16, 72, 170, 0.77)',
|
||||
},
|
||||
],
|
||||
spaceLength: 10,
|
||||
steppedLine: true,
|
||||
@ -536,6 +543,7 @@ const customColor = {
|
||||
|
||||
const customColorRegex = cloneDeep(customColor);
|
||||
customColorRegex.seriesOverrides[0].alias = '/^A-/';
|
||||
customColorRegex.seriesOverrides[1].alias = '/.*Status: 2[0-9]+.*/i';
|
||||
|
||||
const stairscase = {
|
||||
aliasColors: {},
|
||||
|
@ -119,7 +119,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
|
||||
if (!seriesOverride.alias) {
|
||||
continue; // the matcher config
|
||||
}
|
||||
const aliasIsRegex = seriesOverride.alias.startsWith('/') && seriesOverride.alias.endsWith('/');
|
||||
const aliasIsRegex = /^([/~@;%#'])(.*?)\1([gimsuy]*)$/.test(seriesOverride.alias);
|
||||
const rule: ConfigOverrideRule = {
|
||||
matcher: {
|
||||
id: aliasIsRegex ? FieldMatcherID.byRegexp : FieldMatcherID.byName,
|
||||
|
Loading…
Reference in New Issue
Block a user