Skip to content

Commit

Permalink
[Bug] missing timepicker:quickRanges migration (#93409)
Browse files Browse the repository at this point in the history
* timepicker:quickRanges

* code review

* Change into a 7.12 migration
  • Loading branch information
lizozom authored Mar 4, 2021
1 parent 6512e5a commit f5351e6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/core/server/ui_settings/saved_objects/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,34 @@ export const migrations = {
}),
references: doc.references || [],
}),
'7.12.0': (doc: SavedObjectUnsanitizedDoc<any>): SavedObjectSanitizedDoc<any> => ({
...doc,
...(doc.attributes && {
attributes: Object.keys(doc.attributes).reduce((acc, key) => {
if (key === 'timepicker:quickRanges' && doc.attributes[key].indexOf('section') > -1) {
const ranges = JSON.parse(doc.attributes[key]).map(
({ from, to, display }: { from: string; to: string; display: string }) => {
return {
from,
to,
display,
};
}
);
return {
...acc,
'timepicker:quickRanges': JSON.stringify(ranges, null, 2),
};
} else {
return {
...acc,
[key]: doc.attributes[key],
};
}
}, {}),
}),
references: doc.references || [],
}),
'7.13.0': (doc: SavedObjectUnsanitizedDoc<any>): SavedObjectSanitizedDoc<any> => ({
...doc,
...(doc.attributes && {
Expand Down

0 comments on commit f5351e6

Please sign in to comment.