Skip to content

Commit

Permalink
show actual interval in panel for GTE_INTERVAL_RE values
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Mar 6, 2019
1 parent 9a0c978 commit ca57bac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ export const convertIntervalIntoUnit = (interval, hasTranslateUnitString = true)
}
}
};
export const isGteInterval = (interval) => GTE_INTERVAL_RE.test(interval);

export const isIntervalValid = (interval) => {
return isString(interval) &&
(interval === 'auto' || INTERVAL_STRING_RE.test(interval) || GTE_INTERVAL_RE.test(interval));
(interval === 'auto' || INTERVAL_STRING_RE.test(interval) || isGteInterval(interval));
};

export const getInterval = (visData, model) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { get } from 'lodash';
import { keyCodes, EuiFlexGroup, EuiFlexItem, EuiButton, EuiText, EuiSwitch } from '@elastic/eui';
import { getVisualizeLoader } from 'ui/visualize/loader/visualize_loader';
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
import { getInterval, convertIntervalIntoUnit, isIntervalValid } from './lib/get_interval';
import { getInterval, convertIntervalIntoUnit, isIntervalValid, isGteInterval } from './lib/get_interval';

const MIN_CHART_HEIGHT = 250;

Expand Down Expand Up @@ -161,8 +161,9 @@ class VisEditorVisualization extends Component {
getFormattedPanelInterval() {
const interval = get(this.props, 'model.interval') || 'auto';
const isValid = isIntervalValid(interval);
const shouldShowActualInterval = interval === 'auto' || isGteInterval(interval);

if (interval === 'auto' || !isValid) {
if (shouldShowActualInterval || !isValid) {
const autoInterval = convertIntervalIntoUnit(this.state.panelInterval, false);

if (autoInterval) {
Expand Down

0 comments on commit ca57bac

Please sign in to comment.