Skip to content

Commit 1e59146

Browse files
committed
Use NotificationSubtitle component in NotificationArea
1 parent 5a980d4 commit 1e59146

File tree

2 files changed

+5
-52
lines changed

2 files changed

+5
-52
lines changed

desktop/packages/mullvad-vpn/src/renderer/components/NotificationArea.tsx

+5-40
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useCallback, useState } from 'react';
2-
import styled from 'styled-components';
32

43
import { messages } from '../../shared/gettext';
54
import log from '../../shared/logging';
@@ -17,9 +16,7 @@ import {
1716
} from '../../shared/notifications';
1817
import { useAppContext } from '../context';
1918
import useActions from '../lib/actionsHook';
20-
import { Icon } from '../lib/components';
2119
import { transitions, useHistory } from '../lib/history';
22-
import { formatHtml } from '../lib/html-formatter';
2320
import {
2421
NewDeviceNotificationProvider,
2522
NewVersionNotificationProvider,
@@ -31,8 +28,6 @@ import { RoutePath } from '../lib/routes';
3128
import accountActions from '../redux/account/actions';
3229
import { IReduxState, useSelector } from '../redux/store';
3330
import * as AppButton from './AppButton';
34-
import { ExternalLink } from './ExternalLink';
35-
import { InternalLink } from './InternalLink';
3631
import { ModalAlert, ModalAlertType, ModalMessage, ModalMessageList } from './Modal';
3732
import {
3833
NotificationActions,
@@ -41,20 +36,15 @@ import {
4136
NotificationContent,
4237
NotificationIndicator,
4338
NotificationOpenLinkAction,
44-
NotificationSubtitle,
4539
NotificationTitle,
4640
NotificationTroubleshootDialogAction,
4741
} from './NotificationBanner';
42+
import { NotificationSubtitle } from './NotificationSubtitle';
4843

4944
interface IProps {
5045
className?: string;
5146
}
5247

53-
const StyledIcon = styled(Icon)`
54-
display: inline-flex;
55-
vertical-align: middle;
56-
`;
57-
5848
export default function NotificationArea(props: IProps) {
5949
const { showFullDiskAccessSettings } = useAppContext();
6050

@@ -159,35 +149,10 @@ export default function NotificationArea(props: IProps) {
159149
<NotificationTitle data-testid="notificationTitle">
160150
{notification.title}
161151
</NotificationTitle>
162-
<NotificationSubtitle data-testid="notificationSubTitle">
163-
{Array.isArray(notification.subtitle)
164-
? notification.subtitle.map((subtitle, index, arr) => {
165-
const content = subtitle.action ? (
166-
subtitle.action.type === 'navigate-internal' ? (
167-
<InternalLink variant="labelTiny" {...subtitle.action.link}>
168-
{formatHtml(subtitle.content)}
169-
</InternalLink>
170-
) : subtitle.action.type === 'navigate-external' ? (
171-
<ExternalLink variant="labelTiny" {...subtitle.action.link}>
172-
{formatHtml(subtitle.content)}
173-
<StyledIcon icon="external" size="small" />
174-
</ExternalLink>
175-
) : (
176-
formatHtml(subtitle.content)
177-
)
178-
) : (
179-
formatHtml(subtitle.content)
180-
);
181-
182-
return (
183-
<>
184-
{content}
185-
{index !== arr.length - 1 && ' '}
186-
</>
187-
);
188-
})
189-
: formatHtml(notification.subtitle ?? '')}
190-
</NotificationSubtitle>
152+
<NotificationSubtitle
153+
data-testid="notificationSubTitle"
154+
subtitle={notification.subtitle}
155+
/>
191156
</NotificationContent>
192157
{notification.action && (
193158
<NotificationActionWrapper

desktop/packages/mullvad-vpn/src/renderer/components/NotificationBanner.tsx

-12
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@ export const NotificationTitle = styled.span(tinyText, {
1515
color: Colors.white,
1616
});
1717

18-
export const NotificationSubtitleText = styled.span(tinyText, {
19-
color: Colors.white60,
20-
});
21-
22-
interface INotificationSubtitleProps {
23-
children?: React.ReactNode;
24-
}
25-
26-
export function NotificationSubtitle(props: INotificationSubtitleProps) {
27-
return React.Children.count(props.children) > 0 ? <NotificationSubtitleText {...props} /> : null;
28-
}
29-
3018
export const NotificationActionButton = styled(AppButton.SimpleButton)({
3119
flex: 1,
3220
justifyContent: 'center',

0 commit comments

Comments
 (0)