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 { LinkData, getLinkData } from '../../activityMessagesUtils'
import ActivityDocLink from '../ActivityDocLink.svelte' import ActivityDocLink from '../ActivityDocLink.svelte'
import { getIsTextType } from '../../utils'
export let message: DisplayDocUpdateMessage export let message: DisplayDocUpdateMessage
export let viewlet: DocUpdateMessageViewlet | undefined export let viewlet: DocUpdateMessageViewlet | undefined
export let person: Person | undefined export let person: Person | undefined
export let objectName: IntlString | undefined = undefined
export let object: Doc | undefined export let object: Doc | undefined
export let parentObject: Doc | undefined export let parentObject: Doc | undefined
export let attributeModel: AttributeModel | undefined = undefined export let attributeModel: AttributeModel | undefined = undefined
export let collectionName: IntlString | undefined = undefined
export let hideLink = false export let hideLink = false
const isOwn = message.objectId === message.attachedTo const isOwn = message.objectId === message.attachedTo
@ -42,7 +41,13 @@
linkData = data linkData = data
}) })
function getTitle (): IntlString { function getTitle (attributeModel: AttributeModel): IntlString | undefined {
const isTextType = getIsTextType(attributeModel)
if (!isTextType) {
return undefined
}
const { attributeUpdates } = message const { attributeUpdates } = message
const added = attributeUpdates?.added ?? [] const added = attributeUpdates?.added ?? []
const removed = attributeUpdates?.removed ?? [] const removed = attributeUpdates?.removed ?? []
@ -60,36 +65,13 @@
{#if viewlet?.label} {#if viewlet?.label}
<span class="text-sm lower"> <Label label={viewlet.label} /></span> <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} {:else if attributeModel}
<span class="text-sm lower"><Label label={getTitle()} /></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> <span class="text-sm lower"> <Label label={attributeModel.label} /></span>
{/if} {/if}
{/if}
{#if linkData} {#if linkData}
<ActivityDocLink <ActivityDocLink

View File

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

View File

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

View File

@ -519,3 +519,10 @@ export async function unpinMessage (message?: ActivityMessage): Promise<void> {
await client.update(message, { isPinned: false }) 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 inputSocialValue = (): Locator => this.page.locator('div.popup input.search')
readonly buttonSocialCancel = (): Locator => this.page.locator('div.popup button[type="button"]:not([id])') readonly buttonSocialCancel = (): Locator => this.page.locator('div.popup button[type="button"]:not([id])')
readonly buttonSocialSave = (): Locator => this.page.locator('button#channel-ok') 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 => readonly buttonContactLinkedIn = (): Locator =>
this.page.locator('div[class^="popupPanel-body"] div.horizontal button[id="contact:string:LinkedIn"]') 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]') buttonEstimation = (): Locator => this.page.locator('(//span[text()="Estimation"]/../div/button)[3]')
buttonDueDate = (): Locator => this.page.locator('(//span[text()="Due date"]/../div/button)[2]') buttonDueDate = (): Locator => this.page.locator('(//span[text()="Due date"]/../div/button)[2]')
buttonSaveDueDate = (): Locator => this.page.locator('div.footer > button') 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' }) buttonDelete = (): Locator => this.page.locator('button[class*="menuItem"] > span', { hasText: 'Delete' })
async checkTemplate (data: NewIssue): Promise<void> { async checkTemplate (data: NewIssue): Promise<void> {
@ -75,8 +75,8 @@ export class TemplateDetailsPage extends CommonTrackerPage {
} }
} }
async checkCommentExist (comment: string): Promise<void> { async checkActivityContent (comment: string): Promise<void> {
await expect(this.textComment().filter({ hasText: comment })).toBeVisible() await expect(this.activityContent().filter({ hasText: comment })).toBeVisible()
} }
async deleteTemplate (): Promise<void> { async deleteTemplate (): Promise<void> {

View File

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

View File

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

View File

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

View File

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