Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed PPL Error in containers & added tool tip to date picker #179

Merged
merged 3 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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