index.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import {t} from 'sentry/locale';
  2. import {Organization, TagCollection} from 'sentry/types';
  3. import {QueryFieldValue} from 'sentry/utils/discover/fields';
  4. import {WidgetQuery} from 'sentry/views/dashboards/types';
  5. import {DataSet, useGroupByOptions} from '../../utils';
  6. import {DATA_SET_TO_WIDGET_TYPE} from '../../widgetBuilder';
  7. import {BuildStep} from '../buildStep';
  8. import {GroupBySelector} from './groupBySelector';
  9. interface Props {
  10. columns: QueryFieldValue[];
  11. dataSet: DataSet;
  12. onGroupByChange: (newFields: QueryFieldValue[]) => void;
  13. organization: Organization;
  14. queries: WidgetQuery[];
  15. tags: TagCollection;
  16. }
  17. export function GroupByStep({
  18. dataSet,
  19. columns,
  20. onGroupByChange,
  21. organization,
  22. tags,
  23. queries,
  24. }: Props) {
  25. const widgetType = DATA_SET_TO_WIDGET_TYPE[dataSet];
  26. const groupByOptions = useGroupByOptions(organization, tags, widgetType, queries);
  27. return (
  28. <BuildStep
  29. title={t('Group your results')}
  30. description={t('This is how you can group your data result by field or tag.')}
  31. >
  32. <GroupBySelector
  33. columns={columns}
  34. fieldOptions={groupByOptions}
  35. onChange={onGroupByChange}
  36. />
  37. </BuildStep>
  38. );
  39. }