Skip to content

Commit 575e073

Browse files
committed
feat(notifications): format backticks in title
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent c1b8acf commit 575e073

File tree

4 files changed

+29
-33
lines changed

4 files changed

+29
-33
lines changed

src/renderer/components/notifications/NotificationRow.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ export const NotificationRow: FC<NotificationRowProps> = ({
113113
justify="space-between"
114114
title={notification.display.title}
115115
>
116-
<NotificationTitle
117-
title={notification.subject.title}
118-
wrapTitle={settings.wrapNotificationTitle}
119-
/>
116+
<NotificationTitle title={notification.subject.title} />
120117
<Text
121118
className={cn(
122119
'text-xxs ml-auto mr-2',

src/renderer/components/notifications/NotificationTitle.test.tsx

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,72 @@
11
import { renderWithAppContext } from '../../__helpers__/test-utils';
2+
import { mockSettings } from '../../__mocks__/state-mocks';
23

34
import { NotificationTitle } from './NotificationTitle';
45

56
describe('renderer/components/notifications/NotificationTitle.tsx', () => {
67
it('should render plain text without code blocks', () => {
78
const tree = renderWithAppContext(
8-
<NotificationTitle title="Simple notification title" wrapTitle={false} />,
9+
<NotificationTitle title="Simple notification title" />,
910
);
1011

1112
expect(tree).toMatchSnapshot();
1213
});
1314

1415
it('should render text with single inline code block', () => {
1516
const tree = renderWithAppContext(
16-
<NotificationTitle
17-
title="refactor: migrate deprecated atlaskit `xcss`"
18-
wrapTitle={false}
19-
/>,
17+
<NotificationTitle title="refactor: migrate deprecated atlaskit `xcss`" />,
2018
);
2119

2220
expect(tree).toMatchSnapshot();
2321
});
2422

2523
it('should render text with multiple inline code blocks', () => {
2624
const tree = renderWithAppContext(
27-
<NotificationTitle
28-
title="Replace `foo` with `bar` in config"
29-
wrapTitle={false}
30-
/>,
25+
<NotificationTitle title="Replace `foo` with `bar` in config" />,
3126
);
3227

3328
expect(tree).toMatchSnapshot();
3429
});
3530

3631
it('should render text with code block at the start', () => {
3732
const tree = renderWithAppContext(
38-
<NotificationTitle
39-
title="`useState` hook implementation"
40-
wrapTitle={false}
41-
/>,
33+
<NotificationTitle title="`useState` hook implementation" />,
4234
);
4335

4436
expect(tree).toMatchSnapshot();
4537
});
4638

4739
it('should render text with code block at the end', () => {
4840
const tree = renderWithAppContext(
49-
<NotificationTitle title="Fix issue with `render`" wrapTitle={false} />,
41+
<NotificationTitle title="Fix issue with `render`" />,
5042
);
5143

5244
expect(tree).toMatchSnapshot();
5345
});
5446

55-
it('should apply truncate className when wrapTitle is false', () => {
47+
it('should apply truncate className when wrapNotificationTitle is false', () => {
5648
const tree = renderWithAppContext(
57-
<NotificationTitle
58-
title="refactor: migrate deprecated atlaskit `xcss`"
59-
wrapTitle={false}
60-
/>,
49+
<NotificationTitle title="refactor: migrate deprecated atlaskit `xcss`" />,
50+
{
51+
settings: {
52+
...mockSettings,
53+
wrapNotificationTitle: false,
54+
},
55+
},
6156
);
6257

6358
expect(tree).toMatchSnapshot();
6459
});
6560

66-
it('should not apply truncate className when wrapTitle is true', () => {
61+
it('should not apply truncate className when wrapNotificationTitle is true', () => {
6762
const tree = renderWithAppContext(
68-
<NotificationTitle
69-
title="refactor: migrate deprecated atlaskit `xcss`"
70-
wrapTitle={true}
71-
/>,
63+
<NotificationTitle title="refactor: migrate deprecated atlaskit `xcss`" />,
64+
{
65+
settings: {
66+
...mockSettings,
67+
wrapNotificationTitle: true,
68+
},
69+
},
7270
);
7371

7472
expect(tree).toMatchSnapshot();

src/renderer/components/notifications/NotificationTitle.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@ import type { FC } from 'react';
22

33
import { Text } from '@primer/react';
44

5+
import { useAppContext } from '../../hooks/useAppContext';
6+
57
import { cn } from '../../utils/cn';
68
import { parseInlineCode } from '../../utils/helpers';
79

810
interface NotificationTitleProps {
911
title: string;
10-
wrapTitle: boolean;
1112
}
1213

1314
export const NotificationTitle: FC<NotificationTitleProps> = ({
1415
title,
15-
wrapTitle,
1616
}: NotificationTitleProps) => {
17+
const { settings } = useAppContext();
1718
const parts = parseInlineCode(title);
1819

1920
return (
20-
<Text className={!wrapTitle && 'truncate'}>
21+
<Text className={!settings.wrapNotificationTitle && 'truncate'}>
2122
{parts.map((part) => (
2223
<Text
2324
className={cn(

src/renderer/components/notifications/__snapshots__/NotificationTitle.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)