소스 검색

Merge pull request #20598 from overleaf/jdt-ae-dropbox-limit-notif

Add go to project for 2000 file limit notification

GitOrigin-RevId: dfd69773ebd5c2160dfce75f56b8fa1e93792c23
Jimmy Domagala-Tang 1 년 전
부모
커밋
c6aec5c5c0

+ 2 - 1
services/web/app/src/Features/Notifications/NotificationsBuilder.js

@@ -198,12 +198,13 @@ function ipMatcherAffiliation(userId) {
 function tpdsFileLimit(userId) {
 function tpdsFileLimit(userId) {
   return {
   return {
     key: `tpdsFileLimit-${userId}`,
     key: `tpdsFileLimit-${userId}`,
-    create(projectName, callback) {
+    create(projectName, projectId, callback) {
       if (callback == null) {
       if (callback == null) {
         callback = function () {}
         callback = function () {}
       }
       }
       const messageOpts = {
       const messageOpts = {
         projectName,
         projectName,
+        projectId,
       }
       }
       NotificationsHandler.createNotification(
       NotificationsHandler.createNotification(
         userId,
         userId,

+ 1 - 1
services/web/app/src/Features/ThirdPartyDataStore/TpdsController.js

@@ -62,7 +62,7 @@ async function mergeUpdate(req, res) {
         { err, userId, filePath },
         { err, userId, filePath },
         'tpds trying to append to project over file limit'
         'tpds trying to append to project over file limit'
       )
       )
-      NotificationsBuilder.tpdsFileLimit(userId).create(projectName)
+      NotificationsBuilder.tpdsFileLimit(userId).create(projectName, projectId)
       return res.sendStatus(400)
       return res.sendStatus(400)
     } else {
     } else {
       throw err
       throw err

+ 12 - 8
services/web/frontend/js/features/project-list/components/notifications/groups/common.tsx

@@ -201,19 +201,23 @@ function CommonNotification({ notification }: CommonNotificationProps) {
         <Notification
         <Notification
           type="error"
           type="error"
           onDismiss={() => id && handleDismiss(id)}
           onDismiss={() => id && handleDismiss(id)}
+          title={`${notification?.messageOpts?.projectName || 'A project'} exceeds the 2000 file limit`}
           content={
           content={
             <>
             <>
-              Error: Your project {notification.messageOpts.projectName} has
-              gone over the 2000 file limit using an integration (e.g. Dropbox
-              or GitHub) <br />
-              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={
           action={
-            <OLButton variant="secondary" href="/user/settings">
-              Account Settings
-            </OLButton>
+            notification.messageOpts.projectId ? (
+              <OLButton
+                variant="secondary"
+                onClick={() => id && handleDismiss(id)}
+                href={`/project/${notification.messageOpts.projectId}`}
+              >
+                Open project
+              </OLButton>
+            ) : undefined
           }
           }
         />
         />
       ) : templateKey === 'notification_dropbox_duplicate_project_names' ? (
       ) : templateKey === 'notification_dropbox_duplicate_project_names' ? (

+ 1 - 1
services/web/frontend/js/features/project-list/components/notifications/notification.tsx

@@ -3,7 +3,7 @@ import NewNotification from '@/shared/components/notification'
 
 
 type NotificationProps = Pick<
 type NotificationProps = Pick<
   React.ComponentProps<typeof NewNotification>,
   React.ComponentProps<typeof NewNotification>,
-  'type' | 'action' | 'content' | 'onDismiss' | 'className'
+  'type' | 'action' | 'content' | 'onDismiss' | 'className' | 'title'
 >
 >
 
 
 function Notification({ className, ...props }: NotificationProps) {
 function Notification({ className, ...props }: NotificationProps) {

+ 3 - 5
services/web/test/frontend/features/project-list/components/notifications.test.tsx

@@ -295,14 +295,12 @@ describe('<UserNotifications />', function () {
 
 
       screen.getByRole('alert')
       screen.getByRole('alert')
       screen.getByText(/file limit/i)
       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', {
       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 })
       const closeBtn = screen.getByRole('button', { name: /close/i })
       fireEvent.click(closeBtn)
       fireEvent.click(closeBtn)
 
 

+ 1 - 0
services/web/test/frontend/features/project-list/fixtures/notifications-data.ts

@@ -36,6 +36,7 @@ export const notificationIPMatchedAffiliation = {
 export const notificationTPDSFileLimit = {
 export const notificationTPDSFileLimit = {
   messageOpts: {
   messageOpts: {
     projectName: 'Abc Project',
     projectName: 'Abc Project',
+    projectId: '123',
   },
   },
 } as DeepReadonly<NotificationTPDSFileLimit>
 } as DeepReadonly<NotificationTPDSFileLimit>
 
 

+ 1 - 0
services/web/types/project/dashboard/notification.ts

@@ -42,6 +42,7 @@ export interface NotificationTPDSFileLimit extends NotificationBase {
   templateKey: Extract<TemplateKey, 'notification_tpds_file_limit'>
   templateKey: Extract<TemplateKey, 'notification_tpds_file_limit'>
   messageOpts: {
   messageOpts: {
     projectName: string
     projectName: string
+    projectId?: string
   }
   }
 }
 }