dataSetStep.tsx 2.3 KB

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