dataSetStep.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import styled from '@emotion/styled';
  2. import type {RadioGroupProps} from 'sentry/components/forms/controls/radioGroup';
  3. import RadioGroup from 'sentry/components/forms/controls/radioGroup';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import {t, tct} from 'sentry/locale';
  6. import {space} from 'sentry/styles/space';
  7. import {DisplayType} from 'sentry/views/dashboards/types';
  8. import {DataSet} from '../utils';
  9. import {BuildStep} from './buildStep';
  10. // const DATASET_CHOICES: [DataSet, string][] = [
  11. // [DataSet.EVENTS, t('Errors and Transactions')],
  12. // [DataSet.ISSUES, t('Issues (States, Assignment, Time, etc.)')],
  13. // ];
  14. interface Props {
  15. dataSet: DataSet;
  16. displayType: DisplayType;
  17. hasReleaseHealthFeature: boolean;
  18. onChange: (dataSet: DataSet) => void;
  19. }
  20. export function DataSetStep({
  21. dataSet,
  22. onChange,
  23. hasReleaseHealthFeature,
  24. displayType,
  25. }: Props) {
  26. const disabledChoices: RadioGroupProps<string>['disabledChoices'] = [];
  27. if (displayType !== DisplayType.TABLE) {
  28. disabledChoices.push([
  29. DataSet.ISSUES,
  30. t('This dataset is restricted to tabular visualization.'),
  31. ]);
  32. }
  33. const datasetChoices = new Map<string, string>();
  34. datasetChoices.set(DataSet.EVENTS, t('Errors and Transactions'));
  35. datasetChoices.set(DataSet.ISSUES, t('Issues (States, Assignment, Time, etc.)'));
  36. if (hasReleaseHealthFeature) {
  37. datasetChoices.set(DataSet.RELEASES, t('Releases (Sessions, Crash rates)'));
  38. }
  39. return (
  40. <BuildStep
  41. title={t('Choose your dataset')}
  42. description={tct(
  43. `This reflects the type of information you want to use. To learn more, [link: read the docs].`,
  44. {
  45. link: (
  46. <ExternalLink href="https://docs.sentry.io/product/dashboards/widget-builder/#choose-your-dataset" />
  47. ),
  48. }
  49. )}
  50. >
  51. <DataSetChoices
  52. label="dataSet"
  53. value={dataSet}
  54. choices={[...datasetChoices.entries()]}
  55. disabledChoices={disabledChoices}
  56. onChange={newDataSet => {
  57. onChange(newDataSet as DataSet);
  58. }}
  59. orientInline
  60. />
  61. </BuildStep>
  62. );
  63. }
  64. const DataSetChoices = styled(RadioGroup)`
  65. display: flex;
  66. flex-wrap: wrap;
  67. gap: ${space(2)};
  68. `;