mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Kibana 7.7.0: Chart split orientation is wrong (#67840)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
c718afcbba
commit
d7b830a6bf
2 changed files with 84 additions and 14 deletions
|
@ -623,12 +623,12 @@ describe('migration visualization', () => {
|
||||||
{
|
{
|
||||||
id: '2',
|
id: '2',
|
||||||
schema: 'split',
|
schema: 'split',
|
||||||
params: { foo: 'bar', row: true },
|
params: { foo: 'bar' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '3',
|
id: '3',
|
||||||
schema: 'split',
|
schema: 'split',
|
||||||
params: { hey: 'ya', row: false },
|
params: { hey: 'ya' },
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const tableDoc = generateDoc('table', aggs);
|
const tableDoc = generateDoc('table', aggs);
|
||||||
|
@ -656,7 +656,7 @@ describe('migration visualization', () => {
|
||||||
{
|
{
|
||||||
id: '2',
|
id: '2',
|
||||||
schema: 'split',
|
schema: 'split',
|
||||||
params: { foo: 'bar', row: true },
|
params: { foo: 'bar' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '3',
|
id: '3',
|
||||||
|
@ -681,7 +681,7 @@ describe('migration visualization', () => {
|
||||||
{
|
{
|
||||||
id: '2',
|
id: '2',
|
||||||
schema: 'split',
|
schema: 'split',
|
||||||
params: { foo: 'bar', row: true },
|
params: { foo: 'bar' },
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const tableDoc = generateDoc('table', aggs);
|
const tableDoc = generateDoc('table', aggs);
|
||||||
|
@ -701,12 +701,12 @@ describe('migration visualization', () => {
|
||||||
{
|
{
|
||||||
id: '2',
|
id: '2',
|
||||||
schema: 'split',
|
schema: 'split',
|
||||||
params: { foo: 'bar', row: true },
|
params: { foo: 'bar' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '3',
|
id: '3',
|
||||||
schema: 'split',
|
schema: 'split',
|
||||||
params: { hey: 'ya', row: false },
|
params: { hey: 'ya' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '4',
|
id: '4',
|
||||||
|
@ -731,15 +731,15 @@ describe('migration visualization', () => {
|
||||||
{
|
{
|
||||||
id: '2',
|
id: '2',
|
||||||
schema: 'split',
|
schema: 'split',
|
||||||
params: { foo: 'bar', row: true },
|
params: { foo: 'bar' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '3',
|
id: '3',
|
||||||
schema: 'split',
|
schema: 'split',
|
||||||
params: { hey: 'ya', row: false },
|
params: { hey: 'ya' },
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const expected = [{}, { foo: 'bar', row: true }, { hey: 'ya' }];
|
const expected = [{}, { foo: 'bar' }, { hey: 'ya' }];
|
||||||
const migrated = migrate(generateDoc('table', aggs));
|
const migrated = migrate(generateDoc('table', aggs));
|
||||||
const actual = JSON.parse(migrated.attributes.visState);
|
const actual = JSON.parse(migrated.attributes.visState);
|
||||||
|
|
||||||
|
@ -1386,11 +1386,11 @@ describe('migration visualization', () => {
|
||||||
doc as Parameters<SavedObjectMigrationFn>[0],
|
doc as Parameters<SavedObjectMigrationFn>[0],
|
||||||
savedObjectMigrationContext
|
savedObjectMigrationContext
|
||||||
);
|
);
|
||||||
const generateDoc = (params: any) => ({
|
const generateDoc = (visState: any) => ({
|
||||||
attributes: {
|
attributes: {
|
||||||
title: 'My Vis',
|
title: 'My Vis',
|
||||||
description: 'This is my super cool vis.',
|
description: 'This is my super cool vis.',
|
||||||
visState: JSON.stringify({ params }),
|
visState: JSON.stringify(visState),
|
||||||
uiStateJSON: '{}',
|
uiStateJSON: '{}',
|
||||||
version: 1,
|
version: 1,
|
||||||
kibanaSavedObjectMeta: {
|
kibanaSavedObjectMeta: {
|
||||||
|
@ -1416,7 +1416,7 @@ describe('migration visualization', () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
const timeSeriesDoc = generateDoc(params);
|
const timeSeriesDoc = generateDoc({ params });
|
||||||
const migratedtimeSeriesDoc = migrate(timeSeriesDoc);
|
const migratedtimeSeriesDoc = migrate(timeSeriesDoc);
|
||||||
const migratedParams = JSON.parse(migratedtimeSeriesDoc.attributes.visState).params;
|
const migratedParams = JSON.parse(migratedtimeSeriesDoc.attributes.visState).params;
|
||||||
|
|
||||||
|
@ -1453,12 +1453,38 @@ describe('migration visualization', () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
const timeSeriesDoc = generateDoc(params);
|
const timeSeriesDoc = generateDoc({ params });
|
||||||
const migratedtimeSeriesDoc = migrate(timeSeriesDoc);
|
const migratedtimeSeriesDoc = migrate(timeSeriesDoc);
|
||||||
const migratedParams = JSON.parse(migratedtimeSeriesDoc.attributes.visState).params;
|
const migratedParams = JSON.parse(migratedtimeSeriesDoc.attributes.visState).params;
|
||||||
|
|
||||||
expect(migratedParams.gauge_color_rules[1]).toEqual(params.gauge_color_rules[1]);
|
expect(migratedParams.gauge_color_rules[1]).toEqual(params.gauge_color_rules[1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should move "row" field on split chart by a row or column to vis.params', () => {
|
||||||
|
const visData = {
|
||||||
|
type: 'area',
|
||||||
|
aggs: [
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
schema: 'metric',
|
||||||
|
params: {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '2',
|
||||||
|
type: 'terms',
|
||||||
|
schema: 'split',
|
||||||
|
params: { foo: 'bar', row: true },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
params: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
const migrated = migrate(generateDoc(visData));
|
||||||
|
const actual = JSON.parse(migrated.attributes.visState);
|
||||||
|
|
||||||
|
expect(actual.aggs.filter((agg: any) => 'row' in agg.params)).toEqual([]);
|
||||||
|
expect(actual.params.row).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('7.8.0 tsvb split_color_mode', () => {
|
describe('7.8.0 tsvb split_color_mode', () => {
|
||||||
|
|
|
@ -131,6 +131,50 @@ const migrateOperatorKeyTypo: SavedObjectMigrationFn<any, any> = (doc) => {
|
||||||
return doc;
|
return doc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moving setting wether to do a row or column split to vis.params
|
||||||
|
*
|
||||||
|
* @see https://github.com/elastic/kibana/pull/58462/files#diff-ae69fe15b20a5099d038e9bbe2ed3849
|
||||||
|
**/
|
||||||
|
const migrateSplitByChartRow: SavedObjectMigrationFn<any, any> = (doc) => {
|
||||||
|
const visStateJSON = get<string>(doc, 'attributes.visState');
|
||||||
|
let visState: any;
|
||||||
|
|
||||||
|
if (visStateJSON) {
|
||||||
|
try {
|
||||||
|
visState = JSON.parse(visStateJSON);
|
||||||
|
} catch (e) {
|
||||||
|
// Let it go, the data is invalid and we'll leave it as is
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visState && visState.aggs && visState.params) {
|
||||||
|
let row: boolean | undefined;
|
||||||
|
|
||||||
|
visState.aggs.forEach((agg: any) => {
|
||||||
|
if (agg.type === 'terms' && agg.schema === 'split' && 'row' in agg.params) {
|
||||||
|
row = agg.params.row;
|
||||||
|
|
||||||
|
delete agg.params.row;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (row !== undefined) {
|
||||||
|
visState.params.row = row;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...doc,
|
||||||
|
attributes: {
|
||||||
|
...doc.attributes,
|
||||||
|
visState: JSON.stringify(visState),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
};
|
||||||
|
|
||||||
// Migrate date histogram aggregation (remove customInterval)
|
// Migrate date histogram aggregation (remove customInterval)
|
||||||
const migrateDateHistogramAggregation: SavedObjectMigrationFn<any, any> = (doc) => {
|
const migrateDateHistogramAggregation: SavedObjectMigrationFn<any, any> = (doc) => {
|
||||||
const visStateJSON = get<string>(doc, 'attributes.visState');
|
const visStateJSON = get<string>(doc, 'attributes.visState');
|
||||||
|
@ -673,6 +717,6 @@ export const visualizationSavedObjectTypeMigrations = {
|
||||||
),
|
),
|
||||||
'7.3.1': flow<SavedObjectMigrationFn<any, any>>(migrateFiltersAggQueryStringQueries),
|
'7.3.1': flow<SavedObjectMigrationFn<any, any>>(migrateFiltersAggQueryStringQueries),
|
||||||
'7.4.2': flow<SavedObjectMigrationFn<any, any>>(transformSplitFiltersStringToQueryObject),
|
'7.4.2': flow<SavedObjectMigrationFn<any, any>>(transformSplitFiltersStringToQueryObject),
|
||||||
'7.7.0': flow<SavedObjectMigrationFn<any, any>>(migrateOperatorKeyTypo),
|
'7.7.0': flow<SavedObjectMigrationFn<any, any>>(migrateOperatorKeyTypo, migrateSplitByChartRow),
|
||||||
'7.8.0': flow<SavedObjectMigrationFn<any, any>>(migrateTsvbDefaultColorPalettes),
|
'7.8.0': flow<SavedObjectMigrationFn<any, any>>(migrateTsvbDefaultColorPalettes),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue