Skip to content

Commit

Permalink
[7.12] [Bug] missing timepicker:quickRanges migration (#93409) (#94424)
Browse files Browse the repository at this point in the history
* [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>
  • Loading branch information
lizozom and kibanamachine authored Mar 17, 2021
1 parent 4fa13de commit 338916c
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,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 || [],
}),
};

0 comments on commit 338916c

Please sign in to comment.