Skip to content

Commit

Permalink
Hide anaonymize data field on preference page (#21733)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Roes authored Jan 25, 2023
1 parent 8956c2c commit 113b134
Showing 1 changed file with 32 additions and 26 deletions.
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

0 comments on commit 113b134

Please sign in to comment.