index.tsx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 access = new Set(organization.access);
  26. const features = new Set(organization.features);
  27. const relayPiiConfig = project.relayPiiConfig;
  28. const apiMethod = 'PUT';
  29. const title = t('Security & Privacy');
  30. return (
  31. <Fragment>
  32. <SentryDocumentTitle title={title} projectSlug={projectSlug} />
  33. <SettingsPageHeader title={title} />
  34. <Form
  35. saveOnBlur
  36. allowUndo
  37. initialData={initialData}
  38. apiMethod={apiMethod}
  39. apiEndpoint={endpoint}
  40. onSubmitSuccess={handleUpdateProject}
  41. onSubmitError={() => addErrorMessage('Unable to save change')}
  42. >
  43. <JsonForm
  44. additionalFieldProps={{organization}}
  45. features={features}
  46. disabled={!access.has('project:write')}
  47. forms={projectSecurityAndPrivacyGroups}
  48. />
  49. </Form>
  50. <DataScrubbing
  51. additionalContext={
  52. <span>
  53. {tct(
  54. 'These rules can be configured at the organization level in [linkToOrganizationSecurityAndPrivacy].',
  55. {
  56. linkToOrganizationSecurityAndPrivacy: (
  57. <Link to={`/settings/${organization.slug}/security-and-privacy/`}>
  58. {title}
  59. </Link>
  60. ),
  61. }
  62. )}
  63. </span>
  64. }
  65. endpoint={endpoint}
  66. relayPiiConfig={relayPiiConfig}
  67. disabled={!access.has('project:write')}
  68. organization={organization}
  69. project={project}
  70. onSubmitSuccess={data => handleUpdateProject({...project, ...data})}
  71. />
  72. </Fragment>
  73. );
  74. }