From bda6a9d9aa9b9602d55d1be2b82be8031e731469 Mon Sep 17 00:00:00 2001 From: dej611 Date: Mon, 7 Mar 2022 12:42:25 +0100 Subject: [PATCH] :ok_hand: Address some issues raised by review --- .../public/app_plugin/show_underlying_data.ts | 28 ++++++------------- .../public/indexpattern_datasource/utils.tsx | 7 +++-- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/x-pack/plugins/lens/public/app_plugin/show_underlying_data.ts b/x-pack/plugins/lens/public/app_plugin/show_underlying_data.ts index a8c678167f70f..e1956542f8def 100644 --- a/x-pack/plugins/lens/public/app_plugin/show_underlying_data.ts +++ b/x-pack/plugins/lens/public/app_plugin/show_underlying_data.ts @@ -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( @@ -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()!, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/utils.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/utils.tsx index 401a4d9dcef82..161d8b63bd12d 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/utils.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/utils.tsx @@ -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[];