Skip to content

Commit

Permalink
👌 Address some issues raised by review
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed Mar 7, 2022
1 parent 51da4b9 commit bda6a9d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
28 changes: 9 additions & 19 deletions x-pack/plugins/lens/public/app_plugin/show_underlying_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ export function getLayerMetaInfo(
state: datasourceState,
});
// maybe add also datasourceId validation here?
// if (datasourceAPI.datasourceId !== 'indexpattern') {
// return {
// meta: undefined,
// error: i18n.translate('xpack.lens.app.showUnderlyingDataUnsupportedDatasource', {
// defaultMessage: 'Underlying data does not support the current datasource',
// }),
// isVisible,
// };
// }
if (datasourceAPI.datasourceId !== 'indexpattern') {
return {
meta: undefined,
error: i18n.translate('xpack.lens.app.showUnderlyingDataUnsupportedDatasource', {
defaultMessage: 'Underlying data does not support the current datasource',
}),
isVisible,
};
}
const tableSpec = datasourceAPI.getTableSpec();

const columnsWithNoTimeShifts = tableSpec.filter(
Expand All @@ -108,16 +108,6 @@ export function getLayerMetaInfo(
}

const uniqueFields = [...new Set(columnsWithNoTimeShifts.map(({ fields }) => fields).flat())];
// If no field, return? Or rather carry on and show the default columns?
// if (!uniqueFields.length) {
// return {
// meta: undefined,
// error: i18n.translate('xpack.lens.app.showUnderlyingDataNoFields', {
// defaultMessage: 'The current visualization has no available fields to show',
// }),
// isVisible,
// };
// }
return {
meta: {
id: datasourceAPI.getSourceId()!,
Expand Down
7 changes: 5 additions & 2 deletions x-pack/plugins/lens/public/indexpattern_datasource/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,13 @@ function extractQueriesFromTerms(
}
if (typeof value !== 'string' && Array.isArray(value.keys)) {
return value.keys
.map((term: string, index: number) => `${fields[index]}: ${`"${escape(term)}"`}`)
.map(
(term: string, index: number) =>
`${fields[index]}: ${`"${term === '' ? escape(term) : term}"`}`
)
.join(' AND ');
}
return `${column.sourceField}: ${`"${escape(value)}"`}`;
return `${column.sourceField}: ${`"${value === '' ? escape(value) : value}"`}`;
})
.filter(Boolean) as string[];

Expand Down

0 comments on commit bda6a9d

Please sign in to comment.