metricsCompatibilityQuery.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import omit from 'lodash/omit';
  2. import EventView from 'sentry/utils/discover/eventView';
  3. import GenericDiscoverQuery, {
  4. DiscoverQueryProps,
  5. GenericChildrenProps,
  6. } from 'sentry/utils/discover/genericDiscoverQuery';
  7. export interface MetricsCompatibilityData {
  8. compatible_projects?: number[];
  9. }
  10. type QueryProps = Omit<DiscoverQueryProps, 'eventView' | 'api'> & {
  11. children: (props: GenericChildrenProps<MetricsCompatibilityData>) => React.ReactNode;
  12. eventView: EventView;
  13. };
  14. function getRequestPayload({
  15. eventView,
  16. location,
  17. }: Pick<DiscoverQueryProps, 'eventView' | 'location'>) {
  18. return omit(eventView.getEventsAPIPayload(location), [
  19. 'field',
  20. 'sort',
  21. 'per_page',
  22. 'query',
  23. ]);
  24. }
  25. export default function MetricsCompatibilityQuery({children, ...props}: QueryProps) {
  26. return (
  27. <GenericDiscoverQuery<MetricsCompatibilityData, {}>
  28. route="metrics-compatibility-sums"
  29. getRequestPayload={getRequestPayload}
  30. {...props}
  31. >
  32. {({tableData, ...rest}) => {
  33. return children({
  34. tableData,
  35. ...rest,
  36. });
  37. }}
  38. </GenericDiscoverQuery>
  39. );
  40. }