index.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {t, tct} from 'sentry/locale';
  3. import type {TagCollection} from 'sentry/types/group';
  4. import type {QueryFieldValue} from 'sentry/utils/discover/fields';
  5. import useCustomMeasurements from 'sentry/utils/useCustomMeasurements';
  6. import useOrganization from 'sentry/utils/useOrganization';
  7. import {getDatasetConfig} from 'sentry/views/dashboards/datasetConfig/base';
  8. import type {DisplayType, WidgetQuery, WidgetType} from 'sentry/views/dashboards/types';
  9. import {hasDatasetSelector} from 'sentry/views/dashboards/utils';
  10. import {addIncompatibleFunctions, DataSet} from '../../utils';
  11. import {BuildStep} from '../buildStep';
  12. import {ColumnFields} from './columnFields';
  13. interface Props {
  14. dataSet: DataSet;
  15. displayType: DisplayType;
  16. explodedFields: QueryFieldValue[];
  17. handleColumnFieldChange: (newFields: QueryFieldValue[]) => void;
  18. isOnDemandWidget: boolean;
  19. onQueryChange: (queryIndex: number, newQuery: WidgetQuery) => void;
  20. tags: TagCollection;
  21. widgetType: WidgetType;
  22. queryErrors?: Record<string, any>[];
  23. }
  24. export function ColumnsStep({
  25. dataSet,
  26. displayType,
  27. widgetType,
  28. handleColumnFieldChange,
  29. queryErrors,
  30. explodedFields,
  31. tags,
  32. isOnDemandWidget,
  33. }: Props) {
  34. const organization = useOrganization();
  35. const {customMeasurements} = useCustomMeasurements();
  36. const datasetConfig = getDatasetConfig(widgetType);
  37. const fieldOptions = datasetConfig.getTableFieldOptions(
  38. organization,
  39. tags,
  40. customMeasurements
  41. );
  42. // We need to persist the form values across Errors and Transactions datasets
  43. // for the discover dataset split, so functions that are not compatible with
  44. // errors should still appear in the field options to gracefully handle incorrect
  45. // dataset splitting.
  46. if (
  47. hasDatasetSelector(organization) &&
  48. [DataSet.ERRORS, DataSet.TRANSACTIONS].includes(dataSet)
  49. ) {
  50. addIncompatibleFunctions(explodedFields, fieldOptions);
  51. }
  52. return (
  53. <BuildStep
  54. data-test-id="choose-column-step"
  55. title={t('Choose your columns')}
  56. description={
  57. dataSet === DataSet.ISSUES
  58. ? tct(
  59. '[fieldTagLink: Field and tag] columns will help you view more details about the issues (e.g., title).',
  60. {
  61. fieldTagLink: (
  62. <ExternalLink href="https://docs.sentry.io/product/sentry-basics/search/searchable-properties/#event-properties" />
  63. ),
  64. }
  65. )
  66. : dataSet === DataSet.RELEASES
  67. ? tct(
  68. 'To stack sessions, add [functionLink: functions] f(x) that may take in additional parameters. [fieldTagLink: Field and tag] columns will help you view more details about the sessions (e.g., releases).',
  69. {
  70. functionLink: (
  71. <ExternalLink href="https://docs.sentry.io/product/discover-queries/query-builder/#filter-by-table-columns" />
  72. ),
  73. fieldTagLink: (
  74. <ExternalLink href="https://docs.sentry.io/product/sentry-basics/search/searchable-properties/#release-properties" />
  75. ),
  76. }
  77. )
  78. : tct(
  79. 'To stack events, add [functionLink: functions] f(x) that may take in additional parameters. [fieldTagLink: Field and tag] columns will help you view more details about the events (e.g., title).',
  80. {
  81. functionLink: (
  82. <ExternalLink href="https://docs.sentry.io/product/discover-queries/query-builder/#filter-by-table-columns" />
  83. ),
  84. fieldTagLink: (
  85. <ExternalLink href="https://docs.sentry.io/product/sentry-basics/search/searchable-properties/#event-properties" />
  86. ),
  87. }
  88. )
  89. }
  90. >
  91. <ColumnFields
  92. displayType={displayType}
  93. organization={organization}
  94. widgetType={widgetType}
  95. fields={explodedFields}
  96. errors={queryErrors}
  97. fieldOptions={fieldOptions}
  98. isOnDemandWidget={isOnDemandWidget}
  99. filterAggregateParameters={datasetConfig.filterAggregateParams}
  100. filterPrimaryOptions={datasetConfig.filterTableOptions}
  101. onChange={handleColumnFieldChange}
  102. />
  103. </BuildStep>
  104. );
  105. }