dataSetStep.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. hasReleaseHealthFeature: boolean;
  17. onChange: (dataSet: DataSet) => void;
  18. }
  19. export function DataSetStep({
  20. dataSet,
  21. onChange,
  22. hasReleaseHealthFeature,
  23. displayType,
  24. }: Props) {
  25. const disabledChoices: RadioGroupProps<string>['disabledChoices'] = [];
  26. if (displayType !== DisplayType.TABLE) {
  27. disabledChoices.push([
  28. DataSet.ISSUES,
  29. t('This dataset is restricted to tabular visualization.'),
  30. ]);
  31. }
  32. return (
  33. <BuildStep
  34. title={t('Choose your dataset')}
  35. description={tct(
  36. `This reflects the type of information you want to use. To learn more, [link: read the docs].`,
  37. {
  38. link: (
  39. <ExternalLink href="https://docs.sentry.io/product/dashboards/widget-builder/#choose-your-dataset" />
  40. ),
  41. }
  42. )}
  43. >
  44. <DataSetChoices
  45. label="dataSet"
  46. value={dataSet}
  47. choices={
  48. hasReleaseHealthFeature
  49. ? [
  50. ...DATASET_CHOICES,
  51. [DataSet.RELEASES, t('Releases (Sessions, Crash rates)')],
  52. ]
  53. : DATASET_CHOICES
  54. }
  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. `;