From a8c54a5729740ee360a88df25450753a40ef771b Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Mon, 9 Jan 2023 08:55:52 -0800 Subject: [PATCH] Fixed PPL Error in containers & added tool tip to date picker (#179) (#181) * fix SQL errors displayed in viz. container Signed-off-by: Shenoy Pratik * fix metrics grid test Signed-off-by: Shenoy Pratik * remoe unused flag Signed-off-by: Shenoy Pratik Signed-off-by: Shenoy Pratik (cherry picked from commit 8bb5e301c84747574b6d09dfacc27c1b83e295e6) Co-authored-by: Shenoy Pratik --- .../custom_panels/helpers/utils.tsx | 10 ++- .../visualization_flyout.tsx | 61 +++++++++++-------- .../view/__tests__/metrics_grid.test.tsx | 9 ++- 3 files changed, 49 insertions(+), 31 deletions(-) diff --git a/public/components/custom_panels/helpers/utils.tsx b/public/components/custom_panels/helpers/utils.tsx index 2dca73066..47c945967 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 7c1f2dc9b..290765b80 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 = ( diff --git a/public/components/metrics/view/__tests__/metrics_grid.test.tsx b/public/components/metrics/view/__tests__/metrics_grid.test.tsx index 2cf11a501..cf3a3f57b 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'; @@ -23,6 +27,9 @@ describe('Metrics Grid Component', () => { 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;