From d4af04788b314f5ea8690e8794680ded8bf47582 Mon Sep 17 00:00:00 2001 From: Jimmy Domagala-Tang Date: Tue, 8 Oct 2024 13:34:46 -0400 Subject: [PATCH] Merge pull request #20598 from overleaf/jdt-ae-dropbox-limit-notif Add go to project for 2000 file limit notification GitOrigin-RevId: dfd69773ebd5c2160dfce75f56b8fa1e93792c23 --- .../Notifications/NotificationsBuilder.js | 3 ++- .../ThirdPartyDataStore/TpdsController.js | 2 +- .../notifications/groups/common.tsx | 20 +++++++++++-------- .../components/notifications/notification.tsx | 2 +- .../components/notifications.test.tsx | 8 +++----- .../fixtures/notifications-data.ts | 1 + .../types/project/dashboard/notification.ts | 1 + 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/services/web/app/src/Features/Notifications/NotificationsBuilder.js b/services/web/app/src/Features/Notifications/NotificationsBuilder.js index 58c4f68a1a..a6fedaff13 100644 --- a/services/web/app/src/Features/Notifications/NotificationsBuilder.js +++ b/services/web/app/src/Features/Notifications/NotificationsBuilder.js @@ -198,12 +198,13 @@ function ipMatcherAffiliation(userId) { function tpdsFileLimit(userId) { return { key: `tpdsFileLimit-${userId}`, - create(projectName, callback) { + create(projectName, projectId, callback) { if (callback == null) { callback = function () {} } const messageOpts = { projectName, + projectId, } NotificationsHandler.createNotification( userId, diff --git a/services/web/app/src/Features/ThirdPartyDataStore/TpdsController.js b/services/web/app/src/Features/ThirdPartyDataStore/TpdsController.js index adcef05407..f63b6959bf 100644 --- a/services/web/app/src/Features/ThirdPartyDataStore/TpdsController.js +++ b/services/web/app/src/Features/ThirdPartyDataStore/TpdsController.js @@ -62,7 +62,7 @@ async function mergeUpdate(req, res) { { err, userId, filePath }, 'tpds trying to append to project over file limit' ) - NotificationsBuilder.tpdsFileLimit(userId).create(projectName) + NotificationsBuilder.tpdsFileLimit(userId).create(projectName, projectId) return res.sendStatus(400) } else { throw err diff --git a/services/web/frontend/js/features/project-list/components/notifications/groups/common.tsx b/services/web/frontend/js/features/project-list/components/notifications/groups/common.tsx index 328504fbda..9509b17c14 100644 --- a/services/web/frontend/js/features/project-list/components/notifications/groups/common.tsx +++ b/services/web/frontend/js/features/project-list/components/notifications/groups/common.tsx @@ -201,19 +201,23 @@ function CommonNotification({ notification }: CommonNotificationProps) { id && handleDismiss(id)} + title={`${notification?.messageOpts?.projectName || 'A project'} exceeds the 2000 file limit`} content={ <> - Error: Your project {notification.messageOpts.projectName} has - gone over the 2000 file limit using an integration (e.g. Dropbox - or GitHub)
- Please decrease the size of your project to prevent further - errors. + You can't add more files to the project or sync it with any + integrations until you reduce the number of files. } action={ - - Account Settings - + notification.messageOpts.projectId ? ( + id && handleDismiss(id)} + href={`/project/${notification.messageOpts.projectId}`} + > + Open project + + ) : undefined } /> ) : templateKey === 'notification_dropbox_duplicate_project_names' ? ( diff --git a/services/web/frontend/js/features/project-list/components/notifications/notification.tsx b/services/web/frontend/js/features/project-list/components/notifications/notification.tsx index a90eef989f..b8c399d2f2 100644 --- a/services/web/frontend/js/features/project-list/components/notifications/notification.tsx +++ b/services/web/frontend/js/features/project-list/components/notifications/notification.tsx @@ -3,7 +3,7 @@ import NewNotification from '@/shared/components/notification' type NotificationProps = Pick< React.ComponentProps, - 'type' | 'action' | 'content' | 'onDismiss' | 'className' + 'type' | 'action' | 'content' | 'onDismiss' | 'className' | 'title' > function Notification({ className, ...props }: NotificationProps) { diff --git a/services/web/test/frontend/features/project-list/components/notifications.test.tsx b/services/web/test/frontend/features/project-list/components/notifications.test.tsx index c9cbe8e6ab..9965a440ea 100644 --- a/services/web/test/frontend/features/project-list/components/notifications.test.tsx +++ b/services/web/test/frontend/features/project-list/components/notifications.test.tsx @@ -295,14 +295,12 @@ describe('', function () { screen.getByRole('alert') screen.getByText(/file limit/i) - screen.getByText( - /please decrease the size of your project to prevent further errors/i - ) + screen.getByText(/You can't add more files to the project or sync it/i) const accountSettings = screen.getByRole('link', { - name: /account settings/i, + name: /Open project/i, }) - expect(accountSettings.getAttribute('href')).to.equal('/user/settings') + expect(accountSettings.getAttribute('href')).to.equal('/project/123') const closeBtn = screen.getByRole('button', { name: /close/i }) fireEvent.click(closeBtn) diff --git a/services/web/test/frontend/features/project-list/fixtures/notifications-data.ts b/services/web/test/frontend/features/project-list/fixtures/notifications-data.ts index 56bcc9e8e9..2fae97a2bd 100644 --- a/services/web/test/frontend/features/project-list/fixtures/notifications-data.ts +++ b/services/web/test/frontend/features/project-list/fixtures/notifications-data.ts @@ -36,6 +36,7 @@ export const notificationIPMatchedAffiliation = { export const notificationTPDSFileLimit = { messageOpts: { projectName: 'Abc Project', + projectId: '123', }, } as DeepReadonly diff --git a/services/web/types/project/dashboard/notification.ts b/services/web/types/project/dashboard/notification.ts index 70408df57b..ff5f23e459 100644 --- a/services/web/types/project/dashboard/notification.ts +++ b/services/web/types/project/dashboard/notification.ts @@ -42,6 +42,7 @@ export interface NotificationTPDSFileLimit extends NotificationBase { templateKey: Extract messageOpts: { projectName: string + projectId?: string } }