index.tsx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import {Fragment} from 'react';
  2. import {addErrorMessage} from 'sentry/actionCreators/indicator';
  3. import {hasEveryAccess} from 'sentry/components/acl/access';
  4. import Form from 'sentry/components/forms/form';
  5. import JsonForm from 'sentry/components/forms/jsonForm';
  6. import Link from 'sentry/components/links/link';
  7. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  8. import projectSecurityAndPrivacyGroups from 'sentry/data/forms/projectSecurityAndPrivacyGroups';
  9. import {t, tct} from 'sentry/locale';
  10. import ProjectsStore from 'sentry/stores/projectsStore';
  11. import {Organization, Project} from 'sentry/types';
  12. import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
  13. import PermissionAlert from 'sentry/views/settings/project/permissionAlert';
  14. import {DataScrubbing} from '../components/dataScrubbing';
  15. type Props = {
  16. organization: Organization;
  17. project: Project;
  18. };
  19. export default function ProjectSecurityAndPrivacy({organization, project}: Props) {
  20. function handleUpdateProject(data: Project) {
  21. // This will update our project global state
  22. ProjectsStore.onUpdateSuccess(data);
  23. }
  24. const initialData = project;
  25. const projectSlug = project.slug;
  26. const endpoint = `/projects/${organization.slug}/${projectSlug}/`;
  27. const features = new Set(organization.features);
  28. const relayPiiConfig = project.relayPiiConfig;
  29. const apiMethod = 'PUT';
  30. const title = t('Security & Privacy');
  31. const hasAccess = hasEveryAccess(['project:write'], {organization, project});
  32. return (
  33. <Fragment>
  34. <SentryDocumentTitle title={title} projectSlug={projectSlug} />
  35. <SettingsPageHeader title={title} />
  36. <PermissionAlert project={project} />
  37. <Form
  38. saveOnBlur
  39. allowUndo
  40. initialData={initialData}
  41. apiMethod={apiMethod}
  42. apiEndpoint={endpoint}
  43. onSubmitSuccess={handleUpdateProject}
  44. onSubmitError={() => addErrorMessage('Unable to save change')}
  45. >
  46. <JsonForm
  47. additionalFieldProps={{organization}}
  48. features={features}
  49. disabled={!hasAccess}
  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={!hasAccess}
  71. organization={organization}
  72. project={project}
  73. onSubmitSuccess={data => handleUpdateProject({...project, ...data})}
  74. />
  75. </Fragment>
  76. );
  77. }