dataSetStep.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. [DataSet.RELEASES, t('Releases (Sessions, Crash rates)')],
  13. ];
  14. interface Props {
  15. dataSet: DataSet;
  16. displayType: DisplayType;
  17. onChange: (dataSet: DataSet) => void;
  18. }
  19. export function DataSetStep({dataSet, onChange, displayType}: Props) {
  20. const disabledChoices: RadioGroupProps<string>['disabledChoices'] = [];
  21. if (displayType !== DisplayType.TABLE) {
  22. disabledChoices.push([
  23. DataSet.ISSUES,
  24. t('This dataset is restricted to tabular visualization.'),
  25. ]);
  26. if (displayType === DisplayType.WORLD_MAP) {
  27. disabledChoices.push([
  28. DataSet.RELEASES,
  29. t(
  30. 'This dataset is restricted to big number, tabular and time series visualizations.'
  31. ),
  32. ]);
  33. }
  34. }
  35. return (
  36. <BuildStep
  37. title={t('Choose your dataset')}
  38. description={tct(
  39. `This reflects the type of information you want to use. To learn more, [link: read the docs].`,
  40. {
  41. link: (
  42. <ExternalLink href="https://docs.sentry.io/product/dashboards/widget-builder/#choose-your-dataset" />
  43. ),
  44. }
  45. )}
  46. >
  47. <DataSetChoices
  48. label="dataSet"
  49. value={dataSet}
  50. choices={DATASET_CHOICES}
  51. disabledChoices={disabledChoices}
  52. onChange={newDataSet => {
  53. onChange(newDataSet as DataSet);
  54. }}
  55. orientInline
  56. />
  57. </BuildStep>
  58. );
  59. }
  60. const DataSetChoices = styled(RadioGroup)`
  61. display: flex;
  62. flex-wrap: wrap;
  63. gap: ${space(2)};
  64. `;