-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): refactor analytics settings modal
closes RAUT-946
- Loading branch information
Showing
4 changed files
with
82 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
app/src/organisms/AnalyticsSettingsModal/AnalyticsToggle.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,93 @@ | ||
import * as React from 'react' | ||
import { useSelector, useDispatch } from 'react-redux' | ||
|
||
import { Trans, useTranslation } from 'react-i18next' | ||
import { | ||
ALIGN_CENTER, | ||
Flex, | ||
Icon, | ||
Link, | ||
SPACING, | ||
COLORS, | ||
TYPOGRAPHY, | ||
DIRECTION_ROW, | ||
DIRECTION_COLUMN, | ||
PrimaryButton, | ||
JUSTIFY_FLEX_END, | ||
} from '@opentrons/components' | ||
import { | ||
getAnalyticsOptInSeen, | ||
toggleAnalyticsOptedIn, | ||
setAnalyticsOptInSeen, | ||
} from '../../redux/analytics' | ||
|
||
import { Modal, OutlineButton, SPACING } from '@opentrons/components' | ||
import { AnalyticsToggle } from './AnalyticsToggle' | ||
import { LegacyModal } from '../../molecules/LegacyModal' | ||
import { StyledText } from '../../atoms/text' | ||
import { Portal } from '../../App/portal' | ||
import type { Dispatch } from '../../redux/types' | ||
|
||
// TODO(bc, 2021-02-04): i18n | ||
const TITLE = 'Privacy Settings' | ||
const CONTINUE = 'continue' | ||
const PRIVACY_POLICY_LINK = 'https://opentrons.com/privacy-policy' | ||
|
||
// TODO(mc, 2020-05-07): move render logic to `state.alerts` | ||
export function AnalyticsSettingsModal(): JSX.Element | null { | ||
const { t } = useTranslation('shared') | ||
const dispatch = useDispatch<Dispatch>() | ||
const seen = useSelector(getAnalyticsOptInSeen) | ||
const setSeen = (): unknown => dispatch(setAnalyticsOptInSeen()) | ||
|
||
const handleClick = (): void => { | ||
dispatch(setAnalyticsOptInSeen()) | ||
dispatch(toggleAnalyticsOptedIn()) | ||
} | ||
|
||
return !seen ? ( | ||
<Portal> | ||
<Modal onCloseClick={setSeen} heading={TITLE} alertOverlay> | ||
<AnalyticsToggle /> | ||
<OutlineButton | ||
onClick={setSeen} | ||
float="right" | ||
margin={SPACING.spacing12} | ||
> | ||
{CONTINUE} | ||
</OutlineButton> | ||
</Modal> | ||
<LegacyModal | ||
title={ | ||
<StyledText css={TYPOGRAPHY.h3SemiBold}> | ||
{t('acknowledge_privacy')} | ||
</StyledText> | ||
} | ||
footer={ | ||
<Flex | ||
justifyContent={JUSTIFY_FLEX_END} | ||
paddingRight={SPACING.spacing16} | ||
paddingBottom={SPACING.spacing16} | ||
> | ||
<PrimaryButton onClick={handleClick}> | ||
<StyledText as="p">{t('agree')}</StyledText> | ||
</PrimaryButton> | ||
</Flex> | ||
} | ||
> | ||
<Flex flexDirection={DIRECTION_COLUMN}> | ||
<Flex gridGap={SPACING.spacing10} flexDirection={DIRECTION_COLUMN}> | ||
<Flex gridGap={SPACING.spacing10} flexDirection={DIRECTION_COLUMN}> | ||
<Trans | ||
t={t} | ||
i18nKey={t('privacy_body')} | ||
components={{ block: <StyledText as="p" /> }} | ||
/> | ||
</Flex> | ||
<Link | ||
external | ||
fontSize={TYPOGRAPHY.fontSizeP} | ||
css={TYPOGRAPHY.darkLinkLabelSemiBold} | ||
href={PRIVACY_POLICY_LINK} | ||
> | ||
<Flex | ||
flexDirection={DIRECTION_ROW} | ||
alignItems={ALIGN_CENTER} | ||
color={COLORS.blue50} | ||
> | ||
{t('opentrons_privacy_policy')} | ||
<Icon | ||
marginLeft={SPACING.spacing4} | ||
name="external-link" | ||
size="0.75rem" | ||
/> | ||
</Flex> | ||
</Link> | ||
</Flex> | ||
</Flex> | ||
</LegacyModal> | ||
</Portal> | ||
) : null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters