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 {getDatasetConfig} from 'sentry/views/dashboards/datasetConfig/base';
  5. import {DataSet} 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. tags: TagCollection;
  15. }
  16. export function GroupByStep({
  17. dataSet,
  18. columns,
  19. onGroupByChange,
  20. organization,
  21. tags,
  22. }: Props) {
  23. const datasetConfig = getDatasetConfig(DATA_SET_TO_WIDGET_TYPE[dataSet]);
  24. return (
  25. <BuildStep
  26. title={t('Group your results')}
  27. description={t('This is how you can group your data result by field or tag.')}
  28. >
  29. <GroupBySelector
  30. columns={columns}
  31. fieldOptions={
  32. datasetConfig.getGroupByFieldOptions
  33. ? datasetConfig.getGroupByFieldOptions(organization, tags)
  34. : {}
  35. }
  36. onChange={onGroupByChange}
  37. />
  38. </BuildStep>
  39. );
  40. }