TSVB needs to display better UX message when default index pattern is non-time based (#124341)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Diana Derevyankina 2022-02-08 13:02:15 +03:00 committed by GitHub
parent a248af003d
commit c299aabcb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -58,6 +58,16 @@ export class AggNotSupportedError extends UIError {
}
}
export class TimeFieldNotSpecifiedError extends UIError {
constructor() {
super(
i18n.translate('visTypeTimeseries.errors.timeFieldNotSpecifiedError', {
defaultMessage: 'Time field is required to visualize the data',
})
);
}
}
export const filterCannotBeAppliedErrorMessage = i18n.translate(
'visTypeTimeseries.filterCannotBeAppliedError',
{

View file

@ -9,6 +9,7 @@ import moment from 'moment';
import { AUTO_INTERVAL } from '../../../common/constants';
import { validateField } from '../../../common/fields_utils';
import { validateInterval } from '../../../common/validate_interval';
import { TimeFieldNotSpecifiedError } from '../../../common/errors';
import type { FetchedIndexPattern, Panel, Series } from '../../../common/types';
@ -34,7 +35,11 @@ export function getIntervalAndTimefield(
}
if (panel.use_kibana_indexes) {
validateField(timeField!, index);
if (timeField) {
validateField(timeField, index);
} else {
throw new TimeFieldNotSpecifiedError();
}
}
let interval = panel.interval;