index.tsx 1.2 KB

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