dataSetStep.tsx 2.4 KB

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