AlignmentPeriods.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React, { SFC } from 'react';
  2. import _ from 'lodash';
  3. import { MetricSelect } from 'app/core/components/Select/MetricSelect';
  4. import { alignmentPeriods } from '../constants';
  5. export interface Props {
  6. onChange: (alignmentPeriod) => void;
  7. templateSrv: any;
  8. alignmentPeriod: string;
  9. }
  10. export const AlignmentPeriods: SFC<Props> = ({ alignmentPeriod, templateSrv, onChange }) => {
  11. return (
  12. <>
  13. <div className="gf-form-inline">
  14. <div className="gf-form">
  15. <label className="gf-form-label query-keyword width-9">Alignment Period</label>
  16. <MetricSelect
  17. onChange={value => onChange(value)}
  18. value={alignmentPeriod}
  19. variables={templateSrv.variables}
  20. options={[
  21. {
  22. label: 'Alignment options',
  23. expanded: true,
  24. options: alignmentPeriods.map(ap => ({
  25. ...ap,
  26. label: ap.text,
  27. })),
  28. },
  29. ]}
  30. placeholder="Select Alignment"
  31. className="width-15"
  32. />
  33. </div>
  34. </div>
  35. </>
  36. );
  37. };