mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-22 09:35:00 +02:00
qfix: hide large values from activity (#9894)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
"RemovedObjectType": "Odstraněný {type} : {title}",
|
||||
"AttributeSetTo": "{name} nastaveno na {value}",
|
||||
"AddedTag": "Přidaný štítek: {title}",
|
||||
"RemovedTag": "Odebráný štítek: {title}"
|
||||
"RemovedTag": "Odebráný štítek: {title}",
|
||||
"ValueTooLarge": "Hodnota je příliš velká na zobrazení"
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@
|
||||
"RemovedObjectType": "{objectType} entfernt",
|
||||
"AttributeSetTo": "{attribute} auf {value} gesetzt",
|
||||
"AddedTag": "Tag hinzugefügt: {title}",
|
||||
"RemovedTag": "Tag entfernt: {title}"
|
||||
"RemovedTag": "Tag entfernt: {title}",
|
||||
"ValueTooLarge": "Wert zu groß zum Anzeigen"
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@
|
||||
"RemovedObjectType": "Removed {type} : {title}",
|
||||
"AddedTag": "Added tag: {title}",
|
||||
"RemovedTag": "Removed tag: {title}",
|
||||
"AttributeSetTo": "{name} set to {value}"
|
||||
"AttributeSetTo": "{name} set to {value}",
|
||||
"ValueTooLarge": "Value too large to display"
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@
|
||||
"RemovedObjectType": "Eliminado {type} : {title}",
|
||||
"AttributeSetTo": "{name} establecido en {value}",
|
||||
"AddedTag": "Etiqueta añadida: {title}",
|
||||
"RemovedTag": "Etiqueta eliminada: {title}"
|
||||
"RemovedTag": "Etiqueta eliminada: {title}",
|
||||
"ValueTooLarge": "Valor demasiado grande para mostrar"
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@
|
||||
"RemovedObjectType": "Supprimé {type} : {title}",
|
||||
"AttributeSetTo": "{name} défini sur {value}",
|
||||
"AddedTag": "Tag ajouté: {title}",
|
||||
"RemovedTag": "Tag supprimé: {title}"
|
||||
"RemovedTag": "Tag supprimé: {title}",
|
||||
"ValueTooLarge": "Valeur trop grande pour être affichée"
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@
|
||||
"RemovedObjectType": "{type} rimosso: {title}",
|
||||
"AttributeSetTo": "{name} impostato su {value}",
|
||||
"AddedTag": "Tag aggiunto: {title}",
|
||||
"RemovedTag": "Tag rimosso: {title}"
|
||||
"RemovedTag": "Tag rimosso: {title}",
|
||||
"ValueTooLarge": "Valore troppo grande per essere visualizzato"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@
|
||||
"RemovedObjectType": "{type} を削除:{title}",
|
||||
"AttributeSetTo": "{name} を {value} に設定しました",
|
||||
"AddedTag": "タグを追加しました:{title}",
|
||||
"RemovedTag": "タグを削除しました:{title}"
|
||||
"RemovedTag": "タグを削除しました:{title}",
|
||||
"ValueTooLarge": "表示するには値が大きすぎます"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
"RemovedObjectType": "Removido {type} : {title}",
|
||||
"AttributeSetTo": "{name} definido para {value}",
|
||||
"AddedTag": "Tag adicionado: {title}",
|
||||
"RemovedTag": "Tag removido: {title}"
|
||||
"RemovedTag": "Tag removido: {title}",
|
||||
"ValueTooLarge": "Valor demasiado grande para mostrar"
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@
|
||||
"RemovedObjectType": "Удален(ы) {type} : {title}",
|
||||
"AttributeSetTo": "{name} установлен на {value}",
|
||||
"AddedTag": "Добавлен тег: {title}",
|
||||
"RemovedTag": "Удален тег: {title}"
|
||||
"RemovedTag": "Удален тег: {title}",
|
||||
"ValueTooLarge": "Значение слишком велико для отображения"
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@
|
||||
"RemovedObjectType": "移除 {type} : {title}",
|
||||
"AttributeSetTo": "{name} 设置为 {value}",
|
||||
"AddedTag": "添加标签: {title}",
|
||||
"RemovedTag": "移除标签: {title}"
|
||||
"RemovedTag": "移除标签: {title}",
|
||||
"ValueTooLarge": "值过大,无法显示"
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -33,6 +33,8 @@
|
||||
$: isUnset = values.length > 0 && !values.some((value) => value != null && value !== '')
|
||||
|
||||
$: isTextType = getIsTextType(attributeModel)
|
||||
$: isTooLarge =
|
||||
isTextType && (values[0] === activity.string.ValueTooLarge || prevValue === activity.string.ValueTooLarge)
|
||||
|
||||
let isDiffShown = false
|
||||
|
||||
@@ -48,7 +50,11 @@
|
||||
<span class="lower"><Label label={attributeModel.label} /></span>
|
||||
</div>
|
||||
{:else if isTextType}
|
||||
{#if preview}
|
||||
{#if isTooLarge}
|
||||
<div class="unset row overflow-label">
|
||||
<Label label={activity.string.ValueTooLarge} />
|
||||
</div>
|
||||
{:else if preview}
|
||||
<div class="row overflow-label">
|
||||
<span class="mr-1"><Icon icon={attributeIcon} size="small" /></span>
|
||||
<Label label={activity.string.Changed} />
|
||||
|
||||
@@ -324,7 +324,8 @@ export default plugin(activityId, {
|
||||
RemovedObjectType: '' as IntlString,
|
||||
AttributeSetTo: '' as IntlString,
|
||||
AddedTag: '' as IntlString,
|
||||
RemovedTag: '' as IntlString
|
||||
RemovedTag: '' as IntlString,
|
||||
ValueTooLarge: '' as IntlString
|
||||
},
|
||||
component: {
|
||||
Activity: '' as AnyComponent,
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { type ActivityMessageControl, type DocAttributeUpdates, type DocUpdateAction } from '@hcengineering/activity'
|
||||
import activity, {
|
||||
type ActivityMessageControl,
|
||||
type DocAttributeUpdates,
|
||||
type DocUpdateAction
|
||||
} from '@hcengineering/activity'
|
||||
import cardPlugin, { type Card, type Tag } from '@hcengineering/card'
|
||||
import { type ActivityUpdate, ActivityUpdateType } from '@hcengineering/communication-types'
|
||||
import core, {
|
||||
@@ -24,6 +28,21 @@ import { translate } from '@hcengineering/platform'
|
||||
import { type ActivityControl, type DocObjectCache, getAllObjectTransactions } from '@hcengineering/server-activity'
|
||||
import { type TriggerControl } from '@hcengineering/server-core'
|
||||
|
||||
// Use 100 KB limit for attribute updates
|
||||
const valueSizeLimit = 100 * 1024 // 100 KB
|
||||
|
||||
function valueSizeExceedsLimit (value: any): boolean {
|
||||
if (value == null) return false
|
||||
if (Array.isArray(value)) {
|
||||
return value.some((v) => valueSizeExceedsLimit(v))
|
||||
} else if (typeof value === 'string') {
|
||||
return value.length > valueSizeLimit
|
||||
} else if (typeof value === 'object') {
|
||||
return JSON.stringify(value).length > valueSizeLimit
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function getAvailableAttributesKeys (tx: TxCUD<Doc>, hierarchy: Hierarchy): string[] {
|
||||
if (hierarchy.isDerived(tx._class, core.class.TxUpdateDoc)) {
|
||||
const updateTx = tx as TxUpdateDoc<Doc>
|
||||
@@ -282,6 +301,11 @@ export async function getTxAttributesUpdates (
|
||||
}
|
||||
}
|
||||
|
||||
if (valueSizeExceedsLimit(attrValue)) {
|
||||
attrValue = [activity.string.ValueTooLarge]
|
||||
prevValue = [activity.string.ValueTooLarge]
|
||||
}
|
||||
|
||||
let setAttr = []
|
||||
|
||||
if (Array.isArray(attrValue)) {
|
||||
|
||||
@@ -26,6 +26,8 @@ import { Doc as YDoc } from 'yjs'
|
||||
import { Context } from '../context'
|
||||
import { CollabStorageAdapter } from './adapter'
|
||||
|
||||
const activityMarkupLimit = 100 * 1024 // 100kb
|
||||
|
||||
export interface PlatformStorageAdapterOptions {
|
||||
retryCount?: number
|
||||
retryInterval?: number
|
||||
@@ -211,8 +213,8 @@ export class PlatformStorageAdapter implements CollabStorageAdapter {
|
||||
curr: getMarkup.curr()
|
||||
}
|
||||
|
||||
const currMarkup = markup.curr[objectAttr]
|
||||
const prevMarkup = markup.prev[objectAttr]
|
||||
const currMarkup = markup.curr[objectAttr] ?? ''
|
||||
const prevMarkup = markup.prev[objectAttr] ?? ''
|
||||
|
||||
if (areEqualMarkups(currMarkup, prevMarkup)) {
|
||||
ctx.info('markup not changed, skip platform update', { documentName })
|
||||
@@ -255,6 +257,9 @@ export class PlatformStorageAdapter implements CollabStorageAdapter {
|
||||
|
||||
await ctx.with('update', {}, () => client.diffUpdate(current, { [objectAttr]: blobId }))
|
||||
|
||||
const prevValue = prevMarkup.length > activityMarkupLimit ? activity.string.ValueTooLarge : prevMarkup
|
||||
const currValue = currMarkup.length > activityMarkupLimit ? activity.string.ValueTooLarge : currMarkup
|
||||
|
||||
await ctx.with(
|
||||
'activity',
|
||||
{},
|
||||
@@ -270,8 +275,8 @@ export class PlatformStorageAdapter implements CollabStorageAdapter {
|
||||
attributeUpdates: {
|
||||
attrKey: objectAttr,
|
||||
attrClass: core.class.TypeMarkup,
|
||||
prevValue: prevMarkup,
|
||||
set: [currMarkup],
|
||||
prevValue,
|
||||
set: [currValue],
|
||||
added: [],
|
||||
removed: [],
|
||||
isMixin: hierarchy.isMixin(objectClass)
|
||||
|
||||
Reference in New Issue
Block a user