index.tsx 4.3 KB

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