dataSetStep.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import FeatureBadge from 'sentry/components/featureBadge';
  4. import RadioGroup, {RadioGroupProps} from 'sentry/components/forms/controls/radioGroup';
  5. import ExternalLink from 'sentry/components/links/externalLink';
  6. import {t, tct} from 'sentry/locale';
  7. import space from 'sentry/styles/space';
  8. import {DisplayType} from 'sentry/views/dashboardsV2/types';
  9. import {DataSet} from '../utils';
  10. import {BuildStep} from './buildStep';
  11. const DATASET_CHOICES: [DataSet, string][] = [
  12. [DataSet.EVENTS, t('Errors and Transactions')],
  13. [DataSet.ISSUES, t('Issues (States, Assignment, Time, etc.)')],
  14. ];
  15. interface Props {
  16. dataSet: DataSet;
  17. displayType: DisplayType;
  18. hasReleaseHealthFeature: boolean;
  19. onChange: (dataSet: DataSet) => void;
  20. }
  21. export function DataSetStep({
  22. dataSet,
  23. onChange,
  24. hasReleaseHealthFeature,
  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. if (displayType === DisplayType.WORLD_MAP) {
  34. disabledChoices.push([
  35. DataSet.RELEASES,
  36. t(
  37. 'This dataset is restricted to big number, tabular and time series visualizations.'
  38. ),
  39. ]);
  40. }
  41. }
  42. return (
  43. <BuildStep
  44. title={t('Choose your dataset')}
  45. description={tct(
  46. `This reflects the type of information you want to use. To learn more, [link: read the docs].`,
  47. {
  48. link: (
  49. <ExternalLink href="https://docs.sentry.io/product/dashboards/widget-builder/#choose-your-dataset" />
  50. ),
  51. }
  52. )}
  53. >
  54. <DataSetChoices
  55. label="dataSet"
  56. value={dataSet}
  57. choices={
  58. hasReleaseHealthFeature
  59. ? [
  60. ...DATASET_CHOICES,
  61. [
  62. DataSet.RELEASES,
  63. <Fragment key="releases-dataset">
  64. {t('Releases (Sessions, Crash rates)')} <FeatureBadge type="new" />
  65. </Fragment>,
  66. ],
  67. ]
  68. : DATASET_CHOICES
  69. }
  70. disabledChoices={disabledChoices}
  71. onChange={newDataSet => {
  72. onChange(newDataSet as DataSet);
  73. }}
  74. />
  75. </BuildStep>
  76. );
  77. }
  78. const DataSetChoices = styled(RadioGroup)`
  79. display: flex;
  80. flex-wrap: wrap;
  81. gap: ${space(2)};
  82. `;