Skip to content

Commit

Permalink
Support customized privacy policy and terms of use URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Aug 22, 2024
1 parent 0426efa commit 0f63971
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 32 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ Note: there is a test account you can use. Get this from another developer if yo
- `HS_HOME_SUGGESTIONS` - Comma-separated IDs of the HelpScout articles to suggest on the dashboard page
- `HS_REPORTS_SUGGESTIONS` - Comma-separated IDs of the HelpScout articles to suggest on the reports pages
- `HS_TASKS_SUGGESTIONS` - Comma-separated IDs of the HelpScout articles to suggest on the tasks page
- `PRIVACY_POLICY_URL` - URL of the privacy policy
- `TERMS_OF_USE_URL` - URL of the terms of use

#### Auth provider

Expand Down
2 changes: 2 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ const config = {
process.env.HS_SETTINGS_SERVICES_SUGGESTIONS,
HS_SETUP_FIND_ORGANIZATION: process.env.HS_SETUP_FIND_ORGANIZATION,
ALERT_MESSAGE: process.env.ALERT_MESSAGE,
PRIVACY_POLICY_URL: process.env.PRIVACY_POLICY_URL,
TERMS_OF_USE_URL: process.env.TERMS_OF_USE_URL,
DD_ENV: process.env.DD_ENV ?? 'development',
},
experimental: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import React, { useState } from 'react';
import { useApolloClient } from '@apollo/client';
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
import ChevronRight from '@mui/icons-material/ChevronRight';
import { Box, Button, Drawer, List, Link as MuiLink } from '@mui/material';
import { Box, Button, Drawer, List } from '@mui/material';
import { styled } from '@mui/material/styles';
import { signOut } from 'next-auth/react';
import { useTranslation } from 'react-i18next';
import { PrivacyPolicyLink, TermsOfUseLink } from 'src/components/Links/Links';
import { NextLinkComposed } from 'src/components/common/Links/NextLinkComposed';
import { clearDataDogUser } from 'src/lib/dataDog';
import { useAccountListId } from '../../../../../../hooks/useAccountListId';
Expand Down Expand Up @@ -222,23 +223,9 @@ export const ProfileMenuPanel: React.FC = () => {
{t('Sign Out')}
</Button>
<Box display="flex" justifyContent="center" py={1}>
<MuiLink
href="https://get.mpdx.org/privacy-policy/"
target="_blank"
color="secondary"
variant="caption"
>
{t('Privacy Policy')}
</MuiLink>
<PrivacyPolicyLink color="secondary" variant="caption" />
&nbsp; • &nbsp;
<MuiLink
href="https://get.mpdx.org/terms-of-use/"
target="_blank"
color="secondary"
variant="caption"
>
{t('Terms of Use')}
</MuiLink>
<TermsOfUseLink color="secondary" variant="caption" />
</Box>
</Box>
</LeafListItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import {
ListItemText,
Menu,
MenuItem,
Link as MuiLink,
Typography,
} from '@mui/material';
import { styled } from '@mui/material/styles';
import { signOut } from 'next-auth/react';
import { useSnackbar } from 'notistack';
import { useTranslation } from 'react-i18next';
import { PrivacyPolicyLink, TermsOfUseLink } from 'src/components/Links/Links';
import { AccountList } from 'src/graphql/types.generated';
import { useRequiredSession } from 'src/hooks/useRequiredSession';
import { clearDataDogUser } from 'src/lib/dataDog';
Expand Down Expand Up @@ -374,21 +374,9 @@ const ProfileMenu = (): ReactElement => {
)}
</MenuItem>
<MenuItemFooter>
<MuiLink
href="https://get.mpdx.org/privacy-policy/"
target="_blank"
onClick={handleProfileMenuClose}
>
{t('Privacy Policy')}
</MuiLink>
<PrivacyPolicyLink />
&nbsp; • &nbsp;
<MuiLink
href="https://get.mpdx.org/terms-of-use/"
target="_blank"
onClick={handleProfileMenuClose}
>
{t('Terms of Use')}
</MuiLink>
<TermsOfUseLink />
</MenuItemFooter>
</MenuWrapper>
</>
Expand Down
20 changes: 20 additions & 0 deletions src/components/Links/Links.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { render } from '@testing-library/react';
import { PrivacyPolicyLink, TermsOfUseLink } from './Links';

describe('PrivacyPolicyLink', () => {
it('uses the link from an environment variable', () => {
process.env.PRIVACY_POLICY_URL = 'privacy-policy.com';

const { getByRole } = render(<PrivacyPolicyLink />);
expect(getByRole('link')).toHaveAttribute('href', 'privacy-policy.com');
});
});

describe('TermsOfUseLink', () => {
it('uses the link from an environment variable', () => {
process.env.TERMS_OF_USE_URL = 'terms-of-use.com';

const { getByRole } = render(<TermsOfUseLink />);
expect(getByRole('link')).toHaveAttribute('href', 'terms-of-use.com');
});
});
22 changes: 22 additions & 0 deletions src/components/Links/Links.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Link, LinkProps } from '@mui/material';
import { useTranslation } from 'react-i18next';

export const PrivacyPolicyLink: React.FC<LinkProps> = (props) => {
const { t } = useTranslation();

return (
<Link href={process.env.PRIVACY_POLICY_URL} target="_blank" {...props}>
{t('Privacy Policy')}
</Link>
);
};

export const TermsOfUseLink: React.FC<LinkProps> = (props) => {
const { t } = useTranslation();

return (
<Link href={process.env.TERMS_OF_USE_URL} target="_blank" {...props}>
{t('Terms of Use')}
</Link>
);
};

0 comments on commit 0f63971

Please sign in to comment.