Skip to content

Commit 900350a

Browse files
lizozomLiza K
authored andcommitted
[Bug] missing timepicker:quickRanges migration (#93409)
* timepicker:quickRanges * code review * Change into a 7.12 migration
1 parent bb3d35b commit 900350a

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

src/core/server/ui_settings/saved_objects/migrations.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,34 @@ export const migrations = {
2828
}),
2929
references: doc.references || [],
3030
}),
31+
'7.12.0': (doc: SavedObjectUnsanitizedDoc<any>): SavedObjectSanitizedDoc<any> => ({
32+
...doc,
33+
...(doc.attributes && {
34+
attributes: Object.keys(doc.attributes).reduce((acc, key) => {
35+
if (key === 'timepicker:quickRanges' && doc.attributes[key].indexOf('section') > -1) {
36+
const ranges = JSON.parse(doc.attributes[key]).map(
37+
({ from, to, display }: { from: string; to: string; display: string }) => {
38+
return {
39+
from,
40+
to,
41+
display,
42+
};
43+
}
44+
);
45+
return {
46+
...acc,
47+
'timepicker:quickRanges': JSON.stringify(ranges, null, 2),
48+
};
49+
} else {
50+
return {
51+
...acc,
52+
[key]: doc.attributes[key],
53+
};
54+
}
55+
}, {}),
56+
}),
57+
references: doc.references || [],
58+
}),
3159
'7.13.0': (doc: SavedObjectUnsanitizedDoc<any>): SavedObjectSanitizedDoc<any> => ({
3260
...doc,
3361
...(doc.attributes && {

0 commit comments

Comments
 (0)