index.tsx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import {Component, Fragment} from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import {addErrorMessage} from 'sentry/actionCreators/indicator';
  4. import ProjectActions from 'sentry/actions/projectActions';
  5. import Form from 'sentry/components/forms/form';
  6. import JsonForm from 'sentry/components/forms/jsonForm';
  7. import Link from 'sentry/components/links/link';
  8. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  9. import projectSecurityAndPrivacyGroups from 'sentry/data/forms/projectSecurityAndPrivacyGroups';
  10. import {t, tct} from 'sentry/locale';
  11. import {Organization, Project} from 'sentry/types';
  12. import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
  13. import DataScrubbing from '../components/dataScrubbing';
  14. type Props = RouteComponentProps<{orgId: string; projectId: string}, {}> & {
  15. organization: Organization;
  16. project: Project;
  17. };
  18. class ProjectSecurityAndPrivacy extends Component<Props> {
  19. handleUpdateProject = (data: Project) => {
  20. // This will update our project global state
  21. ProjectActions.updateSuccess(data);
  22. };
  23. render() {
  24. const {organization, project} = this.props;
  25. const initialData = project;
  26. const projectSlug = project.slug;
  27. const endpoint = `/projects/${organization.slug}/${projectSlug}/`;
  28. const access = new Set(organization.access);
  29. const features = new Set(organization.features);
  30. const relayPiiConfig = project.relayPiiConfig;
  31. const apiMethod = 'PUT';
  32. const title = t('Security & Privacy');
  33. return (
  34. <Fragment>
  35. <SentryDocumentTitle title={title} projectSlug={projectSlug} />
  36. <SettingsPageHeader title={title} />
  37. <Form
  38. saveOnBlur
  39. allowUndo
  40. initialData={initialData}
  41. apiMethod={apiMethod}
  42. apiEndpoint={endpoint}
  43. onSubmitSuccess={this.handleUpdateProject}
  44. onSubmitError={() => addErrorMessage('Unable to save change')}
  45. >
  46. <JsonForm
  47. additionalFieldProps={{organization}}
  48. features={features}
  49. disabled={!access.has('project:write')}
  50. forms={projectSecurityAndPrivacyGroups}
  51. />
  52. </Form>
  53. <DataScrubbing
  54. additionalContext={
  55. <span>
  56. {tct(
  57. 'These rules can be configured at the organization level in [linkToOrganizationSecurityAndPrivacy].',
  58. {
  59. linkToOrganizationSecurityAndPrivacy: (
  60. <Link to={`/settings/${organization.slug}/security-and-privacy/`}>
  61. {title}
  62. </Link>
  63. ),
  64. }
  65. )}
  66. </span>
  67. }
  68. endpoint={endpoint}
  69. relayPiiConfig={relayPiiConfig}
  70. disabled={!access.has('project:write')}
  71. organization={organization}
  72. projectId={project.id}
  73. onSubmitSuccess={this.handleUpdateProject}
  74. />
  75. </Fragment>
  76. );
  77. }
  78. }
  79. export default ProjectSecurityAndPrivacy;