Просмотр исходного кода

Fixes #4010 - Import as / email archive import no longer triggered.

Timo Triebensky 6 месяцев назад
Родитель
Сommit
1cf357c699

+ 5 - 1
app/assets/javascripts/app/controllers/_channel/email.coffee

@@ -680,7 +680,11 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal
       return
 
     @$('.js-archiveMessage').removeClass('hide')
-    message = App.i18n.translateContent('In addition, emails were found in your mailbox that are older than %s weeks. You can import such emails as an "archive", which means that no notifications are sent and the tickets have the status "closed". However, you can find them in Zammad anytime using the search function.', data.archive_week_range)
+
+    if data.archive_possible_is_fallback is true
+      message = App.i18n.translateContent('Since the mail server does not support sorting messages by date, it was not possible to detect if there is any mail older than %s weeks in the connected mailbox. You can import such emails as an "archive", which means that no notifications are sent and the tickets have the status "closed". However, you can find them in Zammad anytime using the search function.', data.archive_week_range)
+    else
+      message = App.i18n.translateContent('In addition, emails were found in your mailbox that are older than %s weeks. You can import such emails as an "archive", which means that no notifications are sent and the tickets have the status "closed". However, you can find them in Zammad anytime using the search function.', data.archive_week_range)
     @$('.js-inbound-acknowledge .js-archiveMessageCount').html(message)
 
     configureAttributesAcknowledge = [

+ 5 - 1
app/assets/javascripts/app/controllers/getting_started/channel_email.coffee

@@ -279,7 +279,11 @@ class GettingStartedChannelEmail extends App.ControllerWizardFullScreen
       return
 
     @$('.js-archiveMessage').removeClass('hide')
-    message = App.i18n.translateContent('In addition, emails were found in your mailbox that are older than %s weeks. You can import such emails as an "archive", which means that no notifications are sent and the tickets have the status "closed". However, you can find them in Zammad anytime using the search function.', data.archive_week_range)
+
+    if data.archive_possible_is_fallback is true
+      message = App.i18n.translateContent('Since the mail server does not support sorting messages by date, it was not possible to detect if there is any mail older than %s weeks in the connected mailbox. You can import such emails as an "archive", which means that no notifications are sent and the tickets have the status "closed". However, you can find them in Zammad anytime using the search function.', data.archive_week_range)
+    else
+      message = App.i18n.translateContent('In addition, emails were found in your mailbox that are older than %s weeks. You can import such emails as an "archive", which means that no notifications are sent and the tickets have the status "closed". However, you can find them in Zammad anytime using the search function.', data.archive_week_range)
     @$('.js-inbound-acknowledge .js-archiveMessageCount').html(message)
 
     configureAttributesAcknowledge = [

+ 1 - 0
app/frontend/apps/desktop/entities/channel-email/composables/useEmailInboundForm.ts

@@ -33,6 +33,7 @@ export const useEmailInboundForm = () => {
     metaInformationInbound.value = {
       contentMessages: data.contentMessages || 0,
       archivePossible: data.archivePossible || false,
+      archivePossibleIsFallback: data.archivePossibleIsFallback || false,
       archiveWeekRange: data.archiveWeekRange || 0,
       nextAction,
     }

+ 5 - 2
app/frontend/apps/desktop/entities/channel-email/composables/useEmailInboundMessagesForm.ts

@@ -39,8 +39,11 @@ export const useEmailInboundMessagesForm = (
             {
               isLayout: true,
               component: 'CommonLabel',
-              children:
-                '$t(\'In addition, emails were found in your mailbox that are older than %s weeks. You can import such emails as an "archive", which means that no notifications are sent and the tickets have the status "closed". However, you can find them in Zammad anytime using the search function.\', $metaInformationInbound.archiveWeekRange)',
+              children: {
+                if: '$metaInformationInbound.archivePossibleIsFallback === true',
+                then: '$t(\'Since the mail server does not support sorting messages by date, it was not possible to detect if there is any mail older than %s weeks in the connected mailbox. You can import such emails as an "archive", which means that no notifications are sent and the tickets have the status "closed". However, you can find them in Zammad anytime using the search function.\', $metaInformationInbound.archiveWeekRange)',
+                else: '$t(\'In addition, emails were found in your mailbox that are older than %s weeks. You can import such emails as an "archive", which means that no notifications are sent and the tickets have the status "closed". However, you can find them in Zammad anytime using the search function.\', $metaInformationInbound.archiveWeekRange)',
+              },
             },
             {
               isLayout: true,

+ 1 - 0
app/frontend/apps/desktop/entities/channel-email/graphql/mutations/channelEmailGuessConfiguration.api.ts

@@ -31,6 +31,7 @@ export const ChannelEmailGuessConfigurationDocument = gql`
       mailboxStats {
         contentMessages
         archivePossible
+        archivePossibleIsFallback
         archiveWeekRange
       }
     }

+ 1 - 0
app/frontend/apps/desktop/entities/channel-email/graphql/mutations/channelEmailGuessConfiguration.graphql

@@ -28,6 +28,7 @@ mutation channelEmailGuessConfiguration(
       mailboxStats {
         contentMessages
         archivePossible
+        archivePossibleIsFallback
         archiveWeekRange
       }
     }

+ 1 - 0
app/frontend/apps/desktop/entities/channel-email/graphql/mutations/channelEmailValidateConfigurationInbound.api.ts

@@ -15,6 +15,7 @@ export const ChannelEmailValidateConfigurationInboundDocument = gql`
     mailboxStats {
       contentMessages
       archivePossible
+      archivePossibleIsFallback
       archiveWeekRange
     }
     errors {

+ 1 - 0
app/frontend/apps/desktop/entities/channel-email/graphql/mutations/channelEmailValidateConfigurationInbound.graphql

@@ -8,6 +8,7 @@ mutation channelEmailValidateConfigurationInbound(
     mailboxStats {
       contentMessages
       archivePossible
+      archivePossibleIsFallback
       archiveWeekRange
     }
     errors {

+ 1 - 0
app/frontend/apps/desktop/entities/channel-email/types/email-inbound-outbound.ts

@@ -52,6 +52,7 @@ export type EmailInboundMetaInformationNextAction = 'roundtrip' | 'outbound'
 export interface EmailInboundMetaInformation {
   contentMessages: number
   archivePossible?: boolean
+  archivePossibleIsFallback?: boolean
   archiveWeekRange?: number
   nextAction: EmailInboundMetaInformationNextAction
   archive?: boolean

+ 83 - 0
app/frontend/apps/desktop/pages/guided-setup/__tests__/guided-setup-manual-channel-email.spec.ts

@@ -406,6 +406,7 @@ describe('guided setup manual channel email', () => {
           mailboxStats: {
             contentMessages: 3,
             archivePossible: true,
+            archivePossibleIsFallback: false,
             archiveWeekRange: 2,
           },
         },
@@ -440,6 +441,88 @@ describe('guided setup manual channel email', () => {
       expect(view.getByRole('button', { name: 'Continue' })).toBeInTheDocument()
     })
 
+    it('can show inbound messages form when some messages are detected but imap sort failed', async () => {
+      const view = await visitView('/guided-setup/manual/channels/email')
+
+      const accountForm = view.getByTestId('channel-email-account')
+
+      await view.events.type(
+        getByLabelText(accountForm, 'Full name'),
+        'Zammad Helpdesk',
+      )
+
+      await view.events.type(
+        getByLabelText(accountForm, 'Email address'),
+        'zammad@mail.test.dc.zammad.com',
+      )
+
+      await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
+
+      mockChannelEmailGuessConfigurationMutation({
+        channelEmailGuessConfiguration: {
+          result: {
+            inboundConfiguration: null,
+            outboundConfiguration: null,
+          },
+        },
+      })
+
+      await view.events.click(
+        view.getByRole('button', {
+          name: 'Connect and Continue',
+        }),
+      )
+
+      const inboundForm = view.getByTestId('channel-email-inbound')
+
+      await view.events.type(
+        getByLabelText(inboundForm, 'Host'),
+        'mail.test.dc.zammad.com',
+      )
+
+      await getNode('channel-email-inbound')?.settled
+
+      mockChannelEmailValidateConfigurationInboundMutation({
+        channelEmailValidateConfigurationInbound: {
+          success: true,
+          mailboxStats: {
+            contentMessages: 3,
+            archivePossible: true,
+            archivePossibleIsFallback: true,
+            archiveWeekRange: 2,
+          },
+        },
+      })
+
+      await view.events.click(
+        view.getByRole('button', {
+          name: 'Continue',
+        }),
+      )
+
+      expect(inboundForm).not.toBeVisible()
+
+      const inboundMessagesForm = view.getByTestId(
+        'channel-email-inbound-messages',
+      )
+
+      expect(inboundMessagesForm).toBeVisible()
+
+      expect(inboundMessagesForm).toHaveTextContent(
+        '3 email(s) were found in your mailbox. They will all be moved from your mailbox into Zammad.',
+      )
+
+      expect(inboundMessagesForm).toHaveTextContent(
+        'Since the mail server does not support sorting messages by date, it was not possible to detect if there is any mail older than 2 weeks in the connected mailbox. You can import such emails as an "archive", which means that no notifications are sent and the tickets have the status "closed". However, you can find them in Zammad anytime using the search function.',
+      )
+
+      expect(
+        getByLabelText(inboundMessagesForm, 'Email import mode'),
+      ).toBeInTheDocument()
+
+      expect(view.getByRole('button', { name: 'Continue' })).toBeInTheDocument()
+    })
+
     it('can show outbound configuration form when guess is unsuccessful', async () => {
       const view = await visitView('/guided-setup/manual/channels/email')
 

Некоторые файлы не были показаны из-за большого количества измененных файлов