index.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import {Fragment} from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import Feature from 'sentry/components/acl/feature';
  4. import Form from 'sentry/components/forms/form';
  5. import JsonForm from 'sentry/components/forms/jsonForm';
  6. import ExternalLink from 'sentry/components/links/externalLink';
  7. import {fields} from 'sentry/data/forms/projectIssueGrouping';
  8. import {t, tct} from 'sentry/locale';
  9. import ProjectsStore from 'sentry/stores/projectsStore';
  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<{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 {organization, project} = this.props;
  36. return [
  37. [
  38. 'groupingConfigs',
  39. `/projects/${organization.slug}/${project.slug}/grouping-configs/`,
  40. ],
  41. ];
  42. }
  43. handleSubmit = (response: Project) => {
  44. // This will update our project context
  45. ProjectsStore.onUpdateSuccess(response);
  46. };
  47. renderBody() {
  48. const {groupingConfigs} = this.state;
  49. const {organization, project, params, location} = this.props;
  50. const endpoint = `/projects/${organization.slug}/${project.slug}/`;
  51. const access = new Set(organization.access);
  52. const jsonFormProps = {
  53. additionalFieldProps: {
  54. organization,
  55. groupingConfigs,
  56. },
  57. features: new Set(organization.features),
  58. access,
  59. disabled: !access.has('project:write'),
  60. };
  61. return (
  62. <Fragment>
  63. <SettingsPageHeader title={t('Issue Grouping')} />
  64. <TextBlock>
  65. {tct(
  66. `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].`,
  67. {
  68. link: (
  69. <ExternalLink href="https://docs.sentry.io/product/data-management-settings/event-grouping/" />
  70. ),
  71. }
  72. )}
  73. </TextBlock>
  74. <Form
  75. saveOnBlur
  76. allowUndo
  77. initialData={project}
  78. apiMethod="PUT"
  79. apiEndpoint={endpoint}
  80. onSubmitSuccess={this.handleSubmit}
  81. >
  82. <JsonForm
  83. {...jsonFormProps}
  84. title={t('Fingerprint Rules')}
  85. fields={[fields.fingerprintingRules]}
  86. />
  87. <JsonForm
  88. {...jsonFormProps}
  89. title={t('Stack Trace Rules')}
  90. fields={[fields.groupingEnhancements]}
  91. />
  92. <Feature features={['set-grouping-config']} organization={organization}>
  93. <JsonForm
  94. {...jsonFormProps}
  95. title={t('Change defaults')}
  96. fields={[
  97. fields.groupingConfig,
  98. fields.secondaryGroupingConfig,
  99. fields.secondaryGroupingExpiry,
  100. ]}
  101. />
  102. </Feature>
  103. <JsonForm
  104. {...jsonFormProps}
  105. title={t('Automatic Grouping Updates')}
  106. fields={[fields.groupingAutoUpdate]}
  107. />
  108. <UpgradeGrouping
  109. groupingConfigs={groupingConfigs ?? []}
  110. organization={organization}
  111. projectId={params.projectId}
  112. project={project}
  113. api={this.api}
  114. onUpgrade={this.fetchData}
  115. location={location}
  116. />
  117. </Form>
  118. </Fragment>
  119. );
  120. }
  121. }
  122. export default ProjectIssueGrouping;