[7.12] [Bug] missing timepicker:quickRanges migration (#93409) (#94424)

* [Bug] missing timepicker:quickRanges migration (#93409)

* timepicker:quickRanges

* code review

* Change into a 7.12 migration
# Conflicts:
#	src/core/server/ui_settings/saved_objects/migrations.ts

* Delete migration

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Liza Katz 2021-03-17 20:43:26 +02:00 committed by GitHub
parent 4fa13de239
commit 338916c3e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,4 +28,32 @@ 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 || [],
}),
};