Skip to content

Commit

Permalink
feat(app): refactor analytics settings modal
Browse files Browse the repository at this point in the history
closes RAUT-946
  • Loading branch information
jerader committed Feb 5, 2024
1 parent 974ca5d commit 901e82d
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 75 deletions.
4 changes: 4 additions & 0 deletions app/src/assets/localization/en/shared.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"a_software_update_is_available": "A software update is available for this robot. Update to run protocols.",
"acknowledge_privacy": "Acknowledge Privacy Policy",
"add": "add",
"alphabetical": "Alphabetical",
"agree": "I agree",
"back": "Back",
"before_you_begin": "Before you begin",
"browse": "browse",
Expand Down Expand Up @@ -47,6 +49,8 @@
"ok": "ok",
"on": "On",
"open": "open",
"opentrons_privacy_policy": "Opentrons privacy policy",
"privacy_body": "<block>By proceeding you are agreeing to share desktop app usage data. Opentrons uses this data to improve our products and services.</block> <block>To read more about our data collection policies, visit our Privacy Policy:</block>",
"proceed_to_setup": "Proceed to setup",
"protocol_run_general_error_msg": "Protocol run could not be created on the robot.",
"reanalyze": "Reanalyze",
Expand Down
57 changes: 0 additions & 57 deletions app/src/organisms/AnalyticsSettingsModal/AnalyticsToggle.tsx

This file was deleted.

91 changes: 73 additions & 18 deletions app/src/organisms/AnalyticsSettingsModal/index.tsx
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')

Check warning on line 31 in app/src/organisms/AnalyticsSettingsModal/index.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/organisms/AnalyticsSettingsModal/index.tsx#L31

Added line #L31 was not covered by tests
const dispatch = useDispatch<Dispatch>()
const seen = useSelector(getAnalyticsOptInSeen)
const setSeen = (): unknown => dispatch(setAnalyticsOptInSeen())

const handleClick = (): void => {
dispatch(setAnalyticsOptInSeen())
dispatch(toggleAnalyticsOptedIn())

Check warning on line 37 in app/src/organisms/AnalyticsSettingsModal/index.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/organisms/AnalyticsSettingsModal/index.tsx#L35-L37

Added lines #L35 - L37 were not covered by tests
}

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
}
5 changes: 5 additions & 0 deletions components/src/icons/icon-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ export const ICON_DATA_BY_NAME = {
'M31.45 27.55L29.25 25.35C30.1167 22.9833 29.6667 21.0167 27.9 19.45C26.1333 17.8833 24.2167 17.4833 22.15 18.25L19.95 16.05C20.5167 15.6833 21.15 15.4167 21.85 15.25C22.55 15.0833 23.2667 15 24 15C26.3667 15 28.375 15.825 30.025 17.475C31.675 19.125 32.5 21.1333 32.5 23.5C32.5 24.2333 32.4083 24.9583 32.225 25.675C32.0417 26.3917 31.7833 27.0167 31.45 27.55V27.55ZM37.9 34L35.9 32C37.5333 30.8 38.9583 29.4583 40.175 27.975C41.3917 26.4917 42.2833 25 42.85 23.5C41.1833 19.8 38.6833 16.875 35.35 14.725C32.0167 12.575 28.4 11.5 24.5 11.5C23.1 11.5 21.6667 11.6333 20.2 11.9C18.7333 12.1667 17.5833 12.4833 16.75 12.85L14.45 10.5C15.6167 9.96667 17.1083 9.5 18.925 9.1C20.7417 8.7 22.5167 8.5 24.25 8.5C29.0167 8.5 33.375 9.85833 37.325 12.575C41.275 15.2917 44.1667 18.9333 46 23.5C45.1333 25.6333 44.0167 27.5833 42.65 29.35C41.2833 31.1167 39.7 32.6667 37.9 34ZM40.8 45.3L32.4 37.05C31.2333 37.5167 29.9167 37.875 28.45 38.125C26.9833 38.375 25.5 38.5 24 38.5C19.1333 38.5 14.7167 37.1417 10.75 34.425C6.78333 31.7083 3.86667 28.0667 2 23.5C2.66667 21.7667 3.59167 20.075 4.775 18.425C5.95833 16.775 7.4 15.2 9.1 13.7L2.8 7.4L4.9 5.25L42.75 43.1L40.8 45.3ZM11.15 15.8C9.91667 16.7 8.725 17.8833 7.575 19.35C6.425 20.8167 5.6 22.2 5.1 23.5C6.8 27.2 9.35833 30.125 12.775 32.275C16.1917 34.425 20.0667 35.5 24.4 35.5C25.5 35.5 26.5833 35.4333 27.65 35.3C28.7167 35.1667 29.5167 34.9667 30.05 34.7L26.85 31.5C26.4833 31.6667 26.0333 31.7917 25.5 31.875C24.9667 31.9583 24.4667 32 24 32C21.6667 32 19.6667 31.1833 18 29.55C16.3333 27.9167 15.5 25.9 15.5 23.5C15.5 23 15.5417 22.5 15.625 22C15.7083 21.5 15.8333 21.05 16 20.65L11.15 15.8Z',
viewBox: '0 0 48 49',
},
'external-link': {
path:
'M9.11111 9.11111H2.88889V2.88889H4.66667V2H2.88889C2.39556 2 2 2.4 2 2.88889V9.11111C2 9.6 2.39556 10 2.88889 10H9.11111C9.6 10 10 9.6 10 9.11111V7.33333H9.11111V9.11111ZM6.44444 2V2.88889H8.48444L4.11556 7.25778L4.74222 7.88444L9.11111 3.51556V5.55556H10V2H6.44444Z',
viewBox: '0 0 12 12',
},
'flask-outline': {
path:
'M2.44444444,20.4 C2.44444444,21.0627417 2.99165197,21.6 3.66666667,21.6 L18.3333333,21.6 C19.008348,21.6 19.5555556,21.0627417 19.5555556,20.4 C19.5555556,20.148 19.47,19.908 19.3355556,19.716 L12.2222222,7.62 L12.2222222,2.4 L9.77777778,2.4 L9.77777778,7.62 L2.66444444,19.716 C2.53,19.908 2.44444444,20.148 2.44444444,20.4 Z M3.66666667,24 C1.64162258,24 0,22.3882251 0,20.4 C0,19.68 0.22,19.008 0.611111111,18.444 L7.33333333,6.972 L7.33333333,4.8 C6.65831864,4.8 6.11111111,4.2627417 6.11111111,3.6 L6.11111111,2.4 C6.11111111,1.0745166 7.20552617,0 8.55555556,0 L13.4444444,0 C14.7944738,0 15.8888889,1.0745166 15.8888889,2.4 L15.8888889,3.6 C15.8888889,4.2627417 15.3416814,4.8 14.6666667,4.8 L14.6666667,6.972 L21.3888889,18.444 C21.78,19.008 22,19.68 22,20.4 C22,22.3882251 20.3583774,24 18.3333333,24 L3.66666667,24 Z M12.2222222,16.8 L13.86,15.192 L16.2188889,19.2 L5.78111111,19.2 L9.03222222,13.668 L12.2222222,16.8 Z M11.6111111,12 C11.9486185,12 12.2222222,12.2686292 12.2222222,12.6 C12.2222222,12.9313708 11.9486185,13.2 11.6111111,13.2 C11.2736038,13.2 11,12.9313708 11,12.6 C11,12.2686292 11.2736038,12 11.6111111,12 Z',
Expand Down

0 comments on commit 901e82d

Please sign in to comment.