Skip to content

Commit

Permalink
refactor and add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Nov 10, 2020
1 parent faec3dc commit 83f576c
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions x-pack/plugins/lens/public/indexpattern_datasource/format_column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,29 @@ export const formatColumn: ExpressionFunctionDefinition<
},
});
}
if (parentFormatParams && isNestedFormat(col.meta.params)) {
if (parentFormatParams) {
const innerParams = (col.meta.params?.params as Record<string, unknown>) ?? {};
return withParams(col, {
...col.meta.params,
params: {
...innerParams,
...parentFormatParams,
},
});
}
if (parentFormatParams && !isNestedFormat(col.meta.params)) {
const innerParams = (col.meta.params?.params as Record<string, unknown>) ?? {};
return withParams(col, {
...col.meta.params,
id: parentFormatId,
params: {
id: col.meta.params?.id,
params: innerParams,
...parentFormatParams,
},
});
if (isNestedFormat(col.meta.params)) {
// original format is already a nested one, we are just replacing the wrapper params
return withParams(col, {
...col.meta.params,
params: {
...innerParams,
...parentFormatParams,
},
});
} else {
// original format is not nested, wrapping it insifr parentFormatId/parentFormatParams
return withParams(col, {
...col.meta.params,
id: parentFormatId,
params: {
id: col.meta.params?.id,
params: innerParams,
...parentFormatParams,
},
});
}
}
}
return col;
Expand Down

0 comments on commit 83f576c

Please sign in to comment.