index.tsx 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import {Fragment} from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import {addErrorMessage} from 'sentry/actionCreators/indicator';
  4. import {updateOrganization} from 'sentry/actionCreators/organizations';
  5. import Form from 'sentry/components/forms/form';
  6. import JsonForm from 'sentry/components/forms/jsonForm';
  7. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  8. import organizationSecurityAndPrivacyGroups from 'sentry/data/forms/organizationSecurityAndPrivacyGroups';
  9. import {t} from 'sentry/locale';
  10. import {Organization} from 'sentry/types';
  11. import withOrganization from 'sentry/utils/withOrganization';
  12. import AsyncView from 'sentry/views/asyncView';
  13. import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
  14. import DataScrubbing from '../components/dataScrubbing';
  15. type Props = RouteComponentProps<{orgId: string; projectId: string}, {}> & {
  16. organization: Organization;
  17. };
  18. class OrganizationSecurityAndPrivacyContent extends AsyncView<Props> {
  19. getEndpoints(): ReturnType<AsyncView['getEndpoints']> {
  20. const {orgId} = this.props.params;
  21. return [['authProvider', `/organizations/${orgId}/auth-provider/`]];
  22. }
  23. handleUpdateOrganization = (data: Organization) => {
  24. // This will update OrganizationStore (as well as OrganizationsStore
  25. // which is slightly incorrect because it has summaries vs a detailed org)
  26. updateOrganization(data);
  27. };
  28. renderBody() {
  29. const {organization} = this.props;
  30. const {orgId} = this.props.params;
  31. const initialData = organization;
  32. const endpoint = `/organizations/${orgId}/`;
  33. const access = new Set(organization.access);
  34. const features = new Set(organization.features);
  35. const relayPiiConfig = organization.relayPiiConfig;
  36. const {authProvider} = this.state;
  37. const title = t('Security & Privacy');
  38. return (
  39. <Fragment>
  40. <SentryDocumentTitle title={title} orgSlug={organization.slug} />
  41. <SettingsPageHeader title={title} />
  42. <Form
  43. data-test-id="organization-settings-security-and-privacy"
  44. apiMethod="PUT"
  45. apiEndpoint={endpoint}
  46. initialData={initialData}
  47. additionalFieldProps={{hasSsoEnabled: !!authProvider}}
  48. onSubmitSuccess={this.handleUpdateOrganization}
  49. onSubmitError={() => addErrorMessage(t('Unable to save change'))}
  50. saveOnBlur
  51. allowUndo
  52. >
  53. <JsonForm
  54. features={features}
  55. forms={organizationSecurityAndPrivacyGroups}
  56. disabled={!access.has('org:write')}
  57. />
  58. </Form>
  59. <DataScrubbing
  60. additionalContext={t('These rules can be configured for each project.')}
  61. endpoint={endpoint}
  62. relayPiiConfig={relayPiiConfig}
  63. disabled={!access.has('org:write')}
  64. organization={organization}
  65. onSubmitSuccess={this.handleUpdateOrganization}
  66. />
  67. </Fragment>
  68. );
  69. }
  70. }
  71. export default withOrganization(OrganizationSecurityAndPrivacyContent);