-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathdataConsentForm.tsx
78 lines (72 loc) · 2.41 KB
/
dataConsentForm.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import {addErrorMessage} from 'sentry/actionCreators/indicator';
import {updateOrganization} from 'sentry/actionCreators/organizations';
import Form from 'sentry/components/forms/form';
import JsonForm from 'sentry/components/forms/jsonForm';
import {t} from 'sentry/locale';
import type {Organization} from 'sentry/types/organization';
import useOrganization from 'sentry/utils/useOrganization';
import withSubscription from 'getsentry/components/withSubscription';
import {useGenAiConsentButtonAccess} from 'getsentry/hooks/genAiAccess';
import type {Subscription} from 'getsentry/types';
import trackGetsentryAnalytics from 'getsentry/utils/trackGetsentryAnalytics';
import DataConsentFields from 'getsentry/views/legalAndCompliance/dataConsent';
function DataConsentForm({subscription}: {subscription: Subscription}) {
const organization = useOrganization();
const endpoint = `/organizations/${organization.slug}/data-consent/`;
const {
isDisabled: isGenAiButtonDisabled,
message: genAiButtonMessage,
isUsRegion,
hasBillingAccess,
isSuperuser,
isTouchCustomerAndNeedsMsaUpdate,
} = useGenAiConsentButtonAccess({
subscription,
});
const initialData = {
genAIConsent: organization.genAIConsent,
aggregatedDataConsent: organization.aggregatedDataConsent,
};
return (
<Form
data-test-id="data-consent"
apiMethod="PUT"
apiEndpoint={endpoint}
saveOnBlur
allowUndo
initialData={initialData}
onSubmitError={() => {
addErrorMessage(t('Unable to save change'));
}}
onSubmitSuccess={(updatedOrganization: Partial<Organization>) => {
updateOrganization({id: organization.id, ...updatedOrganization});
}}
onFieldChange={(name, value) => {
if (name === 'genAIConsent') {
trackGetsentryAnalytics('gen_ai_consent.settings_clicked', {
organization,
value,
});
}
trackGetsentryAnalytics('data_consent_settings.updated', {
organization,
setting: name,
value,
});
}}
>
<JsonForm
additionalFieldProps={{
isGenAiButtonDisabled,
genAiButtonMessage,
isUsRegion,
hasBillingAccess,
isSuperuser,
isTouchCustomerAndNeedsMsaUpdate,
}}
forms={DataConsentFields}
/>
</Form>
);
}
export default withSubscription(DataConsentForm);