ServicePicker.tsx 921 B

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