index.tsx 2.7 KB

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