index.tsx 2.9 KB

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