From b78b0ea424fefe19d263f63975d58a16e475d40d Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Fri, 6 Jan 2023 14:07:01 -0800 Subject: [PATCH 1/3] fix SQL errors displayed in viz. container Signed-off-by: Shenoy Pratik --- .../custom_panels/helpers/utils.tsx | 10 ++- .../visualization_flyout.tsx | 61 +++++++++++-------- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/public/components/custom_panels/helpers/utils.tsx b/public/components/custom_panels/helpers/utils.tsx index 2dca730667..47c9459678 100644 --- a/public/components/custom_panels/helpers/utils.tsx +++ b/public/components/custom_panels/helpers/utils.tsx @@ -143,8 +143,12 @@ const pplServiceRequestor = async ( setVisualizationData(res); }) .catch((error: Error) => { - setIsError(error.stack || 'Issue in fetching visualization'); - console.error(error); + const errorMessage = JSON.parse(error.body.message); + setIsError( + errorMessage.error.reason + '. ' + errorMessage.error.details || + 'Issue in fetching visualization' + ); + console.error(error.body); }) .finally(() => { setIsLoading(false); @@ -435,7 +439,7 @@ export const displayVisualization = (metaData: any, data: any, type: string) => const mixedUserConfigs = { availabilityConfig: { - ...(metaData.user_configs?.availabilityConfig || {}) + ...(metaData.user_configs?.availabilityConfig || {}), }, dataConfig: { ...finalDataConfig, diff --git a/public/components/custom_panels/panel_modules/visualization_flyout/visualization_flyout.tsx b/public/components/custom_panels/panel_modules/visualization_flyout/visualization_flyout.tsx index 7c1f2dc9ba..290765b801 100644 --- a/public/components/custom_panels/panel_modules/visualization_flyout/visualization_flyout.tsx +++ b/public/components/custom_panels/panel_modules/visualization_flyout/visualization_flyout.tsx @@ -24,6 +24,7 @@ import { EuiSpacer, EuiText, EuiTitle, + EuiToolTip, ShortDate, } from '@elastic/eui'; import _ from 'lodash'; @@ -180,33 +181,39 @@ export const VisaulizationFlyout = ({ }; const timeRange = ( - - endDate} - aria-label="Start date" - dateFormat={uiSettingsService.get('dateFormat')} - /> - } - endDateControl={ - endDate} - aria-label="End date" - dateFormat={uiSettingsService.get('dateFormat')} - /> - } - /> - + + + endDate} + aria-label="Start date" + dateFormat={uiSettingsService.get('dateFormat')} + /> + } + endDateControl={ + endDate} + aria-label="End date" + dateFormat={uiSettingsService.get('dateFormat')} + /> + } + /> + + ); const flyoutHeader = ( From 7c9e54f7edc0368c9c78560d206a318cd09f686f Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Fri, 6 Jan 2023 15:02:23 -0800 Subject: [PATCH 2/3] fix metrics grid test Signed-off-by: Shenoy Pratik --- .../metrics/view/__tests__/metrics_grid.test.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/components/metrics/view/__tests__/metrics_grid.test.tsx b/public/components/metrics/view/__tests__/metrics_grid.test.tsx index 2cf11a5014..b3b5c781c9 100644 --- a/public/components/metrics/view/__tests__/metrics_grid.test.tsx +++ b/public/components/metrics/view/__tests__/metrics_grid.test.tsx @@ -11,7 +11,11 @@ import { MetricsGrid } from '../metrics_grid'; import httpClientMock from '../../../../../test/__mocks__/httpClientMock'; import { coreStartMock } from '../../../../../test/__mocks__/coreMocks'; import PPLService from '../../../../services/requests/ppl'; -import { sampleMetric, sampleMetricsVisualizations } from '../../../../../test/metrics_contants'; +import { + sampleMetric, + sampleMetricsVisualizations, + samplePPLResponse, +} from '../../../../../test/metrics_contants'; import { createStore } from '@reduxjs/toolkit'; import rootReducer from '../../../../framework/redux/reducers'; import { Provider } from 'react-redux'; @@ -21,8 +25,12 @@ describe('Metrics Grid Component', () => { configure({ adapter: new Adapter() }); const store = createStore(rootReducer); + let flag = 0; it('renders Metrics Grid Component', async () => { httpClientMock.get = jest.fn(() => Promise.resolve((sampleMetric as unknown) as HttpResponse)); + httpClientMock.post = jest.fn(() => + Promise.resolve((samplePPLResponse as unknown) as HttpResponse) + ); const http = httpClientMock; const core = coreStartMock; From 06735b05fd63f8a71260368abeb8271a7f552de5 Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Fri, 6 Jan 2023 16:10:51 -0800 Subject: [PATCH 3/3] remoe unused flag Signed-off-by: Shenoy Pratik --- public/components/metrics/view/__tests__/metrics_grid.test.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/public/components/metrics/view/__tests__/metrics_grid.test.tsx b/public/components/metrics/view/__tests__/metrics_grid.test.tsx index b3b5c781c9..cf3a3f57b9 100644 --- a/public/components/metrics/view/__tests__/metrics_grid.test.tsx +++ b/public/components/metrics/view/__tests__/metrics_grid.test.tsx @@ -25,7 +25,6 @@ describe('Metrics Grid Component', () => { configure({ adapter: new Adapter() }); const store = createStore(rootReducer); - let flag = 0; it('renders Metrics Grid Component', async () => { httpClientMock.get = jest.fn(() => Promise.resolve((sampleMetric as unknown) as HttpResponse)); httpClientMock.post = jest.fn(() =>