Do not display headers that duplicate content (#5468)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2024-04-25 19:59:44 +04:00 committed by GitHub
parent 16a891cd48
commit e9c7f33394
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 31 additions and 61 deletions

View File

@ -22,15 +22,14 @@
import { LinkData, getLinkData } from '../../activityMessagesUtils'
import ActivityDocLink from '../ActivityDocLink.svelte'
import { getIsTextType } from '../../utils'
export let message: DisplayDocUpdateMessage
export let viewlet: DocUpdateMessageViewlet | undefined
export let person: Person | undefined
export let objectName: IntlString | undefined = undefined
export let object: Doc | undefined
export let parentObject: Doc | undefined
export let attributeModel: AttributeModel | undefined = undefined
export let collectionName: IntlString | undefined = undefined
export let hideLink = false
const isOwn = message.objectId === message.attachedTo
@ -42,7 +41,13 @@
linkData = data
})
function getTitle (): IntlString {
function getTitle (attributeModel: AttributeModel): IntlString | undefined {
const isTextType = getIsTextType(attributeModel)
if (!isTextType) {
return undefined
}
const { attributeUpdates } = message
const added = attributeUpdates?.added ?? []
const removed = attributeUpdates?.removed ?? []
@ -60,35 +65,12 @@
{#if viewlet?.label}
<span class="text-sm lower"> <Label label={viewlet.label} /></span>
{:else if message.previousMessages?.some(({ action }) => action !== message.action)}
{@const name = collectionName ?? objectName}
<span class="text-sm lower">
<Label label={activity.string.Updated} />
{#if name}
<Label label={name} />
{/if}
</span>
{:else if message.action === 'create' && objectName}
<span class="text-sm lower">
<Label label={isOwn ? activity.string.Created : activity.string.Added} />
{#if collectionName && (!isOwn || message.previousMessages?.length)}
<Label label={collectionName} />
{:else}
<Label label={objectName} />
{/if}
</span>
{:else if message.action === 'remove' && objectName}
<span class="text-sm lower">
<Label label={activity.string.Removed} />
{#if collectionName && message.previousMessages?.length}
<Label label={collectionName} />
{:else}
<Label label={objectName} />
{/if}
</span>
{:else if attributeModel}
<span class="text-sm lower"><Label label={getTitle()} /></span>
<span class="text-sm lower"> <Label label={attributeModel.label} /></span>
{@const title = getTitle(attributeModel)}
{#if title}
<span class="text-sm lower"><Label label={title} /></span>
<span class="text-sm lower"> <Label label={attributeModel.label} /></span>
{/if}
{/if}
{#if linkData}

View File

@ -173,17 +173,7 @@
{onClick}
>
<svelte:fragment slot="header">
<DocUpdateMessageHeader
message={value}
{object}
{parentObject}
{viewlet}
{person}
{objectName}
{collectionName}
{attributeModel}
{hideLink}
/>
<DocUpdateMessageHeader message={value} {object} {parentObject} {viewlet} {person} {attributeModel} {hideLink} />
</svelte:fragment>
<svelte:fragment slot="content">
{#if viewlet?.component && object}

View File

@ -15,10 +15,10 @@
<script lang="ts">
import ui, { Icon, Label, IconEdit } from '@hcengineering/ui'
import { AttributeModel } from '@hcengineering/view'
import core from '@hcengineering/core'
import activity, { DocAttributeUpdates, DocUpdateMessageViewlet } from '@hcengineering/activity'
import ChangeAttributesTemplate from './ChangeAttributesTemplate.svelte'
import { getIsTextType } from '../../../utils'
export let viewlet: DocUpdateMessageViewlet | undefined
export let attributeModel: AttributeModel
@ -32,13 +32,6 @@
$: isTextType = getIsTextType(attributeModel)
function getIsTextType (attributeModel: AttributeModel): boolean {
return (
attributeModel.attribute?.type?._class === core.class.TypeMarkup ||
attributeModel.attribute?.type?._class === core.class.TypeCollaborativeMarkup
)
}
let isDiffShown = false
function toggleShowMore (): void {

View File

@ -519,3 +519,10 @@ export async function unpinMessage (message?: ActivityMessage): Promise<void> {
await client.update(message, { isPinned: false })
}
export function getIsTextType (attributeModel: AttributeModel): boolean {
return (
attributeModel.attribute?.type?._class === core.class.TypeMarkup ||
attributeModel.attribute?.type?._class === core.class.TypeCollaborativeMarkup
)
}

View File

@ -31,7 +31,7 @@ export class CommonRecruitingPage extends CalendarPage {
readonly inputSocialValue = (): Locator => this.page.locator('div.popup input.search')
readonly buttonSocialCancel = (): Locator => this.page.locator('div.popup button[type="button"]:not([id])')
readonly buttonSocialSave = (): Locator => this.page.locator('button#channel-ok')
readonly textActivity = (): Locator => this.page.locator('div.header')
readonly textActivity = (): Locator => this.page.locator('div.content')
readonly buttonContactLinkedIn = (): Locator =>
this.page.locator('div[class^="popupPanel-body"] div.horizontal button[id="contact:string:LinkedIn"]')

View File

@ -13,7 +13,7 @@ export class TemplateDetailsPage extends CommonTrackerPage {
buttonEstimation = (): Locator => this.page.locator('(//span[text()="Estimation"]/../div/button)[3]')
buttonDueDate = (): Locator => this.page.locator('(//span[text()="Due date"]/../div/button)[2]')
buttonSaveDueDate = (): Locator => this.page.locator('div.footer > button')
textComment = (): Locator => this.page.locator('div.grid div.header')
activityContent = (): Locator => this.page.locator('div.grid div.content')
buttonDelete = (): Locator => this.page.locator('button[class*="menuItem"] > span', { hasText: 'Delete' })
async checkTemplate (data: NewIssue): Promise<void> {
@ -75,8 +75,8 @@ export class TemplateDetailsPage extends CommonTrackerPage {
}
}
async checkCommentExist (comment: string): Promise<void> {
await expect(this.textComment().filter({ hasText: comment })).toBeVisible()
async checkActivityContent (comment: string): Promise<void> {
await expect(this.activityContent().filter({ hasText: comment })).toBeVisible()
}
async deleteTemplate (): Promise<void> {

View File

@ -165,7 +165,7 @@ test.describe('Vacancy tests', () => {
const vacancyDetailsPage = new VacancyDetailsPage(page)
await vacancyDetailsPage.moreActionOn('Archive')
await vacancyDetailsPage.pressYesForPopup(page)
await vacancyDetailsPage.checkActivityExist('changed archived at')
await vacancyDetailsPage.checkActivityExist('Archived set to Yes')
await navigationMenuPage.clickButtonVacancies()
await vacanciesPage.checkVacancyNotExist(

View File

@ -58,7 +58,6 @@ test.describe('Mentions issue tests', () => {
...mentionIssue,
assignee: 'Dirak Kainin'
})
await issuesDetailsPage.checkActivityExist('changed assignee')
await issuesDetailsPage.checkActivityContentExist('Assignee set to Dirak Kainin')
await issuesDetailsPage.checkCollaboratorsCount('2 members')
await issuesDetailsPage.checkCollaborators(['Appleseed John', 'Dirak Kainin'])
@ -81,7 +80,6 @@ test.describe('Mentions issue tests', () => {
await issuesPage.openIssueByName(backlinkIssue.title)
const issuesDetailsPage = new IssuesDetailsPage(page)
await issuesDetailsPage.checkActivityExist('created issue')
await issuesDetailsPage.checkActivityContentExist(`New issue: ${backlinkIssue.title}`)
await issuesDetailsPage.openLinkFromActivitiesByText(backlinkIssue.title)
await issuesDetailsPage.checkIssue(backlinkIssue)

View File

@ -61,9 +61,9 @@ test.describe('Tracker milestone tests', () => {
await milestonesDetailsPage.addComment(commentText)
await milestonesDetailsPage.checkCommentExist(commentText)
await milestonesDetailsPage.checkActivityExist('created milestone')
await milestonesDetailsPage.checkActivityExist('changed target date at')
await milestonesDetailsPage.checkActivityExist('changed status at')
await milestonesDetailsPage.checkActivityContentExist(`New milestone: ${editMilestone.name}`)
await milestonesDetailsPage.checkActivityContentExist(`Status set to ${editMilestone.status}`)
await milestonesDetailsPage.checkActivityExist('changed description at')
})

View File

@ -80,7 +80,7 @@ test.describe('Tracker template tests', () => {
estimation: '1d'
})
await templateDetailsPage.checkCommentExist('Appleseed John created template')
await templateDetailsPage.checkActivityContent(`New template: ${newTemplate.title}`)
const estimations = new Map([
['0', '0h'],