Skip to content

Commit

Permalink
TSVB needs to display better UX message when default index pattern is…
Browse files Browse the repository at this point in the history
… non-time based (#124341)

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
DianaDerevyankina and kibanamachine authored Feb 8, 2022
1 parent a248af0 commit c299aab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/plugins/vis_types/timeseries/common/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;
Expand Down

0 comments on commit c299aab

Please sign in to comment.