ServiceSelector.tsx 859 B

1234567891011121314151617181920212223242526272829303132
  1. import React, { SFC } from 'react';
  2. import uniqBy from 'lodash/uniqBy';
  3. interface Props {
  4. onServiceChange: any;
  5. metricDescriptors: any[];
  6. }
  7. const ServiceSelector: SFC<Props> = props => {
  8. const extractServices = () =>
  9. uniqBy(props.metricDescriptors, 'service').map(m => ({
  10. value: m.service,
  11. name: m.serviceShortName,
  12. }));
  13. return (
  14. <div className="gf-form max-width-21">
  15. <span className="gf-form-label width-7">Service</span>
  16. <div className="gf-form-select-wrapper max-width-14">
  17. <select className="gf-form-input" required onChange={props.onServiceChange}>
  18. {extractServices().map((qt, i) => (
  19. <option key={i} value={qt.value} ng-if="false">
  20. {qt.name}
  21. </option>
  22. ))}
  23. </select>
  24. </div>
  25. </div>
  26. );
  27. };
  28. export default ServiceSelector;