index.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import {Fragment} from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import ProjectActions from 'sentry/actions/projectActions';
  4. import Feature from 'sentry/components/acl/feature';
  5. import Form from 'sentry/components/forms/form';
  6. import JsonForm from 'sentry/components/forms/jsonForm';
  7. import ExternalLink from 'sentry/components/links/externalLink';
  8. import {fields} from 'sentry/data/forms/projectIssueGrouping';
  9. import {t, tct} from 'sentry/locale';
  10. import {EventGroupingConfig, Organization, Project} from 'sentry/types';
  11. import routeTitleGen from 'sentry/utils/routeTitle';
  12. import AsyncView from 'sentry/views/asyncView';
  13. import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
  14. import TextBlock from 'sentry/views/settings/components/text/textBlock';
  15. import UpgradeGrouping from './upgradeGrouping';
  16. type Props = RouteComponentProps<{orgId: string; projectId: string}, {}> & {
  17. organization: Organization;
  18. project: Project;
  19. };
  20. type State = {
  21. groupingConfigs: EventGroupingConfig[] | null;
  22. } & AsyncView['state'];
  23. class ProjectIssueGrouping extends AsyncView<Props, State> {
  24. getTitle() {
  25. const {projectId} = this.props.params;
  26. return routeTitleGen(t('Issue Grouping'), projectId, false);
  27. }
  28. getDefaultState() {
  29. return {
  30. ...super.getDefaultState(),
  31. groupingConfigs: [],
  32. };
  33. }
  34. getEndpoints(): ReturnType<AsyncView['getEndpoints']> {
  35. const {projectId, orgId} = this.props.params;
  36. return [['groupingConfigs', `/projects/${orgId}/${projectId}/grouping-configs/`]];
  37. }
  38. handleSubmit = (response: Project) => {
  39. // This will update our project context
  40. ProjectActions.updateSuccess(response);
  41. };
  42. renderBody() {
  43. const {groupingConfigs} = this.state;
  44. const {organization, project, params, location} = this.props;
  45. const {orgId, projectId} = params;
  46. const endpoint = `/projects/${orgId}/${projectId}/`;
  47. const access = new Set(organization.access);
  48. const jsonFormProps = {
  49. additionalFieldProps: {
  50. organization,
  51. groupingConfigs,
  52. },
  53. features: new Set(organization.features),
  54. access,
  55. disabled: !access.has('project:write'),
  56. };
  57. return (
  58. <Fragment>
  59. <SettingsPageHeader title={t('Issue Grouping')} />
  60. <TextBlock>
  61. {tct(
  62. `All events have a fingerprint. Events with the same fingerprint are grouped together into an issue. To learn more about issue grouping, [link: read the docs].`,
  63. {
  64. link: (
  65. <ExternalLink href="https://docs.sentry.io/product/data-management-settings/event-grouping/" />
  66. ),
  67. }
  68. )}
  69. </TextBlock>
  70. <Form
  71. saveOnBlur
  72. allowUndo
  73. initialData={project}
  74. apiMethod="PUT"
  75. apiEndpoint={endpoint}
  76. onSubmitSuccess={this.handleSubmit}
  77. >
  78. <JsonForm
  79. {...jsonFormProps}
  80. title={t('Fingerprint Rules')}
  81. fields={[fields.fingerprintingRules]}
  82. />
  83. <JsonForm
  84. {...jsonFormProps}
  85. title={t('Stack Trace Rules')}
  86. fields={[fields.groupingEnhancements]}
  87. />
  88. <Feature features={['set-grouping-config']} organization={organization}>
  89. <JsonForm
  90. {...jsonFormProps}
  91. title={t('Change defaults')}
  92. fields={[
  93. fields.groupingConfig,
  94. fields.secondaryGroupingConfig,
  95. fields.secondaryGroupingExpiry,
  96. ]}
  97. />
  98. </Feature>
  99. <JsonForm
  100. {...jsonFormProps}
  101. title={t('Automatic Grouping Updates')}
  102. fields={[fields.groupingAutoUpdate]}
  103. />
  104. <UpgradeGrouping
  105. groupingConfigs={groupingConfigs ?? []}
  106. organization={organization}
  107. projectId={params.projectId}
  108. project={project}
  109. api={this.api}
  110. onUpgrade={this.fetchData}
  111. location={location}
  112. />
  113. </Form>
  114. </Fragment>
  115. );
  116. }
  117. }
  118. export default ProjectIssueGrouping;