dataSetStep.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. if (displayType === DisplayType.WORLD_MAP) {
  32. disabledChoices.push([
  33. DataSet.RELEASES,
  34. t(
  35. 'This dataset is restricted to big number, tabular and time series visualizations.'
  36. ),
  37. ]);
  38. }
  39. }
  40. return (
  41. <BuildStep
  42. title={t('Choose your dataset')}
  43. description={tct(
  44. `This reflects the type of information you want to use. To learn more, [link: read the docs].`,
  45. {
  46. link: (
  47. <ExternalLink href="https://docs.sentry.io/product/dashboards/widget-builder/#choose-your-dataset" />
  48. ),
  49. }
  50. )}
  51. >
  52. <DataSetChoices
  53. label="dataSet"
  54. value={dataSet}
  55. choices={
  56. hasReleaseHealthFeature
  57. ? [
  58. ...DATASET_CHOICES,
  59. [DataSet.RELEASES, t('Releases (Sessions, Crash rates)')],
  60. ]
  61. : DATASET_CHOICES
  62. }
  63. disabledChoices={disabledChoices}
  64. onChange={newDataSet => {
  65. onChange(newDataSet as DataSet);
  66. }}
  67. orientInline
  68. />
  69. </BuildStep>
  70. );
  71. }
  72. const DataSetChoices = styled(RadioGroup)`
  73. display: flex;
  74. flex-wrap: wrap;
  75. gap: ${space(2)};
  76. `;