all files / src/explore/components/ MetricDefinitionOption.jsx

90.48% Statements 19/21
83.33% Branches 5/6
100% Functions 1/1
89.47% Lines 17/19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                                        
import React from 'react';
import PropTypes from 'prop-types';
 
import MetricOption from '../../components/MetricOption';
import ColumnOption from '../../components/ColumnOption';
import AggregateOption from './AggregateOption';
import columnType from '../propTypes/columnType';
import savedMetricType from '../propTypes/savedMetricType';
import aggregateOptionType from '../propTypes/aggregateOptionType';
 
const propTypes = {
  option: PropTypes.oneOfType([
    columnType,
    savedMetricType,
    aggregateOptionType,
  ]).isRequired,
};
 
export default function MetricDefinitionOption({ option }) {
  if (option.metric_name) {
    return (
      <MetricOption metric={option} showType />
    );
  } else if (option.column_name) {
    return (
      <ColumnOption column={option} showType />
    );
  } else Eif (option.aggregate_name) {
    return (
      <AggregateOption aggregate={option} showType />
    );
  }
  notify.error('You must supply either a saved metric, column or aggregate to MetricDefinitionOption');
  return null;
}
MetricDefinitionOption.propTypes = propTypes;