Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪟 🐛 Hide anonymize data field on preference page #21733

Merged
merged 2 commits into from
Jan 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import LabeledInput from "components/LabeledInput";
import { LabeledSwitch } from "components/LabeledSwitch";
import { Button } from "components/ui/Button";

import { useConfig } from "config";
import { links } from "utils/links";

import EditControls from "./components/EditControls";
Expand Down Expand Up @@ -70,12 +71,13 @@ const PreferencesForm: React.FC<PreferencesFormProps> = ({
errorMessage,
}) => {
const { formatMessage } = useIntl();
const config = useConfig();

return (
<Formik
initialValues={{
email: preferencesValues?.email || "",
anonymousDataCollection: preferencesValues?.anonymousDataCollection || false,
anonymousDataCollection: preferencesValues?.anonymousDataCollection || !config.segment.enabled,
news: preferencesValues?.news || false,
securityUpdates: preferencesValues?.securityUpdates || false,
}}
Expand Down Expand Up @@ -116,32 +118,36 @@ const PreferencesForm: React.FC<PreferencesFormProps> = ({
)}
</Field>
</FormItem>
<Subtitle>
<FormattedMessage id="preferences.anonymizeUsage" />
</Subtitle>
<Text>
<FormattedMessage
id="preferences.collectData"
values={{
docs: (docs: React.ReactNode) => (
<DocsLink target="_blank" href={links.docsLink}>
{docs}
</DocsLink>
),
}}
/>
</Text>
<FormItem>
<Field name="anonymousDataCollection">
{({ field }: FieldProps<string>) => (
<LabeledSwitch
{...field}
disabled={!values.email}
label={<FormattedMessage id="preferences.anonymizeData" />}
{config.segment.enabled && (
<>
<Subtitle>
<FormattedMessage id="preferences.anonymizeUsage" />
</Subtitle>
<Text>
<FormattedMessage
id="preferences.collectData"
values={{
docs: (docs: React.ReactNode) => (
<DocsLink target="_blank" href={links.docsLink}>
{docs}
</DocsLink>
),
}}
/>
)}
</Field>
</FormItem>
</Text>
<FormItem>
<Field name="anonymousDataCollection">
{({ field }: FieldProps<string>) => (
<LabeledSwitch
{...field}
disabled={!values.email}
label={<FormattedMessage id="preferences.anonymizeData" />}
/>
)}
</Field>
</FormItem>
</>
)}
<Subtitle>
<FormattedMessage id="preferences.news" />
</Subtitle>
Expand Down