Skip to content

Commit

Permalink
🐛 Better handling to support already serialized formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed Oct 22, 2020
1 parent 7a93683 commit 456a80b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const indexPattern2 = ({
title: 'my-fake-restricted-pattern',
timeFieldName: 'timestamp',
hasRestrictions: true,
fieldFormatMap: {},
fieldFormatMap: { bytes: { id: 'bytes', params: { pattern: '0.0' } } },
fields: [
{
name: 'timestamp',
Expand Down
7 changes: 4 additions & 3 deletions x-pack/plugins/lens/public/indexpattern_datasource/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ export async function loadIndexPatterns({
fieldFormatMap:
fieldFormatMap &&
Object.fromEntries(
Object.entries(fieldFormatMap)
.filter(([id, format]) => format)
.map(([id, format]) => [id, format.toJSON()])
Object.entries(fieldFormatMap).map(([id, format]) => [
id,
'toJSON' in format ? format.toJSON() : format,
])
),
fields: newFields,
hasRestrictions: !!typeMeta?.aggs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const createMockedRestrictedIndexPattern = () => ({
title: 'my-fake-restricted-pattern',
timeFieldName: 'timestamp',
hasRestrictions: true,
fieldFormatMap: { bytes: null },
fieldFormatMap: { bytes: { id: 'bytes', params: { pattern: '0.0' } } },
fields: [
{
name: 'timestamp',
Expand Down

0 comments on commit 456a80b

Please sign in to comment.