diff --git a/plugins/activity-assets/lang/en.json b/plugins/activity-assets/lang/en.json index 0ba772ed53..9ed719b362 100644 --- a/plugins/activity-assets/lang/en.json +++ b/plugins/activity-assets/lang/en.json @@ -3,6 +3,8 @@ "Delete": "Delete", "Edit": "Edit", "Options": "Options", - "Edited": "edited" + "Edited": "edited", + "DocCreated": "created {_class}", + "DocDeleted": "deleted {_class}" } } \ No newline at end of file diff --git a/plugins/activity-resources/src/components/TxView.svelte b/plugins/activity-resources/src/components/TxView.svelte index 335a62d670..66620170bc 100644 --- a/plugins/activity-resources/src/components/TxView.svelte +++ b/plugins/activity-resources/src/components/TxView.svelte @@ -141,7 +141,7 @@ {#if viewlet && viewlet?.editable} <div class="edited"> {#if viewlet.label} - <Label label={viewlet.label} /> + <Label label={viewlet.label} params={viewlet.labelParams ?? {}} /> {/if} {#if tx.updated} <Label label={activity.string.Edited} /> @@ -152,7 +152,7 @@ </div> {:else if viewlet && viewlet.label} <div class='flex-center'> - <Label label={viewlet.label} /> + <Label label={viewlet.label} params={viewlet.labelParams ?? {}} /> {#if viewlet.labelComponent} <Component is={viewlet.labelComponent} {props} /> {/if} diff --git a/plugins/activity-resources/src/components/utils.ts b/plugins/activity-resources/src/components/utils.ts index 906870fa87..551ad8c0d1 100644 --- a/plugins/activity-resources/src/components/utils.ts +++ b/plugins/activity-resources/src/components/utils.ts @@ -1,14 +1,14 @@ import type { TxViewlet } from '@anticrm/activity' -import activity from '@anticrm/activity' +import activity from '../plugin' import core, { Class, Doc, Ref, TxCUD, TxOperations } from '@anticrm/core' -import { Asset, IntlString } from '@anticrm/platform' +import { Asset, IntlString, translate } from '@anticrm/platform' import { AnyComponent, AnySvelteComponent } from '@anticrm/ui' import { AttributeModel } from '@anticrm/view' import { buildModel, getObjectPresenter } from '@anticrm/view-resources' import { ActivityKey, activityKey, DisplayTx } from '../activity' export type TxDisplayViewlet = - | (Pick<TxViewlet, 'icon' | 'label' | 'display' | 'editable' | 'hideOnRemove' | 'labelComponent'> & { + | (Pick<TxViewlet, 'icon' | 'label' | 'display' | 'editable' | 'hideOnRemove' | 'labelComponent' | 'labelParams'> & { component?: AnyComponent | AnySvelteComponent }) | undefined @@ -16,7 +16,7 @@ export type TxDisplayViewlet = async function createPseudoViewlet ( client: TxOperations, dtx: DisplayTx, - label: string + label: IntlString ): Promise<TxDisplayViewlet> { const doc = dtx.doc if (doc === undefined) { @@ -24,12 +24,14 @@ async function createPseudoViewlet ( } const docClass: Class<Doc> = client.getModel().getObject(doc._class) + const trLabel = await translate(docClass.label, {}) const presenter = await getObjectPresenter(client, doc._class, { key: 'doc-presenter' }) if (presenter !== undefined) { return { display: 'inline', icon: docClass.icon ?? activity.icon.Activity, - label: (`${label} ` + docClass.label) as IntlString, + label: label, + labelParams: { _class: trLabel }, component: presenter.presenter } } @@ -76,10 +78,10 @@ async function checkInlineViewlets ( ): Promise<{ viewlet: TxDisplayViewlet, model: AttributeModel[] }> { if (dtx.tx._class === core.class.TxCreateDoc) { // Check if we have a class presenter we could have a pseudo viewlet based on class presenter. - viewlet = await createPseudoViewlet(client, dtx, 'created') + viewlet = await createPseudoViewlet(client, dtx, activity.string.DocCreated) } if (dtx.tx._class === core.class.TxRemoveDoc) { - viewlet = await createPseudoViewlet(client, dtx, 'deleted') + viewlet = await createPseudoViewlet(client, dtx, activity.string.DocDeleted) } if (dtx.tx._class === core.class.TxUpdateDoc) { model = await createUpdateModel(dtx, client, model) diff --git a/plugins/activity-resources/src/plugin.ts b/plugins/activity-resources/src/plugin.ts index 247ff8f60c..d3847c6717 100644 --- a/plugins/activity-resources/src/plugin.ts +++ b/plugins/activity-resources/src/plugin.ts @@ -13,12 +13,14 @@ // limitations under the License. // -import chunter, { chunterId } from '@anticrm/chunter' +import activity, { activityId } from '@anticrm/activity' import type { IntlString } from '@anticrm/platform' import { mergeIds } from '@anticrm/platform' -export default mergeIds(chunterId, chunter, { +export default mergeIds(activityId, activity, { string: { - Activity: '' as IntlString + Activity: '' as IntlString, + DocCreated: '' as IntlString, + DocDeleted: '' as IntlString } }) diff --git a/plugins/activity/src/index.ts b/plugins/activity/src/index.ts index a3910b8634..13b4978b8e 100644 --- a/plugins/activity/src/index.ts +++ b/plugins/activity/src/index.ts @@ -37,6 +37,7 @@ export interface TxViewlet extends Doc { // Label will be displayed right after author label?: IntlString + labelParams?: any // Do component need to be emphasized or not. display: 'inline' | 'content' | 'emphasized'