Skip to content

Commit

Permalink
Fixed PPL Error in containers & added tool tip to date picker (#179) (#…
Browse files Browse the repository at this point in the history
…181)

* fix SQL errors displayed in viz. container

Signed-off-by: Shenoy Pratik <[email protected]>

* fix metrics grid test

Signed-off-by: Shenoy Pratik <[email protected]>

* remoe unused flag

Signed-off-by: Shenoy Pratik <[email protected]>

Signed-off-by: Shenoy Pratik <[email protected]>
(cherry picked from commit 8bb5e30)

Co-authored-by: Shenoy Pratik <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and ps48 authored Jan 9, 2023
1 parent baf90c4 commit a8c54a5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 31 deletions.
10 changes: 7 additions & 3 deletions public/components/custom_panels/helpers/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
EuiSpacer,
EuiText,
EuiTitle,
EuiToolTip,
ShortDate,
} from '@elastic/eui';
import _ from 'lodash';
Expand Down Expand Up @@ -180,33 +181,39 @@ export const VisaulizationFlyout = ({
};

const timeRange = (
<EuiFormRow label="Panel Time Range" fullWidth>
<EuiDatePickerRange
className="date-picker-preview"
fullWidth
readOnly
startDateControl={
<EuiDatePicker
selected={startDate}
startDate={startDate}
endDate={endDate}
isInvalid={startDate > endDate}
aria-label="Start date"
dateFormat={uiSettingsService.get('dateFormat')}
/>
}
endDateControl={
<EuiDatePicker
selected={endDate}
startDate={startDate}
endDate={endDate}
isInvalid={startDate > endDate}
aria-label="End date"
dateFormat={uiSettingsService.get('dateFormat')}
/>
}
/>
</EuiFormRow>
<EuiToolTip
position="bottom"
content="Picker is disabled. Please edit date/time from panel"
display="block"
>
<EuiFormRow label="Panel Time Range" fullWidth>
<EuiDatePickerRange
className="date-picker-preview"
fullWidth
readOnly
startDateControl={
<EuiDatePicker
selected={startDate}
startDate={startDate}
endDate={endDate}
isInvalid={startDate > endDate}
aria-label="Start date"
dateFormat={uiSettingsService.get('dateFormat')}
/>
}
endDateControl={
<EuiDatePicker
selected={endDate}
startDate={startDate}
endDate={endDate}
isInvalid={startDate > endDate}
aria-label="End date"
dateFormat={uiSettingsService.get('dateFormat')}
/>
}
/>
</EuiFormRow>
</EuiToolTip>
);

const flyoutHeader = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down

0 comments on commit a8c54a5

Please sign in to comment.