Browse Source

Maintenance: Inconsistency in content (- shown at the beginning of article)

Benjamin Scharf 2 months ago
parent
commit
613a4a55ce

+ 17 - 6
app/frontend/apps/desktop/pages/ticket/components/TicketDetailView/ArticleBubble/ArticleBubbleBody.vue

@@ -41,6 +41,13 @@ const body = computed(() => {
   return props.article.bodyWithUrls
 })
 
+const showAuthorInformation = computed(() => {
+  const author = props.article.author.fullname // `-` => system message
+  return (
+    !props.showMetaInformation && author !== '-' && (author?.length ?? 0) > 0
+  )
+})
+
 const { setupLinksHandlers } = useHtmlLinks('/desktop')
 const { populateInlineImages } = useHtmlInlineImages(
   toRef(props, 'inlineImages'),
@@ -68,23 +75,27 @@ onMounted(() => {
 
 <template>
   <div
-    class="Content -:pt-9 -:p-3 relative transition-[padding]"
+    class="Content -:p-3 relative transition-[padding]"
     :class="[
       bodyClasses,
       {
         'pt-3': showMetaInformation,
+        '-:pt-9': showAuthorInformation,
       },
     ]"
   >
     <div
-      v-if="!showMetaInformation"
+      v-if="showAuthorInformation"
       class="absolute top-3 flex w-full px-3 ltr:left-0 rtl:right-0"
+      role="group"
+      aria-describedby="author-name-and-creation-date"
     >
+      <p id="author-name-and-creation-date" class="sr-only">
+        {{ $t('Author name and article creation date') }}
+      </p>
+
       <CommonLabel class="font-bold" size="small" variant="neutral">
-        {{
-          article.author.fullname ||
-          `${article.author.firstname} ${article.author.lastname}`
-        }}
+        {{ article.author.fullname }}
       </CommonLabel>
 
       <CommonDateTime

+ 31 - 0
app/frontend/apps/desktop/pages/ticket/components/TicketDetailView/ArticleBubble/__tests__/ArticleBubbleBody.spec.ts

@@ -4,6 +4,7 @@ import { renderComponent } from '#tests/support/components/index.ts'
 
 import { createDummyArticle } from '#shared/entities/ticket-article/__tests__/mocks/ticket-articles.ts'
 import { createDummyTicket } from '#shared/entities/ticket-article/__tests__/mocks/ticket.ts'
+import { convertToGraphQLId } from '#shared/graphql/utils.ts'
 
 import { provideTicketInformationMocks } from '#desktop/entities/ticket/__tests__/mocks/provideTicketInformationMocks.ts'
 import ArticleBubbleBody from '#desktop/pages/ticket/components/TicketDetailView/ArticleBubble/ArticleBubbleBody.vue'
@@ -62,4 +63,34 @@ describe('ArticleBubbleBody', () => {
       await wrapper.queryByText(article.author.fullname!),
     ).to.toBeInTheDocument()
   })
+
+  it('does not display system message name on article body', async () => {
+    const article = createDummyArticle({
+      bodyWithUrls: 'test &amp; body',
+      contentType: 'text/plain',
+      internal: true,
+      author: {
+        id: convertToGraphQLId('User', 1), // System message user id
+        fullname: '-',
+        firstname: '-',
+        lastname: '',
+        email: '',
+        active: false,
+        image: null,
+        vip: false,
+        outOfOffice: false,
+        outOfOfficeStartAt: null,
+        outOfOfficeEndAt: null,
+        authorizations: [],
+      },
+    })
+
+    const wrapper = renderBody(article, false)
+
+    expect(
+      wrapper.queryByRole('group', {
+        description: 'Author name and article creation date',
+      }),
+    ).not.toBeInTheDocument()
+  })
 })

+ 6 - 2
i18n/zammad.pot

@@ -1923,6 +1923,10 @@ msgstr ""
 msgid "Author"
 msgstr ""
 
+#: app/frontend/apps/desktop/pages/ticket/components/TicketDetailView/ArticleBubble/ArticleBubbleBody.vue:94
+msgid "Author name and article creation date"
+msgstr ""
+
 #: app/controllers/application_controller/handles_errors.rb:106
 msgid "Authorization failed"
 msgstr ""
@@ -12666,7 +12670,7 @@ msgstr ""
 #: app/assets/javascripts/app/controllers/_ui_element/ticket_duplicate_detection.coffee:71
 #: app/assets/javascripts/app/controllers/article_view/item.coffee:447
 #: app/assets/javascripts/app/controllers/data_privacy.coffee:111
-#: app/frontend/apps/desktop/pages/ticket/components/TicketDetailView/ArticleBubble/ArticleBubbleBody.vue:118
+#: app/frontend/apps/desktop/pages/ticket/components/TicketDetailView/ArticleBubble/ArticleBubbleBody.vue:129
 #: app/frontend/apps/mobile/pages/ticket/components/TicketDetailView/ArticleBubble.vue:280
 msgid "See less"
 msgstr ""
@@ -12677,7 +12681,7 @@ msgstr ""
 #: app/assets/javascripts/app/views/data_privacy/tasks.jst.eco:41
 #: app/assets/javascripts/app/views/generic/ticket_duplicate_detection/warning.jst.eco:21
 #: app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco:134
-#: app/frontend/apps/desktop/pages/ticket/components/TicketDetailView/ArticleBubble/ArticleBubbleBody.vue:118
+#: app/frontend/apps/desktop/pages/ticket/components/TicketDetailView/ArticleBubble/ArticleBubbleBody.vue:129
 #: app/frontend/apps/desktop/pages/ticket/components/TicketDetailView/ArticleMore.vue:17
 #: app/frontend/apps/mobile/pages/ticket/components/TicketDetailView/ArticleBubble.vue:280
 msgid "See more"