Skip to content

Commit 2713100

Browse files
authored
feat: user setting to wrap notification titles (#1779)
Signed-off-by: Adam Setch <[email protected]>
1 parent 4955efc commit 2713100

File tree

9 files changed

+146
-45
lines changed

9 files changed

+146
-45
lines changed

src/renderer/__mocks__/state-mocks.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import {
22
type Account,
3+
type AppearanceSettingsState,
34
type AuthState,
5+
type FilterSettingsState,
46
type GitifyState,
57
type GitifyUser,
68
GroupBy,
79
type Hostname,
810
type Link,
11+
type NotificationSettingsState,
912
OpenPreference,
1013
type SettingsState,
14+
type SystemSettingsState,
1115
Theme,
1216
type Token,
1317
} from '../types';
@@ -80,16 +84,17 @@ export const mockAuth: AuthState = {
8084

8185
export const mockToken = 'token-123-456' as Token;
8286

83-
const mockAppearanceSettings = {
87+
const mockAppearanceSettings: AppearanceSettingsState = {
8488
theme: Theme.SYSTEM,
8589
zoomPercentage: 100,
8690
detailedNotifications: true,
8791
showPills: true,
8892
showNumber: true,
8993
showAccountHeader: false,
94+
wrapNotificationTitle: false,
9095
};
9196

92-
const mockNotificationSettings = {
97+
const mockNotificationSettings: NotificationSettingsState = {
9398
groupBy: GroupBy.REPOSITORY,
9499
fetchAllNotifications: true,
95100
participating: false,
@@ -98,7 +103,7 @@ const mockNotificationSettings = {
98103
delayNotificationState: false,
99104
};
100105

101-
const mockSystemSettings = {
106+
const mockSystemSettings: SystemSettingsState = {
102107
openLinks: OpenPreference.FOREGROUND,
103108
keyboardShortcut: true,
104109
showNotificationsCountInTray: true,
@@ -108,7 +113,7 @@ const mockSystemSettings = {
108113
openAtStartup: false,
109114
};
110115

111-
const mockFilters = {
116+
const mockFilters: FilterSettingsState = {
112117
hideBots: false,
113118
filterReasons: [],
114119
};

src/renderer/components/notifications/NotificationRow.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ export const NotificationRow: FC<INotificationRow> = ({
115115
<Stack
116116
direction="vertical"
117117
gap="none"
118-
className="cursor-pointer truncate w-full"
118+
className={cn(
119+
'cursor-pointer text-sm w-full',
120+
!settings.wrapNotificationTitle && 'truncate',
121+
)}
119122
onClick={() => handleNotification()}
120123
>
121124
<NotificationHeader notification={notification} />
@@ -126,10 +129,13 @@ export const NotificationRow: FC<INotificationRow> = ({
126129
justify="space-between"
127130
gap="condensed"
128131
title={notificationTitle}
129-
className="text-sm mb-0.5 truncate"
132+
className={cn(
133+
'mb-0.5',
134+
!settings.wrapNotificationTitle && 'truncate',
135+
)}
130136
data-testid="notification-row"
131137
>
132-
<Text className="block truncate flex-shrink overflow-ellipsis">
138+
<Text className={!settings.wrapNotificationTitle && 'truncate'}>
133139
{notification.subject.title}
134140
</Text>
135141
<Text

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

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+18-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/components/settings/AppearanceSettings.test.tsx

+25
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,29 @@ describe('renderer/routes/components/settings/AppearanceSettings.tsx', () => {
216216
expect(updateSetting).toHaveBeenCalledTimes(1);
217217
expect(updateSetting).toHaveBeenCalledWith('showAccountHeader', true);
218218
});
219+
220+
it('should toggle wrap notification title checkbox', async () => {
221+
await act(async () => {
222+
render(
223+
<AppContext.Provider
224+
value={{
225+
auth: {
226+
accounts: [mockGitHubAppAccount],
227+
},
228+
settings: mockSettings,
229+
updateSetting,
230+
}}
231+
>
232+
<MemoryRouter>
233+
<AppearanceSettings />
234+
</MemoryRouter>
235+
</AppContext.Provider>,
236+
);
237+
});
238+
239+
fireEvent.click(screen.getByTestId('checkbox-wrapNotificationTitle'));
240+
241+
expect(updateSetting).toHaveBeenCalledTimes(1);
242+
expect(updateSetting).toHaveBeenCalledWith('wrapNotificationTitle', true);
243+
});
219244
});

0 commit comments

Comments
 (0)