From 4c7677bcf6409a8295caf4d5329032fa7bb5e897 Mon Sep 17 00:00:00 2001 From: Kristina Fefelova Date: Wed, 13 Dec 2023 00:58:07 +0400 Subject: [PATCH 1/4] Change activity messages structure Signed-off-by: Kristina Fefelova --- dev/generator/package.json | 2 +- dev/generator/src/comments.ts | 14 +- dev/tool/package.json | 2 +- dev/tool/src/clean.ts | 10 +- dev/tool/src/mixin.ts | 2 - models/activity/package.json | 3 +- models/activity/src/index.ts | 191 ++++++++++++++- models/activity/src/migration.ts | 48 ++++ models/activity/src/plugin.ts | 22 +- models/all/src/migration.ts | 2 + models/attachment/package.json | 1 - models/attachment/src/index.ts | 15 +- models/attachment/src/plugin.ts | 13 +- models/calendar/src/index.ts | 4 +- models/calendar/src/plugin.ts | 6 +- models/chunter/package.json | 1 + models/chunter/src/index.ts | 180 +++++++------- models/chunter/src/migration.ts | 5 +- models/chunter/src/plugin.ts | 30 +-- models/contact/package.json | 27 ++- models/contact/src/index.ts | 41 ++-- models/contact/src/plugin.ts | 9 +- models/hr/package.json | 19 +- models/hr/src/index.ts | 5 +- models/inventory/package.json | 19 +- models/inventory/src/index.ts | 27 ++- models/inventory/src/plugin.ts | 2 +- models/lead/package.json | 30 +-- models/lead/src/index.ts | 24 +- models/lead/src/plugin.ts | 3 +- models/notification/src/activityMessages.ts | 148 ------------ models/notification/src/index.ts | 226 ++++++------------ models/notification/src/plugin.ts | 21 +- models/recruit/package.json | 2 + models/recruit/src/index.ts | 38 ++- models/recruit/src/plugin.ts | 11 +- models/recruit/src/review-model.ts | 5 +- models/request/src/index.ts | 6 +- models/server-chunter/src/index.ts | 2 +- models/server-notification/package.json | 2 + models/server-notification/src/index.ts | 5 +- models/server-notification/src/migration.ts | 31 +-- models/server-openai/package.json | 2 +- models/server-openai/src/index.ts | 4 +- models/setting/src/index.ts | 4 +- models/setting/src/plugin.ts | 10 +- models/task/package.json | 2 +- models/task/src/index.ts | 5 +- models/task/src/plugin.ts | 1 - models/telegram/src/index.ts | 8 +- models/telegram/src/plugin.ts | 8 +- models/tracker/package.json | 1 + models/tracker/src/index.ts | 71 ++++-- models/tracker/src/plugin.ts | 20 +- models/tracker/src/types.ts | 8 +- models/view/src/index.ts | 13 +- packages/platform/package.json | 16 +- plugins/activity-assets/assets/icons.svg | 5 + plugins/activity-assets/lang/en.json | 20 +- plugins/activity-assets/lang/ru.json | 26 +- plugins/activity-assets/src/index.ts | 3 +- plugins/activity-resources/package.json | 2 + .../src/activityMessagesUtils.ts | 94 ++------ .../src/components/Activity.svelte | 24 +- .../src/components/ActivityExtension.svelte} | 18 +- .../src/components/ActivityFilter.svelte | 9 +- .../src/components/FilterPopup.svelte | 4 +- .../ActivityMessageExtension.svelte | 2 +- .../ActivityMessagePresenter.svelte | 2 +- .../ActivityMessageTemplate.svelte | 33 ++- .../activity-message/PinMessageAction.svelte | 2 +- .../DocUpdateMessageAttributes.svelte | 7 +- .../DocUpdateMessageContent.svelte | 14 +- .../DocUpdateMessageHeader.svelte | 14 +- .../DocUpdateMessageObjectValue.svelte | 6 +- .../DocUpdateMessagePresenter.svelte | 32 +-- .../AddedAttributesPresenter.svelte | 4 +- .../ChangeAttributesTemplate.svelte | 4 +- .../RemovedAttributesPresenter.svelte | 4 +- .../attributes/SetAttributesPresenter.svelte | 10 +- .../reactions/AddReactionAction.svelte} | 9 +- .../reactions/ReactionAddedMessage.svelte} | 3 +- .../components/reactions}/Reactions.svelte | 4 +- .../reactions}/ReactionsPresenter.svelte | 8 +- .../reactions}/ReactionsTooltip.svelte | 0 plugins/activity-resources/src/index.ts | 21 +- plugins/activity-resources/src/utils.ts | 29 ++- plugins/activity/package.json | 1 - plugins/activity/src/index.ts | 175 +++++++++++++- plugins/attachment-resources/package.json | 1 - .../AttachmentsUpdatedMessage.svelte} | 2 +- plugins/attachment-resources/src/index.ts | 14 +- plugins/bitrix/package.json | 2 +- plugins/bitrix/src/sync.ts | 4 +- plugins/chunter-resources/package.json | 1 + .../src/components/Channel.svelte | 4 +- .../src/components/Message.svelte | 13 +- .../src/components/Thread.svelte | 4 +- .../src/components/ThreadView.svelte | 6 +- .../BacklinkCreatedLabel.svelte} | 7 +- .../chat-message/ChatMessageHeader.svelte | 6 +- .../chat-message/ChatMessageInput.svelte | 6 +- .../chat-message/ChatMessagePopup.svelte | 9 +- .../chat-message/ChatMessagePresenter.svelte | 24 +- .../chat-message/ChatMessagesPresenter.svelte | 0 plugins/chunter-resources/src/index.ts | 53 ++-- plugins/chunter-resources/src/plugin.ts | 3 +- plugins/chunter-resources/src/utils.ts | 29 +-- plugins/chunter/package.json | 12 +- plugins/chunter/src/index.ts | 42 +++- plugins/contact-resources/package.json | 1 - .../NameChangedActivityMessage.svelte} | 8 +- plugins/contact-resources/src/index.ts | 8 +- plugins/notification-assets/assets/icons.svg | 20 -- plugins/notification-assets/lang/en.json | 26 +- plugins/notification-assets/lang/ru.json | 26 +- plugins/notification-assets/src/index.ts | 5 +- .../NotificationCollaboratorsChanged.svelte | 4 +- .../src/components/icons/Emoji.svelte | 24 -- .../src/components/icons/Thread.svelte | 27 --- .../src/components/inbox/Inbox.svelte | 18 +- .../src/components/inbox/InboxAside.svelte | 21 +- .../src/inboxNotificationsClient.ts | 4 +- plugins/notification-resources/src/index.ts | 40 +--- plugins/notification-resources/src/utils.ts | 84 +++++-- plugins/notification/package.json | 1 + plugins/notification/src/index.ts | 198 +-------------- plugins/request/package.json | 2 +- plugins/request/src/index.ts | 2 +- .../src/components/issues/IssuePreview.svelte | 6 +- .../src/components/issues/KanbanView.svelte | 2 +- plugins/view/src/index.ts | 8 - .../notification-resources/package.json | 1 + .../notification-resources/src/index.ts | 20 +- .../notification-resources/src/utils.ts | 4 +- server-plugins/notification/src/index.ts | 22 +- server-plugins/openai/package.json | 2 +- server-plugins/openai/src/resources.ts | 11 +- server-plugins/tracker-resources/package.json | 1 + server-plugins/tracker-resources/src/index.ts | 6 +- 140 files changed, 1419 insertions(+), 1441 deletions(-) create mode 100644 models/activity/src/migration.ts delete mode 100644 models/notification/src/activityMessages.ts rename plugins/{notification-resources => activity-resources}/src/activityMessagesUtils.ts (85%) rename plugins/{chunter-resources/src/components/notification/ActivityMessageReactionsAction.svelte => activity-resources/src/components/ActivityExtension.svelte} (57%) rename plugins/{notification-resources => activity-resources}/src/components/activity-message/ActivityMessageExtension.svelte (96%) rename plugins/{notification-resources => activity-resources}/src/components/activity-message/ActivityMessagePresenter.svelte (95%) rename plugins/{notification-resources => activity-resources}/src/components/activity-message/ActivityMessageTemplate.svelte (87%) rename plugins/{notification-resources => activity-resources}/src/components/activity-message/PinMessageAction.svelte (94%) rename plugins/{notification-resources => activity-resources}/src/components/doc-update-message/DocUpdateMessageAttributes.svelte (86%) rename plugins/{notification-resources => activity-resources}/src/components/doc-update-message/DocUpdateMessageContent.svelte (91%) rename plugins/{notification-resources => activity-resources}/src/components/doc-update-message/DocUpdateMessageHeader.svelte (89%) rename plugins/{notification-resources => activity-resources}/src/components/doc-update-message/DocUpdateMessageObjectValue.svelte (91%) rename plugins/{notification-resources => activity-resources}/src/components/doc-update-message/DocUpdateMessagePresenter.svelte (88%) rename plugins/{notification-resources => activity-resources}/src/components/doc-update-message/attributes/AddedAttributesPresenter.svelte (88%) rename plugins/{notification-resources => activity-resources}/src/components/doc-update-message/attributes/ChangeAttributesTemplate.svelte (94%) rename plugins/{notification-resources => activity-resources}/src/components/doc-update-message/attributes/RemovedAttributesPresenter.svelte (88%) rename plugins/{notification-resources => activity-resources}/src/components/doc-update-message/attributes/SetAttributesPresenter.svelte (90%) rename plugins/{chunter-resources/src/components/ReactionsAction.svelte => activity-resources/src/components/reactions/AddReactionAction.svelte} (86%) rename plugins/{chunter-resources/src/components/notification/NotificationReactionCreated.svelte => activity-resources/src/components/reactions/ReactionAddedMessage.svelte} (92%) rename plugins/{chunter-resources/src/components => activity-resources/src/components/reactions}/Reactions.svelte (96%) rename plugins/{chunter-resources/src/components => activity-resources/src/components/reactions}/ReactionsPresenter.svelte (84%) rename plugins/{chunter-resources/src/components => activity-resources/src/components/reactions}/ReactionsTooltip.svelte (100%) rename plugins/attachment-resources/src/components/{notification/NotificationAttachmentChanged.svelte => activity/AttachmentsUpdatedMessage.svelte} (94%) rename plugins/chunter-resources/src/components/{notification/NotificationBacklinkLabel.svelte => activity/BacklinkCreatedLabel.svelte} (98%) rename plugins/{notification-resources => chunter-resources}/src/components/chat-message/ChatMessageHeader.svelte (89%) rename plugins/{notification-resources => chunter-resources}/src/components/chat-message/ChatMessageInput.svelte (94%) rename plugins/{notification-resources => chunter-resources}/src/components/chat-message/ChatMessagePopup.svelte (92%) rename plugins/{notification-resources => chunter-resources}/src/components/chat-message/ChatMessagePresenter.svelte (85%) rename plugins/{notification-resources => chunter-resources}/src/components/chat-message/ChatMessagesPresenter.svelte (100%) rename plugins/contact-resources/src/components/{notification/NotificationNameChanged.svelte => activity/NameChangedActivityMessage.svelte} (85%) delete mode 100644 plugins/notification-resources/src/components/icons/Emoji.svelte delete mode 100644 plugins/notification-resources/src/components/icons/Thread.svelte diff --git a/dev/generator/package.json b/dev/generator/package.json index b7ef8e52863..f86db4ce469 100644 --- a/dev/generator/package.json +++ b/dev/generator/package.json @@ -39,6 +39,7 @@ "dependencies": { "@hcengineering/account": "^0.6.0", "@hcengineering/attachment": "^0.6.9", + "@hcengineering/chunter": "^0.6.12", "@hcengineering/client": "^0.6.14", "@hcengineering/client-resources": "^0.6.23", "@hcengineering/contact": "^0.6.20", @@ -54,7 +55,6 @@ "@hcengineering/task": "^0.6.13", "@hcengineering/telegram": "^0.6.14", "@hcengineering/tracker": "^0.6.13", - "@hcengineering/notification": "^0.6.16", "@types/pdfkit": "~0.12.3", "commander": "^8.1.0", "faker": "~5.5.3", diff --git a/dev/generator/src/comments.ts b/dev/generator/src/comments.ts index fe314a736df..9f2936c9a6d 100644 --- a/dev/generator/src/comments.ts +++ b/dev/generator/src/comments.ts @@ -1,5 +1,5 @@ +import chunter, { ChatMessage } from '@hcengineering/chunter' import { AttachedData, Class, Doc, generateId, Ref, Space, TxOperations } from '@hcengineering/core' -import notification, { ChatMessage } from '@hcengineering/notification' import faker from 'faker' export interface CommentOptions { @@ -25,20 +25,12 @@ export async function addComments ( const commentData: AttachedData = { message: faker.lorem.paragraphs(options.paragraphMin + faker.datatype.number(options.paragraphMax)) } - await client.addCollection( - notification.class.ChatMessage, - space, - objectId, - _class, - collection, - commentData, - commentId - ) + await client.addCollection(chunter.class.ChatMessage, space, objectId, _class, collection, commentData, commentId) if (faker.datatype.number(100) > options.updateFactor) { const updateMsg = faker.lorem.paragraphs(options.paragraphMin + faker.datatype.number(options.paragraphMax)) - await client.updateCollection(notification.class.ChatMessage, space, commentId, objectId, _class, collection, { + await client.updateCollection(chunter.class.ChatMessage, space, commentId, objectId, _class, collection, { message: updateMsg }) } diff --git a/dev/tool/package.json b/dev/tool/package.json index 33f918d8fde..217c6610b67 100644 --- a/dev/tool/package.json +++ b/dev/tool/package.json @@ -49,6 +49,7 @@ "@elastic/elasticsearch": "^7.14.0", "@hcengineering/account": "^0.6.0", "@hcengineering/attachment": "^0.6.9", + "@hcengineering/chunter": "^0.6.12", "@hcengineering/client": "^0.6.14", "@hcengineering/client-resources": "^0.6.23", "@hcengineering/contact": "^0.6.20", @@ -64,7 +65,6 @@ "@hcengineering/model-recruit": "^0.6.0", "@hcengineering/model-telegram": "^0.6.0", "@hcengineering/mongo": "^0.6.1", - "@hcengineering/notification": "^0.6.16", "@hcengineering/openai": "^0.6.0", "@hcengineering/platform": "^0.6.9", "@hcengineering/recruit": "^0.6.21", diff --git a/dev/tool/src/clean.ts b/dev/tool/src/clean.ts index 3303c21646f..a13b46b4aab 100644 --- a/dev/tool/src/clean.ts +++ b/dev/tool/src/clean.ts @@ -38,9 +38,9 @@ import { connect } from '@hcengineering/server-tool' import tracker from '@hcengineering/tracker' import tags, { TagCategory, TagElement, TagReference } from '@hcengineering/tags' import { MongoClient } from 'mongodb' -import notification, { ChatMessage } from '@hcengineering/notification' +import chunter, { ChatMessage } from '@hcengineering/chunter' -export const DOMAIN_COMMENT = 'comment' as Domain +export const DOMAIN_CHUNTER = 'chunter' as Domain export async function cleanWorkspace ( mongoUrl: string, @@ -322,11 +322,11 @@ export async function fixCommentDoubleIdCreate (workspaceId: WorkspaceId, transa try { const commentTxes = await connection.findAll(core.class.TxCollectionCUD, { 'tx._class': core.class.TxCreateDoc, - 'tx.objectClass': notification.class.ChatMessage + 'tx.objectClass': chunter.class.ChatMessage }) const commentTxesRemoved = await connection.findAll(core.class.TxCollectionCUD, { 'tx._class': core.class.TxRemoveDoc, - 'tx.objectClass': notification.class.ChatMessage + 'tx.objectClass': chunter.class.ChatMessage }) const removed = new Map(commentTxesRemoved.map((it) => [it.tx.objectId, it])) // Do not checked removed @@ -354,7 +354,7 @@ export async function fixCommentDoubleIdCreate (workspaceId: WorkspaceId, transa doc._id = c.tx.objectId as Ref await connection.upload(DOMAIN_TX, [c]) // Also we need to create snapsot - await connection.upload(DOMAIN_COMMENT, [doc]) + await connection.upload(DOMAIN_CHUNTER, [doc]) } } } diff --git a/dev/tool/src/mixin.ts b/dev/tool/src/mixin.ts index dd65295baf0..e2d27c1443a 100644 --- a/dev/tool/src/mixin.ts +++ b/dev/tool/src/mixin.ts @@ -31,8 +31,6 @@ import { getWorkspaceDB } from '@hcengineering/mongo' import { connect } from '@hcengineering/server-tool' import { MongoClient } from 'mongodb' -export const DOMAIN_COMMENT = 'comment' as Domain - interface PropertyInfo { name: string cValue: any diff --git a/models/activity/package.json b/models/activity/package.json index fe1ddfcaa9c..4cb6b4a1614 100644 --- a/models/activity/package.json +++ b/models/activity/package.json @@ -31,6 +31,7 @@ "@hcengineering/model": "^0.6.7", "@hcengineering/model-core": "^0.6.0", "@hcengineering/platform": "^0.6.9", - "@hcengineering/ui": "^0.6.11" + "@hcengineering/ui": "^0.6.11", + "@hcengineering/model-view": "^0.6.0" } } diff --git a/models/activity/src/index.ts b/models/activity/src/index.ts index 42b8a3b8126..76a76aed12e 100644 --- a/models/activity/src/index.ts +++ b/models/activity/src/index.ts @@ -13,17 +13,62 @@ // limitations under the License. // -import type { TxViewlet } from '@hcengineering/activity' -import core, { DOMAIN_MODEL, type Class, type Doc, type DocumentQuery, type Ref, type Tx } from '@hcengineering/core' -import { Model, type Builder } from '@hcengineering/model' -import { TDoc } from '@hcengineering/model-core' -import type { Asset, IntlString } from '@hcengineering/platform' +import { + type ActivityDoc, + type ActivityExtension, + type ActivityExtensionKind, + type ActivityMessage, + type ActivityMessageExtension, + type ActivityMessageExtensionKind, + type ActivityMessagesFilter, + type DocAttributeUpdates, + type DocUpdateAction, + type DocUpdateMessage, + type DocUpdateMessageViewlet, + type DocUpdateMessageViewletAttributesConfig, + type Reaction, + type TxViewlet +} from '@hcengineering/activity' +import core, { + DOMAIN_MODEL, + type Class, + type Doc, + type DocumentQuery, + type Ref, + type Tx, + IndexKind, + type TxCUD, + type Domain, + type Account +} from '@hcengineering/core' +import { + Model, + type Builder, + Prop, + Index, + TypeRef, + TypeString, + Mixin, + Collection, + TypeBoolean +} from '@hcengineering/model' +import { TAttachedDoc, TClass, TDoc } from '@hcengineering/model-core' +import type { Asset, IntlString, Resource } from '@hcengineering/platform' import { type AnyComponent } from '@hcengineering/ui/src/types' import activity from './plugin' +import view from '@hcengineering/model-view' +export { activityOperation } from './migration' export { activityId } from '@hcengineering/activity' +export const DOMAIN_ACTIVITY = 'activity' as Domain + +@Mixin(activity.mixin.ActivityDoc, core.class.Class) +export class TActivityDoc extends TClass implements ActivityDoc { + ignoreCollections?: string[] +} + @Model(activity.class.TxViewlet, core.class.Doc, DOMAIN_MODEL) export class TTxViewlet extends TDoc implements TxViewlet { icon!: Asset @@ -39,8 +84,142 @@ export class TTxViewlet extends TDoc implements TxViewlet { hideOnRemove!: boolean } +@Model(activity.class.ActivityMessage, core.class.AttachedDoc, DOMAIN_ACTIVITY) +export class TActivityMessage extends TAttachedDoc implements ActivityMessage { + @Prop(TypeBoolean(), activity.string.Pinned) + @Index(IndexKind.Indexed) + isPinned?: boolean + + @Prop(Collection(activity.class.Reaction), activity.string.Reactions) + reactions?: number +} + +@Model(activity.class.DocUpdateMessage, activity.class.ActivityMessage, DOMAIN_ACTIVITY) +export class TDocUpdateMessage extends TActivityMessage implements DocUpdateMessage { + @Prop(TypeRef(core.class.Doc), core.string.Object) + @Index(IndexKind.Indexed) + objectId!: Ref + + @Prop(TypeRef(core.class.Class), core.string.Class) + @Index(IndexKind.Indexed) + objectClass!: Ref> + + @Prop(TypeRef(core.class.TxCUD), core.string.Object) + @Index(IndexKind.Indexed) + txId!: Ref> + + action!: DocUpdateAction + updateCollection?: string + attributeUpdates?: DocAttributeUpdates +} + +@Model(activity.class.DocUpdateMessageViewlet, core.class.Doc, DOMAIN_MODEL) +export class TDocUpdateMessageViewlet extends TDoc implements DocUpdateMessageViewlet { + @Prop(TypeRef(core.class.Doc), core.string.Class) + @Index(IndexKind.Indexed) + objectClass!: Ref> + + @Prop(TypeString(), core.string.String) + @Index(IndexKind.Indexed) + action!: DocUpdateAction + + label?: IntlString + labelComponent?: AnyComponent + + valueAttr?: string + + icon?: Asset + component?: AnyComponent + config?: DocUpdateMessageViewletAttributesConfig + hideIfRemoved?: boolean + onlyWithParent?: boolean +} + +@Model(activity.class.ActivityMessageExtension, core.class.Doc, DOMAIN_MODEL) +export class TActivityMessageExtension extends TDoc implements ActivityMessageExtension { + @Prop(TypeRef(activity.class.ActivityMessage), core.string.Class) + @Index(IndexKind.Indexed) + ofMessage!: Ref> + + components!: { kind: ActivityMessageExtensionKind, component: AnyComponent }[] +} + +@Model(activity.class.ActivityExtension, core.class.Doc, DOMAIN_MODEL) +export class TActivityExtension extends TDoc implements ActivityExtension { + @Prop(TypeRef(core.class.Class), core.string.Class) + @Index(IndexKind.Indexed) + ofClass!: Ref> + + components!: Record +} + +@Model(activity.class.ActivityMessagesFilter, core.class.Doc, DOMAIN_MODEL) +export class TActivityMessagesFilter extends TDoc implements ActivityMessagesFilter { + label!: IntlString + filter!: Resource<(message: ActivityMessage, _class?: Ref) => boolean> +} + +@Model(activity.class.Reaction, core.class.AttachedDoc, DOMAIN_ACTIVITY) +export class TReaction extends TAttachedDoc implements Reaction { + @Prop(TypeString(), activity.string.Emoji) + emoji!: string + + @Prop(TypeRef(core.class.Account), view.string.Created) + createBy!: Ref +} export function createModel (builder: Builder): void { - builder.createModel(TTxViewlet) + builder.createModel( + TTxViewlet, + TActivityDoc, + TActivityMessagesFilter, + TActivityMessageExtension, + TActivityMessage, + TDocUpdateMessage, + TDocUpdateMessageViewlet, + TActivityExtension, + TReaction + ) + + builder.mixin(activity.class.DocUpdateMessage, core.class.Class, activity.mixin.ActivityDoc, {}) + + builder.mixin(activity.class.DocUpdateMessage, core.class.Class, view.mixin.ObjectPresenter, { + presenter: activity.component.DocUpdateMessagePresenter + }) + + builder.createDoc(activity.class.ActivityMessagesFilter, core.space.Model, { + label: activity.string.Attributes, + filter: activity.filter.AttributesFilter + }) + + builder.createDoc(activity.class.ActivityMessagesFilter, core.space.Model, { + label: activity.string.Pinned, + filter: activity.filter.PinnedFilter + }) + + builder.createDoc( + activity.class.DocUpdateMessageViewlet, + core.space.Model, + { + objectClass: activity.class.Reaction, + action: 'create', + component: activity.component.ReactionAddedMessage, + label: activity.string.Reacted, + onlyWithParent: true, + hideIfRemoved: true + }, + activity.ids.ReactionAddedActivityViewlet + ) + + builder.createDoc( + activity.class.DocUpdateMessageViewlet, + core.space.Model, + { + objectClass: activity.class.Reaction, + action: 'remove', + hideIfRemoved: true + }, + activity.ids.ReactionRemovedActivityViewlet + ) } export default activity diff --git a/models/activity/src/migration.ts b/models/activity/src/migration.ts new file mode 100644 index 00000000000..d566c275bc7 --- /dev/null +++ b/models/activity/src/migration.ts @@ -0,0 +1,48 @@ +// +// Copyright © 2022 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { type Class, type Doc, type Domain, type Ref } from '@hcengineering/core' +import { + type MigrateOperation, + type MigrationClient, + type MigrationUpgradeClient, + tryMigrate +} from '@hcengineering/model' + +import activity from './plugin' +import { activityId, DOMAIN_ACTIVITY } from './index' + +const DOMAIN_CHUNTER = 'chunter' as Domain + +async function migrateReactions (client: MigrationClient): Promise { + await client.update( + DOMAIN_CHUNTER, + { _class: 'chunter:class:Reaction' as Ref> }, + { _class: activity.class.Reaction } + ) + await client.move(DOMAIN_CHUNTER, { _class: activity.class.Reaction }, DOMAIN_ACTIVITY) +} + +export const activityOperation: MigrateOperation = { + async migrate (client: MigrationClient): Promise { + await tryMigrate(client, activityId, [ + { + state: 'reactions', + func: migrateReactions + } + ]) + }, + async upgrade (client: MigrationUpgradeClient): Promise {} +} diff --git a/models/activity/src/plugin.ts b/models/activity/src/plugin.ts index ecac7b59a80..912cede81ec 100644 --- a/models/activity/src/plugin.ts +++ b/models/activity/src/plugin.ts @@ -12,8 +12,24 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import { activityId } from '@hcengineering/activity' +import { activityId, type ActivityMessage, type DocUpdateMessageViewlet } from '@hcengineering/activity' import activity from '@hcengineering/activity-resources/src/plugin' -import { mergeIds } from '@hcengineering/platform' +import { type IntlString, mergeIds, type Resource } from '@hcengineering/platform' +import { type Doc, type Ref } from '@hcengineering/core' -export default mergeIds(activityId, activity, {}) +export default mergeIds(activityId, activity, { + string: { + Attributes: '' as IntlString, + Pinned: '' as IntlString, + Emoji: '' as IntlString, + Reacted: '' as IntlString + }, + filter: { + AttributesFilter: '' as Resource<(message: ActivityMessage, _class?: Ref) => boolean>, + PinnedFilter: '' as Resource<(message: ActivityMessage, _class?: Ref) => boolean> + }, + ids: { + ReactionAddedActivityViewlet: '' as Ref, + ReactionRemovedActivityViewlet: '' as Ref + } +}) diff --git a/models/all/src/migration.ts b/models/all/src/migration.ts index a2fbe38b925..f749ad7f886 100644 --- a/models/all/src/migration.ts +++ b/models/all/src/migration.ts @@ -37,9 +37,11 @@ import { hrOperation } from '@hcengineering/model-hr' import { bitrixOperation } from '@hcengineering/model-bitrix' import { calendarOperation } from '@hcengineering/model-calendar' import { notificationServerOperation } from '@hcengineering/model-server-notification' +import { activityOperation } from '@hcengineering/model-activity' export const migrateOperations: [string, MigrateOperation][] = [ ['core', coreOperation], + ['activity', activityOperation], ['chunter', chunterOperation], ['calendar', calendarOperation], ['gmail', gmailOperation], diff --git a/models/attachment/package.json b/models/attachment/package.json index a16d569ce84..5c92ba04bbc 100644 --- a/models/attachment/package.json +++ b/models/attachment/package.json @@ -33,7 +33,6 @@ "@hcengineering/model-core": "^0.6.0", "@hcengineering/model-preference": "^0.6.0", "@hcengineering/model-view": "^0.6.0", - "@hcengineering/notification": "^0.6.16", "@hcengineering/platform": "^0.6.9", "@hcengineering/ui": "^0.6.11", "@hcengineering/view": "^0.6.9" diff --git a/models/attachment/src/index.ts b/models/attachment/src/index.ts index 97783eccea4..49cc85af535 100644 --- a/models/attachment/src/index.ts +++ b/models/attachment/src/index.ts @@ -32,7 +32,6 @@ import core, { TAttachedDoc } from '@hcengineering/model-core' import preference, { TPreference } from '@hcengineering/model-preference' import view, { createAction } from '@hcengineering/model-view' import attachment from './plugin' -import notification from '@hcengineering/notification' export { attachmentId } from '@hcengineering/attachment' export { attachmentOperation } from './migration' @@ -124,32 +123,32 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: attachment.class.Attachment, action: 'create', icon: attachment.icon.Attachment, label: attachment.string.AddAttachment, - component: attachment.notification.NotificationAttachmentChanged + component: attachment.activity.AttachmentsUpdatedMessage }, - attachment.ids.NotificationAttachmentCreated + attachment.ids.AttachmentCreatedActivityViewlet ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: attachment.class.Attachment, action: 'remove', icon: attachment.icon.Attachment, label: attachment.string.RemovedAttachment, - component: attachment.notification.NotificationAttachmentChanged + component: attachment.activity.AttachmentsUpdatedMessage }, - attachment.ids.NotificationAttachmentRemoved + attachment.ids.AttachmentRemovedActivityViewlet ) - builder.createDoc(notification.class.ActivityMessagesFilter, core.space.Model, { + builder.createDoc(activity.class.ActivityMessagesFilter, core.space.Model, { label: attachment.string.FilterAttachments, filter: attachment.filter.AttachmentsFilter }) diff --git a/models/attachment/src/plugin.ts b/models/attachment/src/plugin.ts index f74e51257cc..9bc47631bd4 100644 --- a/models/attachment/src/plugin.ts +++ b/models/attachment/src/plugin.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import type { TxViewlet } from '@hcengineering/activity' +import type { TxViewlet, ActivityMessage, DocUpdateMessageViewlet } from '@hcengineering/activity' import { attachmentId } from '@hcengineering/attachment' import attachment from '@hcengineering/attachment-resources/src/plugin' import type { Ref, Doc } from '@hcengineering/core' @@ -21,7 +21,6 @@ import type { IntlString, Resource } from '@hcengineering/platform' import { mergeIds } from '@hcengineering/platform' import type { AnyComponent } from '@hcengineering/ui/src/types' import type { ActionCategory } from '@hcengineering/view' -import { type ActivityMessage, type DocUpdateMessageViewlet } from '@hcengineering/notification' export default mergeIds(attachmentId, attachment, { component: { @@ -47,14 +46,12 @@ export default mergeIds(attachmentId, attachment, { ids: { TxAttachmentCreate: '' as Ref, TxAttachmentRemove: '' as Ref, - NotificationAttachmentCreated: '' as Ref, - NotificationAttachmentRemoved: '' as Ref + AttachmentCreatedActivityViewlet: '' as Ref, + AttachmentRemovedActivityViewlet: '' as Ref }, activity: { - TxAttachmentCreate: '' as AnyComponent - }, - notification: { - NotificationAttachmentChanged: '' as AnyComponent + TxAttachmentCreate: '' as AnyComponent, + AttachmentsUpdatedMessage: '' as AnyComponent }, category: { Attachments: '' as Ref diff --git a/models/calendar/src/index.ts b/models/calendar/src/index.ts index 39f5d708a05..7310c2da16d 100644 --- a/models/calendar/src/index.ts +++ b/models/calendar/src/index.ts @@ -244,7 +244,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: calendar.class.Event, @@ -252,7 +252,7 @@ export function createModel (builder: Builder): void { action: 'update', hideIfRemoved: true }, - calendar.ids.UpdateRemainderNotificationViewlet + calendar.ids.UpdateRemainderActivityViewlet ) builder.createDoc( diff --git a/models/calendar/src/plugin.ts b/models/calendar/src/plugin.ts index c9f7eb65997..78980c5d225 100644 --- a/models/calendar/src/plugin.ts +++ b/models/calendar/src/plugin.ts @@ -13,11 +13,11 @@ // limitations under the License. // -import { type TxViewlet } from '@hcengineering/activity' +import { type DocUpdateMessageViewlet, type TxViewlet } from '@hcengineering/activity' import { calendarId } from '@hcengineering/calendar' import calendar from '@hcengineering/calendar-resources/src/plugin' import { type Ref } from '@hcengineering/core' -import { type DocUpdateMessageViewlet, type NotificationGroup } from '@hcengineering/notification' +import { type NotificationGroup } from '@hcengineering/notification' import type { IntlString } from '@hcengineering/platform' import { mergeIds } from '@hcengineering/platform' import { type AnyComponent } from '@hcengineering/ui/src/types' @@ -66,7 +66,7 @@ export default mergeIds(calendarId, calendar, { }, ids: { ReminderViewlet: '' as Ref, - UpdateRemainderNotificationViewlet: '' as Ref, + UpdateRemainderActivityViewlet: '' as Ref, CalendarNotificationGroup: '' as Ref } }) diff --git a/models/chunter/package.json b/models/chunter/package.json index 46e73183701..016006399f0 100644 --- a/models/chunter/package.json +++ b/models/chunter/package.json @@ -33,6 +33,7 @@ "@hcengineering/core": "^0.6.28", "@hcengineering/model": "^0.6.7", "@hcengineering/model-attachment": "^0.6.0", + "@hcengineering/model-activity": "^0.6.0", "@hcengineering/model-core": "^0.6.0", "@hcengineering/model-notification": "^0.6.0", "@hcengineering/model-preference": "^0.6.0", diff --git a/models/chunter/src/index.ts b/models/chunter/src/index.ts index 329892ecec2..18d99fa7608 100644 --- a/models/chunter/src/index.ts +++ b/models/chunter/src/index.ts @@ -24,17 +24,28 @@ import { type Comment, type DirectMessage, type Message, - type Reaction, type SavedMessages, type ThreadMessage, - type DirectMessageInput + type DirectMessageInput, + type ChatMessage, + type ChatMessageViewlet } from '@hcengineering/chunter' import contact, { type Person } from '@hcengineering/contact' -import type { Account, Class, Doc, Domain, Ref, Space, Timestamp } from '@hcengineering/core' -import { IndexKind } from '@hcengineering/core' +import { + type Account, + type Class, + type Doc, + type Domain, + DOMAIN_MODEL, + type Ref, + type Space, + type Timestamp, + IndexKind +} from '@hcengineering/core' import { ArrOf, type Builder, + Collection as PropCollection, Collection, Index, Mixin, @@ -48,7 +59,7 @@ import { UX } from '@hcengineering/model' import attachment from '@hcengineering/model-attachment' -import core, { TAttachedDoc, TClass, TSpace } from '@hcengineering/model-core' +import core, { TAttachedDoc, TClass, TDoc, TSpace } from '@hcengineering/model-core' import notification from '@hcengineering/model-notification' import preference, { TPreference } from '@hcengineering/model-preference' import view, { createAction, actionTemplates as viewTemplates } from '@hcengineering/model-view' @@ -56,6 +67,8 @@ import workbench from '@hcengineering/model-workbench' import chunter from './plugin' import { type AnyComponent } from '@hcengineering/ui/src/types' import { TypeBoolean } from '@hcengineering/model' +import type { IntlString } from '@hcengineering/platform' +import { TActivityMessage } from '@hcengineering/model-activity' export { chunterId } from '@hcengineering/chunter' export { chunterOperation } from './migration' @@ -99,7 +112,7 @@ export class TChunterMessage extends TAttachedDoc implements ChunterMessage { @Prop(TypeTimestamp(), chunter.string.Edit) editedOn?: Timestamp - @Prop(Collection(chunter.class.Reaction), chunter.string.Reactions) + @Prop(Collection(activity.class.Reaction), activity.string.Reactions) reactions?: number } @@ -130,18 +143,6 @@ export class TMessage extends TChunterMessage implements Message { lastReply?: Timestamp } -@Model(chunter.class.Reaction, core.class.AttachedDoc, DOMAIN_CHUNTER) -export class TReaction extends TAttachedDoc implements Reaction { - @Prop(TypeString(), chunter.string.Emoji) - emoji!: string - - @Prop(TypeRef(core.class.Account), chunter.string.CreateBy) - createBy!: Ref - - declare attachedTo: Ref - declare attachedToClass: Ref> -} - @Model(chunter.class.Comment, core.class.AttachedDoc, DOMAIN_COMMENT) @UX(chunter.string.Comment, undefined, 'COM') export class TComment extends TAttachedDoc implements Comment { @@ -152,7 +153,7 @@ export class TComment extends TAttachedDoc implements Comment { @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, { shortLabel: attachment.string.Files }) attachments?: number - @Prop(Collection(chunter.class.Reaction), chunter.string.Reactions) + @Prop(Collection(activity.class.Reaction), activity.string.Reactions) reactions?: number @Prop(TypeBoolean(), chunter.string.PinMessage) @@ -177,6 +178,32 @@ export class TDirectMessageInput extends TClass implements DirectMessageInput { component!: AnyComponent } +@Model(chunter.class.ChatMessage, activity.class.ActivityMessage, DOMAIN_CHUNTER) +export class TChatMessage extends TActivityMessage implements ChatMessage { + @Prop(TypeMarkup(), chunter.string.Message) + @Index(IndexKind.FullText) + message!: string + + @Prop(PropCollection(attachment.class.Attachment), attachment.string.Attachments, { + shortLabel: attachment.string.Files + }) + attachments?: number + + @Prop(TypeBoolean(), core.string.Boolean) + @Index(IndexKind.Indexed) + isEdited?: boolean +} + +@Model(chunter.class.ChatMessageViewlet, core.class.Doc, DOMAIN_MODEL) +export class TChatMessageViewlet extends TDoc implements ChatMessageViewlet { + @Prop(TypeRef(core.class.Doc), core.string.Class) + @Index(IndexKind.Indexed) + objectClass!: Ref> + + label?: IntlString + onlyWithParent?: boolean +} + export function createModel (builder: Builder, options = { addApplication: true }): void { builder.createModel( TChunterSpace, @@ -189,13 +216,14 @@ export function createModel (builder: Builder, options = { addApplication: true TBacklink, TDirectMessage, TSavedMessages, - TReaction, - TDirectMessageInput + TDirectMessageInput, + TChatMessage, + TChatMessageViewlet ) const spaceClasses = [chunter.class.Channel, chunter.class.DirectMessage] spaceClasses.forEach((spaceClass) => { - builder.mixin(spaceClass, core.class.Class, notification.mixin.ActivityDoc, {}) + builder.mixin(spaceClass, core.class.Class, activity.mixin.ActivityDoc, {}) builder.mixin(spaceClass, core.class.Class, workbench.mixin.SpaceView, { view: { @@ -497,7 +525,7 @@ export function createModel (builder: Builder, options = { addApplication: true activity.class.TxViewlet, core.space.Model, { - objectClass: notification.class.ChatMessage, + objectClass: chunter.class.ChatMessage, icon: chunter.icon.Chunter, txClass: core.class.TxCreateDoc, component: chunter.activity.TxCommentCreate, @@ -616,7 +644,7 @@ export function createModel (builder: Builder, options = { addApplication: true activity.class.TxViewlet, core.space.Model, { - objectClass: notification.class.ChatMessage, + objectClass: chunter.class.ChatMessage, icon: chunter.icon.Chunter, txClass: core.class.TxRemoveDoc, display: 'inline', @@ -672,7 +700,7 @@ export function createModel (builder: Builder, options = { addApplication: true chunter.ids.TxBacklinkRemove ) - builder.createDoc(notification.class.ActivityMessagesFilter, core.space.Model, { + builder.createDoc(activity.class.ActivityMessagesFilter, core.space.Model, { label: chunter.string.FilterBacklinks, filter: chunter.filter.BacklinksFilter }) @@ -758,44 +786,6 @@ export function createModel (builder: Builder, options = { addApplication: true chunter.ids.ChannelNotification ) - builder.createDoc( - notification.class.ActivityMessageExtension, - core.space.Model, - { - ofMessage: notification.class.DocUpdateMessage, - components: [ - { - kind: 'footer', - component: chunter.component.ReactionsPresenter - }, - { - kind: 'action', - component: chunter.component.ActivityMessageReactionsAction - } - ] - }, - chunter.ids.DocUpdateMessageExtension - ) - - builder.createDoc( - notification.class.ActivityMessageExtension, - core.space.Model, - { - ofMessage: notification.class.ChatMessage, - components: [ - { - kind: 'footer', - component: chunter.component.ReactionsPresenter - }, - { - kind: 'action', - component: chunter.component.ActivityMessageReactionsAction - } - ] - }, - chunter.ids.ChatMessageExtension - ) - builder.createDoc( notification.class.NotificationType, core.space.Model, @@ -814,52 +804,27 @@ export function createModel (builder: Builder, options = { addApplication: true ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: chunter.class.Backlink, action: 'create', component: chunter.component.BacklinkContent, - labelComponent: chunter.component.NotificationBacklinkLabel, + labelComponent: chunter.activity.BacklinkCreatedLabel, hideIfRemoved: true }, - chunter.ids.NotificationBacklinkCreated + chunter.ids.BacklinkCreatedActivityViewlet ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: chunter.class.Backlink, action: 'remove', hideIfRemoved: true }, - chunter.ids.NotificationBacklinkRemoved - ) - - builder.createDoc( - notification.class.DocUpdateMessageViewlet, - core.space.Model, - { - objectClass: chunter.class.Reaction, - action: 'create', - component: chunter.component.NotificationReactionCreated, - label: chunter.string.Reacted, - onlyWithParent: true, - hideIfRemoved: true - }, - chunter.ids.NotificationReactionCreated - ) - - builder.createDoc( - notification.class.DocUpdateMessageViewlet, - core.space.Model, - { - objectClass: chunter.class.Reaction, - action: 'remove', - hideIfRemoved: true - }, - chunter.ids.NotificationReactionRemoved + chunter.ids.BacklinkRemovedActivityViewlet ) createAction(builder, { @@ -874,6 +839,35 @@ export function createModel (builder: Builder, options = { addApplication: true mode: 'space' } }) + + builder.createDoc(activity.class.ActivityMessagesFilter, core.space.Model, { + label: chunter.string.Comments, + filter: chunter.filter.ChatMessagesFilter + }) + builder.mixin(chunter.class.ChatMessage, core.class.Class, activity.mixin.ActivityDoc, {}) + + builder.mixin(chunter.class.ChatMessage, core.class.Class, view.mixin.CollectionPresenter, { + presenter: chunter.component.ChatMessagesPresenter + }) + + builder.mixin(chunter.class.ChatMessage, core.class.Class, view.mixin.ObjectPresenter, { + presenter: chunter.component.ChatMessagePresenter + }) + + createAction( + builder, + { + action: chunter.actionImpl.DeleteChatMessage, + label: view.string.Delete, + icon: view.icon.Delete, + input: 'focus', + keyBinding: ['Backspace'], + category: chunter.category.Chunter, + target: chunter.class.ChatMessage, + context: { mode: ['context', 'browser'], group: 'edit' } + }, + chunter.action.DeleteChatMessage + ) } export default chunter diff --git a/models/chunter/src/migration.ts b/models/chunter/src/migration.ts index 7bd812ba5a7..75db42c70a2 100644 --- a/models/chunter/src/migration.ts +++ b/models/chunter/src/migration.ts @@ -21,7 +21,6 @@ import { tryMigrate } from '@hcengineering/model' import { chunterId } from '@hcengineering/chunter' -import notification from '@hcengineering/notification' import { DOMAIN_NOTIFICATION } from '@hcengineering/model-notification' import { DOMAIN_COMMENT } from './index' @@ -90,8 +89,8 @@ async function createBacklink (tx: TxOperations): Promise { } async function convertCommentsToChatMessages (client: MigrationClient): Promise { - await client.update(DOMAIN_COMMENT, { _class: chunter.class.Comment }, { _class: notification.class.ChatMessage }) - await client.move(DOMAIN_COMMENT, { _class: notification.class.ChatMessage }, DOMAIN_NOTIFICATION) + await client.update(DOMAIN_COMMENT, { _class: chunter.class.Comment }, { _class: chunter.class.ChatMessage }) + await client.move(DOMAIN_COMMENT, { _class: chunter.class.ChatMessage }, DOMAIN_NOTIFICATION) } export const chunterOperation: MigrateOperation = { diff --git a/models/chunter/src/plugin.ts b/models/chunter/src/plugin.ts index f873e2559cd..d581285a747 100644 --- a/models/chunter/src/plugin.ts +++ b/models/chunter/src/plugin.ts @@ -13,16 +13,11 @@ // limitations under the License. // -import type { TxViewlet } from '@hcengineering/activity' +import type { ActivityMessage, DocUpdateMessageViewlet, TxViewlet } from '@hcengineering/activity' import { chunterId, type Channel } from '@hcengineering/chunter' import chunter from '@hcengineering/chunter-resources/src/plugin' import type { Doc, Ref, Space } from '@hcengineering/core' -import { - type ActivityMessage, - type ActivityMessageExtension, - type DocUpdateMessageViewlet, - type NotificationGroup -} from '@hcengineering/notification' +import { type NotificationGroup } from '@hcengineering/notification' import type { IntlString, Resource } from '@hcengineering/platform' import { mergeIds } from '@hcengineering/platform' import type { AnyComponent, Location } from '@hcengineering/ui/src/types' @@ -37,9 +32,6 @@ export default mergeIds(chunterId, chunter, { Threads: '' as AnyComponent, SavedMessages: '' as AnyComponent, ChunterBrowser: '' as AnyComponent, - ReactionsPresenter: '' as AnyComponent, - ReactionsAction: '' as AnyComponent, - ActivityMessageReactionsAction: '' as AnyComponent, BacklinkContent: '' as AnyComponent, BacklinkReference: '' as AnyComponent }, @@ -58,14 +50,14 @@ export default mergeIds(chunterId, chunter, { MarkCommentUnread: '' as ViewAction, ArchiveChannel: '' as ViewAction, UnarchiveChannel: '' as ViewAction, - ConvertDmToPrivateChannel: '' as ViewAction + ConvertDmToPrivateChannel: '' as ViewAction, + DeleteChatMessage: '' as ViewAction }, category: { Chunter: '' as Ref }, string: { ApplicationLabelChunter: '' as IntlString, - LeftComment: '' as IntlString, MentionedIn: '' as IntlString, Content: '' as IntlString, Comment: '' as IntlString, @@ -100,16 +92,13 @@ export default mergeIds(chunterId, chunter, { TxChatMessageCreate: '' as Ref, TxChatMessageRemove: '' as Ref, ChunterNotificationGroup: '' as Ref, - DocUpdateMessageExtension: '' as Ref, - ChatMessageExtension: '' as Ref, - NotificationBacklinkCreated: '' as Ref, - NotificationBacklinkRemoved: '' as Ref, - NotificationReactionCreated: '' as Ref, - NotificationReactionRemoved: '' as Ref + BacklinkCreatedActivityViewlet: '' as Ref, + BacklinkRemovedActivityViewlet: '' as Ref }, activity: { TxCommentCreate: '' as AnyComponent, - TxMessageCreate: '' as AnyComponent + TxMessageCreate: '' as AnyComponent, + BacklinkCreatedLabel: '' as AnyComponent }, space: { General: '' as Ref, @@ -121,6 +110,7 @@ export default mergeIds(chunterId, chunter, { GetFragment: '' as Resource<(doc: Doc, props: Record) => Promise> }, filter: { - BacklinksFilter: '' as Resource<(message: ActivityMessage, _class?: Ref) => boolean> + BacklinksFilter: '' as Resource<(message: ActivityMessage, _class?: Ref) => boolean>, + ChatMessagesFilter: '' as Resource<(message: ActivityMessage, _class?: Ref) => boolean> } }) diff --git a/models/contact/package.json b/models/contact/package.json index 5a822568944..35f18e920f3 100644 --- a/models/contact/package.json +++ b/models/contact/package.json @@ -25,24 +25,25 @@ "prettier-plugin-svelte": "^3.1.0" }, "dependencies": { - "@hcengineering/model-core": "^0.6.0", - "@hcengineering/model-chunter": "^0.6.0", - "@hcengineering/model-workbench": "^0.6.1", + "@hcengineering/activity": "^0.6.0", + "@hcengineering/chunter": "^0.6.12", + "@hcengineering/contact": "^0.6.20", + "@hcengineering/contact-resources": "^0.6.0", + "@hcengineering/core": "^0.6.28", + "@hcengineering/model": "^0.6.7", "@hcengineering/model-attachment": "^0.6.0", + "@hcengineering/model-chunter": "^0.6.0", + "@hcengineering/model-core": "^0.6.0", "@hcengineering/model-notification": "^0.6.0", - "@hcengineering/model-view": "^0.6.0", "@hcengineering/model-presentation": "^0.6.0", - "@hcengineering/model": "^0.6.7", + "@hcengineering/model-view": "^0.6.0", + "@hcengineering/model-workbench": "^0.6.1", + "@hcengineering/notification": "^0.6.16", + "@hcengineering/platform": "^0.6.9", "@hcengineering/setting": "^0.6.11", - "@hcengineering/core": "^0.6.28", + "@hcengineering/templates": "^0.6.7", "@hcengineering/ui": "^0.6.11", - "@hcengineering/platform": "^0.6.9", - "@hcengineering/activity": "^0.6.0", - "@hcengineering/contact": "^0.6.20", - "@hcengineering/notification": "^0.6.16", - "@hcengineering/contact-resources": "^0.6.0", "@hcengineering/view": "^0.6.9", - "cross-fetch": "^3.1.5", - "@hcengineering/templates": "^0.6.7" + "cross-fetch": "^3.1.5" } } diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index d5005475bf7..4e76760f7dd 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -112,7 +112,7 @@ export class TContact extends TDoc implements Contact { @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, { shortLabel: attachment.string.Files }) attachments?: number - @Prop(Collection(notification.class.ChatMessage), notification.string.Comments) + @Prop(Collection(chunter.class.ChatMessage), chunter.string.Comments) comments?: number @Prop(TypeString(), contact.string.Location) @@ -221,24 +221,37 @@ export function createModel (builder: Builder): void { TContactsTab ) - builder.mixin(contact.class.Contact, core.class.Class, notification.mixin.ActivityDoc, { + builder.mixin(contact.class.Contact, core.class.Class, activity.mixin.ActivityDoc, { ignoreCollections: ['comments'] }) - builder.mixin(contact.class.Person, core.class.Class, notification.mixin.ActivityDoc, { + + builder.mixin(contact.class.Person, core.class.Class, activity.mixin.ActivityDoc, { + preposition: contact.string.For, ignoreCollections: ['comments'] }) - builder.mixin(contact.mixin.Employee, core.class.Class, notification.mixin.ActivityDoc, { + + builder.mixin(contact.mixin.Employee, core.class.Class, activity.mixin.ActivityDoc, { + preposition: contact.string.For, ignoreCollections: ['comments'] }) - builder.mixin(contact.class.Organization, core.class.Class, notification.mixin.ActivityDoc, { + + builder.mixin(contact.class.Organization, core.class.Class, activity.mixin.ActivityDoc, { ignoreCollections: ['comments'] }) - builder.mixin(contact.class.Person, core.class.Class, notification.mixin.NotificationObjectPreposition, { - preposition: contact.string.For + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: contact.class.Contact, + components: { input: chunter.component.ChatMessageInput } }) - builder.mixin(contact.mixin.Employee, core.class.Class, notification.mixin.NotificationObjectPreposition, { - preposition: contact.string.For + + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: contact.class.Person, + components: { input: chunter.component.ChatMessageInput } + }) + + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: contact.class.Organization, + components: { input: chunter.component.ChatMessageInput } }) builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.ObjectFactory, { @@ -329,12 +342,12 @@ export function createModel (builder: Builder): void { match: { 'operations.name': { $exists: true } } }) - builder.createDoc(notification.class.DocUpdateMessageViewlet, core.space.Model, { + builder.createDoc(activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: contact.class.Person, action: 'update', config: { name: { - presenter: contact.notification.NotificationNameChanged + presenter: contact.activity.NameChangedActivityMessage } } }) @@ -968,7 +981,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: contact.class.Person, @@ -978,7 +991,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: contact.mixin.Employee, @@ -988,7 +1001,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: contact.class.Organization, diff --git a/models/contact/src/plugin.ts b/models/contact/src/plugin.ts index 3cda3bff466..ead8c97e1e2 100644 --- a/models/contact/src/plugin.ts +++ b/models/contact/src/plugin.ts @@ -18,18 +18,17 @@ import { contactId } from '@hcengineering/contact' import contact from '@hcengineering/contact-resources/src/plugin' import type { Client, Doc, Ref } from '@hcengineering/core' import { type ObjectSearchCategory, type ObjectSearchFactory } from '@hcengineering/model-presentation' -import { type ChatMessageViewlet, type NotificationGroup } from '@hcengineering/notification' +import { type NotificationGroup } from '@hcengineering/notification' import { type IntlString, mergeIds, type Resource } from '@hcengineering/platform' import { type TemplateFieldFunc } from '@hcengineering/templates' import type { AnyComponent } from '@hcengineering/ui/src/types' import { type Action, type ActionCategory, type ViewAction } from '@hcengineering/view' +import { type ChatMessageViewlet } from '@hcengineering/chunter' export default mergeIds(contactId, contact, { activity: { - TxNameChange: '' as AnyComponent - }, - notification: { - NotificationNameChanged: '' as AnyComponent + TxNameChange: '' as AnyComponent, + NameChangedActivityMessage: '' as AnyComponent }, component: { PersonPresenter: '' as AnyComponent, diff --git a/models/hr/package.json b/models/hr/package.json index d66814350ca..d4090b56e3d 100644 --- a/models/hr/package.json +++ b/models/hr/package.json @@ -25,20 +25,21 @@ "prettier-plugin-svelte": "^3.1.0" }, "dependencies": { + "@hcengineering/contact": "^0.6.20", "@hcengineering/core": "^0.6.28", + "@hcengineering/hr": "^0.6.12", + "@hcengineering/hr-resources": "^0.6.0", "@hcengineering/model": "^0.6.7", - "@hcengineering/ui": "^0.6.11", - "@hcengineering/contact": "^0.6.20", - "@hcengineering/platform": "^0.6.9", + "@hcengineering/model-attachment": "^0.6.0", + "@hcengineering/model-calendar": "^0.6.0", + "@hcengineering/model-chunter": "^0.6.0", + "@hcengineering/model-contact": "^0.6.1", "@hcengineering/model-core": "^0.6.0", - "@hcengineering/notification": "^0.6.16", "@hcengineering/model-view": "^0.6.0", "@hcengineering/model-workbench": "^0.6.1", - "@hcengineering/model-contact": "^0.6.1", - "@hcengineering/model-calendar": "^0.6.0", - "@hcengineering/model-attachment": "^0.6.0", - "@hcengineering/hr": "^0.6.12", - "@hcengineering/hr-resources": "^0.6.0", + "@hcengineering/notification": "^0.6.16", + "@hcengineering/platform": "^0.6.9", + "@hcengineering/ui": "^0.6.11", "@hcengineering/view": "^0.6.9" } } diff --git a/models/hr/src/index.ts b/models/hr/src/index.ts index 8cfc91717ae..a3d934975f4 100644 --- a/models/hr/src/index.ts +++ b/models/hr/src/index.ts @@ -59,6 +59,7 @@ import notification from '@hcengineering/notification' import { type Asset, type IntlString } from '@hcengineering/platform' import hr from './plugin' import { PaletteColorIndexes } from '@hcengineering/ui/src/colors' +import chunter from '@hcengineering/model-chunter' export { hrId } from '@hcengineering/hr' export { hrOperation } from './migration' @@ -83,7 +84,7 @@ export class TDepartment extends TSpace implements Department { @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, { shortLabel: attachment.string.Files }) attachments?: number - @Prop(Collection(notification.class.ChatMessage), notification.string.Comments) + @Prop(Collection(chunter.class.ChatMessage), chunter.string.Comments) comments?: number avatar?: string | null @@ -157,7 +158,7 @@ export class TRequest extends TAttachedDoc implements Request { @Hidden() type!: Ref - @Prop(Collection(notification.class.ChatMessage), notification.string.Comments) + @Prop(Collection(chunter.class.ChatMessage), chunter.string.Comments) comments?: number @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, { shortLabel: attachment.string.Files }) diff --git a/models/inventory/package.json b/models/inventory/package.json index 29a3e546487..a644a65cb66 100644 --- a/models/inventory/package.json +++ b/models/inventory/package.json @@ -25,20 +25,21 @@ "prettier-plugin-svelte": "^3.1.0" }, "dependencies": { + "@hcengineering/activity": "^0.6.0", + "@hcengineering/chunter": "^0.6.12", "@hcengineering/core": "^0.6.28", + "@hcengineering/inventory": "^0.6.7", + "@hcengineering/inventory-resources": "^0.6.0", "@hcengineering/model": "^0.6.7", - "@hcengineering/model-workbench": "^0.6.1", "@hcengineering/model-attachment": "^0.6.0", + "@hcengineering/model-chunter": "^0.6.0", "@hcengineering/model-core": "^0.6.0", - "@hcengineering/ui": "^0.6.11", + "@hcengineering/model-view": "^0.6.0", + "@hcengineering/model-workbench": "^0.6.1", "@hcengineering/platform": "^0.6.9", - "@hcengineering/notification": "^0.6.16", - "@hcengineering/inventory": "^0.6.7", - "@hcengineering/inventory-resources": "^0.6.0", - "@hcengineering/view": "^0.6.9", "@hcengineering/setting": "^0.6.11", - "@hcengineering/workbench": "^0.6.9", - "@hcengineering/model-view": "^0.6.0", - "@hcengineering/model-chunter": "^0.6.0" + "@hcengineering/ui": "^0.6.11", + "@hcengineering/view": "^0.6.9", + "@hcengineering/workbench": "^0.6.9" } } diff --git a/models/inventory/src/index.ts b/models/inventory/src/index.ts index c355e960530..23c34e068e4 100644 --- a/models/inventory/src/index.ts +++ b/models/inventory/src/index.ts @@ -22,8 +22,8 @@ import { createAction } from '@hcengineering/model-view' import workbench from '@hcengineering/model-workbench' import setting from '@hcengineering/setting' import view, { type Viewlet } from '@hcengineering/view' -import notification from '@hcengineering/notification' import chunter from '@hcengineering/model-chunter' +import activity from '@hcengineering/activity' import inventory from './plugin' export { inventoryId } from '@hcengineering/inventory' @@ -79,9 +79,24 @@ export class TVariant extends TAttachedDoc implements Variant { export function createModel (builder: Builder): void { builder.createModel(TCategory, TProduct, TVariant) - builder.mixin(inventory.class.Product, core.class.Class, notification.mixin.ActivityDoc, {}) - builder.mixin(inventory.class.Category, core.class.Class, notification.mixin.ActivityDoc, {}) - builder.mixin(inventory.class.Variant, core.class.Class, notification.mixin.ActivityDoc, {}) + builder.mixin(inventory.class.Product, core.class.Class, activity.mixin.ActivityDoc, {}) + builder.mixin(inventory.class.Category, core.class.Class, activity.mixin.ActivityDoc, {}) + builder.mixin(inventory.class.Variant, core.class.Class, activity.mixin.ActivityDoc, {}) + + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: inventory.class.Product, + components: { input: chunter.component.ChatMessageInput } + }) + + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: inventory.class.Category, + components: { input: chunter.component.ChatMessageInput } + }) + + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: inventory.class.Variant, + components: { input: chunter.component.ChatMessageInput } + }) builder.mixin(inventory.class.Category, core.class.Class, view.mixin.ObjectPresenter, { presenter: inventory.component.CategoryPresenter @@ -169,7 +184,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: inventory.class.Product, @@ -179,7 +194,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: inventory.class.Category, diff --git a/models/inventory/src/plugin.ts b/models/inventory/src/plugin.ts index b98b60615b5..bc4cec433ee 100644 --- a/models/inventory/src/plugin.ts +++ b/models/inventory/src/plugin.ts @@ -14,13 +14,13 @@ // limitations under the License. // +import { type ChatMessageViewlet } from '@hcengineering/chunter' import type { Ref } from '@hcengineering/core' import { inventoryId } from '@hcengineering/inventory' import inventory from '@hcengineering/inventory-resources/src/plugin' import { type IntlString, mergeIds } from '@hcengineering/platform' import type { AnyComponent } from '@hcengineering/ui/src/types' import { type Action, type ActionCategory, type ViewAction, type Viewlet } from '@hcengineering/view' -import { type ChatMessageViewlet } from '@hcengineering/notification' export default mergeIds(inventoryId, inventory, { action: { CreateSubcategory: '' as Ref diff --git a/models/lead/package.json b/models/lead/package.json index 2e0a04a66bc..b9fbc8bab41 100644 --- a/models/lead/package.json +++ b/models/lead/package.json @@ -25,26 +25,28 @@ "prettier-plugin-svelte": "^3.1.0" }, "dependencies": { + "@hcengineering/activity": "^0.6.0", + "@hcengineering/contact": "^0.6.20", "@hcengineering/core": "^0.6.28", + "@hcengineering/lead": "^0.6.0", + "@hcengineering/chunter": "^0.6.12", + "@hcengineering/lead-resources": "^0.6.0", "@hcengineering/model": "^0.6.7", - "@hcengineering/ui": "^0.6.11", - "@hcengineering/contact": "^0.6.20", - "@hcengineering/platform": "^0.6.9", + "@hcengineering/model-attachment": "^0.6.0", + "@hcengineering/model-chunter": "^0.6.0", + "@hcengineering/model-contact": "^0.6.1", "@hcengineering/model-core": "^0.6.0", + "@hcengineering/model-notification": "^0.6.0", + "@hcengineering/model-task": "^0.6.0", + "@hcengineering/model-tracker": "^0.6.0", "@hcengineering/model-view": "^0.6.0", "@hcengineering/model-workbench": "^0.6.1", - "@hcengineering/model-contact": "^0.6.1", - "@hcengineering/model-chunter": "^0.6.0", - "@hcengineering/model-attachment": "^0.6.0", - "@hcengineering/lead": "^0.6.0", - "@hcengineering/lead-resources": "^0.6.0", + "@hcengineering/notification": "^0.6.16", + "@hcengineering/platform": "^0.6.9", "@hcengineering/setting": "^0.6.11", - "@hcengineering/view": "^0.6.9", "@hcengineering/task": "^0.6.13", - "@hcengineering/model-notification": "^0.6.0", - "@hcengineering/notification": "^0.6.16", - "@hcengineering/model-task": "^0.6.0", - "@hcengineering/workbench": "^0.6.9", - "@hcengineering/model-tracker": "^0.6.0" + "@hcengineering/ui": "^0.6.11", + "@hcengineering/view": "^0.6.9", + "@hcengineering/workbench": "^0.6.9" } } diff --git a/models/lead/src/index.ts b/models/lead/src/index.ts index 032eead78a1..f27cb85ed53 100644 --- a/models/lead/src/index.ts +++ b/models/lead/src/index.ts @@ -43,6 +43,8 @@ import workbench from '@hcengineering/model-workbench' import notification from '@hcengineering/notification' import setting from '@hcengineering/setting' import { type ViewOptionsModel } from '@hcengineering/view' +import activity from '@hcengineering/activity' + import lead from './plugin' export { leadId } from '@hcengineering/lead' @@ -59,7 +61,7 @@ export class TFunnel extends TProject implements Funnel { @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, { shortLabel: attachment.string.Files }) attachments?: number - @Prop(Collection(notification.class.ChatMessage), notification.string.Comments) + @Prop(Collection(chunter.class.ChatMessage), chunter.string.Comments) comments?: number } @@ -102,13 +104,25 @@ export function createModel (builder: Builder): void { builder.createModel(TFunnel, TLead, TCustomer) - builder.mixin(lead.class.Lead, core.class.Class, notification.mixin.ActivityDoc, { + builder.mixin(lead.class.Lead, core.class.Class, activity.mixin.ActivityDoc, { ignoreCollections: ['comments'] }) - builder.mixin(lead.mixin.Customer, core.class.Class, notification.mixin.ActivityDoc, { + + builder.mixin(lead.mixin.Customer, core.class.Class, activity.mixin.ActivityDoc, { ignoreCollections: ['comments'] }) - builder.mixin(lead.class.Funnel, core.class.Class, notification.mixin.ActivityDoc, {}) + + builder.mixin(lead.class.Funnel, core.class.Class, activity.mixin.ActivityDoc, {}) + + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: lead.class.Lead, + components: { input: chunter.component.ChatMessageInput } + }) + + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: lead.class.Funnel, + components: { input: chunter.component.ChatMessageInput } + }) builder.mixin(lead.class.Funnel, core.class.Class, workbench.mixin.SpaceView, { view: { @@ -518,7 +532,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: lead.class.Lead, diff --git a/models/lead/src/plugin.ts b/models/lead/src/plugin.ts index 3630538e04e..49ce0b10f73 100644 --- a/models/lead/src/plugin.ts +++ b/models/lead/src/plugin.ts @@ -14,10 +14,11 @@ // limitations under the License. // +import { type ChatMessageViewlet } from '@hcengineering/chunter' import type { Ref } from '@hcengineering/core' import { type Funnel, leadId } from '@hcengineering/lead' import lead from '@hcengineering/lead-resources/src/plugin' -import { type ChatMessageViewlet, type NotificationGroup, type NotificationType } from '@hcengineering/notification' +import { type NotificationGroup, type NotificationType } from '@hcengineering/notification' import type { IntlString } from '@hcengineering/platform' import { mergeIds } from '@hcengineering/platform' import { type ProjectType } from '@hcengineering/task' diff --git a/models/notification/src/activityMessages.ts b/models/notification/src/activityMessages.ts deleted file mode 100644 index a4db0abd103..00000000000 --- a/models/notification/src/activityMessages.ts +++ /dev/null @@ -1,148 +0,0 @@ -import { type Builder } from '@hcengineering/model' -import view, { createAction } from '@hcengineering/model-view' -import core from '@hcengineering/model-core' - -import notification from './plugin' - -export function buildActivityMessages (builder: Builder): void { - builder.mixin(notification.class.DocUpdateMessage, core.class.Class, notification.mixin.ActivityDoc, {}) - builder.mixin(notification.class.ChatMessage, core.class.Class, notification.mixin.ActivityDoc, {}) - - builder.mixin(notification.class.ChatMessage, core.class.Class, view.mixin.CollectionPresenter, { - presenter: notification.component.ChatMessagesPresenter - }) - - builder.mixin(notification.class.ChatMessage, core.class.Class, view.mixin.ObjectPresenter, { - presenter: notification.component.ChatMessagePresenter - }) - - builder.mixin(notification.class.DocUpdateMessage, core.class.Class, view.mixin.ObjectPresenter, { - presenter: notification.component.DocUpdateMessagePresenter - }) - - builder.createDoc( - notification.class.ActivityMessageExtension, - core.space.Model, - { - ofMessage: notification.class.DocUpdateMessage, - components: [ - { - kind: 'action', - component: notification.component.PinMessageAction - } - ] - }, - notification.ids.DocUpdateMessagePinExtension - ) - - builder.createDoc( - notification.class.ActivityMessageExtension, - core.space.Model, - { - ofMessage: notification.class.ChatMessage, - components: [ - { - kind: 'action', - component: notification.component.PinMessageAction - } - ] - }, - notification.ids.ChatMessagePinExtension - ) - - builder.createDoc( - notification.class.DocUpdateMessageViewlet, - core.space.Model, - { - objectClass: notification.mixin.Collaborators, - action: 'update', - icon: notification.icon.Notifications, - component: notification.activity.TxCollaboratorsChange, - label: notification.string.ChangeCollaborators - }, - notification.ids.NotificationCollaboratorsChanged - ) - - builder.mixin(notification.mixin.Collaborators, core.class.Class, notification.mixin.NotificationAttributePresenter, { - presenter: notification.component.NotificationCollaboratorsChanged - }) - - builder.createDoc(notification.class.ActivityMessagesFilter, core.space.Model, { - label: notification.string.Attributes, - filter: notification.filter.AttributesFilter - }) - - builder.createDoc(notification.class.ActivityMessagesFilter, core.space.Model, { - label: notification.string.Pinned, - filter: notification.filter.PinnedFilter - }) - - builder.createDoc(notification.class.ActivityMessagesFilter, core.space.Model, { - label: notification.string.Comments, - filter: notification.filter.ChatMessagesFilter - }) - - buildActions(builder) -} - -function buildActions (builder: Builder): void { - createAction( - builder, - { - action: notification.actionImpl.DeleteChatMessage, - label: view.string.Delete, - icon: view.icon.Delete, - input: 'focus', - keyBinding: ['Backspace'], - category: notification.category.Notification, - target: notification.class.ChatMessage, - context: { mode: ['context', 'browser'], group: 'edit' } - }, - notification.action.DeleteChatMessage - ) - - createAction( - builder, - { - action: notification.actionImpl.MarkAsReadInboxNotification, - label: notification.string.MarkAsRead, - icon: notification.icon.Notifications, - input: 'focus', - visibilityTester: notification.function.HasInboxNotifications, - category: notification.category.Notification, - target: notification.class.ActivityMessage, - context: { mode: 'context', application: notification.app.Notification, group: 'edit' } - }, - notification.action.MarkAsReadInboxNotification - ) - - createAction( - builder, - { - action: notification.actionImpl.MarkAsUnreadInboxNotification, - label: notification.string.MarkAsUnread, - icon: notification.icon.Track, - input: 'focus', - visibilityTester: notification.function.HasntInboxNotifications, - category: notification.category.Notification, - target: notification.class.ActivityMessage, - context: { mode: 'context', application: notification.app.Notification, group: 'edit' } - }, - notification.action.MarkAsUnreadInboxNotification - ) - - createAction( - builder, - { - action: notification.actionImpl.DeleteInboxNotification, - label: notification.string.Archive, - icon: view.icon.Archive, - input: 'focus', - keyBinding: ['Backspace'], - category: notification.category.Notification, - target: notification.class.ActivityMessage, - context: { mode: ['context', 'browser'], group: 'edit' } - }, - notification.action.DeleteInboxNotification - ) -} diff --git a/models/notification/src/index.ts b/models/notification/src/index.ts index 26a3f85439f..04439419388 100644 --- a/models/notification/src/index.ts +++ b/models/notification/src/index.ts @@ -14,7 +14,7 @@ // limitations under the License. // -import activity from '@hcengineering/activity' +import activity, { type ActivityMessage } from '@hcengineering/activity' import chunter from '@hcengineering/chunter' import { type Account, @@ -39,11 +39,9 @@ import { Mixin, Model, Prop, - TypeMarkup, TypeRef, TypeString, UX, - Collection as PropCollection, TypeBoolean, TypeDate } from '@hcengineering/model' @@ -52,16 +50,6 @@ import preference, { TPreference } from '@hcengineering/model-preference' import view, { createAction } from '@hcengineering/model-view' import workbench from '@hcengineering/model-workbench' import { - type ActivityMessage, - type ActivityMessageExtension, - type ActivityMessageExtensionKind, - type ChatMessage, - type ChatMessageViewlet, - type DocUpdateAction, - type DocAttributeUpdates, - type DocUpdateMessage, - type DocUpdateMessageViewlet, - type DocUpdateMessageViewletAttributesConfig, type DocUpdates, type DocUpdateTx, inboxId, @@ -69,7 +57,6 @@ import { type DocNotifyContext, type Notification, type NotificationGroup, - type NotificationObjectPresenter, type NotificationPreferencesGroup, type NotificationPreview, type NotificationProvider, @@ -77,19 +64,14 @@ import { type NotificationStatus, type NotificationTemplate, type NotificationType, - type ActivityMessagesFilter, - type ActivityDoc, - type NotificationObjectPreposition, - notificationId + notificationId, + type NotificationObjectPresenter } from '@hcengineering/notification' -import { type Asset, type IntlString, type Resource } from '@hcengineering/platform' +import { type Asset, type IntlString } from '@hcengineering/platform' import setting from '@hcengineering/setting' import { type AnyComponent } from '@hcengineering/ui/src/types' -import attachment from '@hcengineering/model-attachment' -import { type NotificationAttributePresenter } from '@hcengineering/view' import notification from './plugin' -import { buildActivityMessages } from './activityMessages' export { notificationId } from '@hcengineering/notification' export { notificationOperation } from './migration' @@ -174,21 +156,6 @@ export class TNotificationPreview extends TClass implements NotificationPreview presenter!: AnyComponent } -@Mixin(notification.mixin.ActivityDoc, core.class.Class) -export class TActivityDoc extends TClass implements ActivityDoc { - ignoreCollections?: string[] -} - -@Mixin(notification.mixin.NotificationObjectPreposition, core.class.Class) -export class TNotificationObjectPreposition extends TClass implements NotificationObjectPreposition { - preposition!: IntlString -} - -@Mixin(notification.mixin.NotificationAttributePresenter, core.class.Class) -export class TNotificationAttributePresenter extends TClass implements NotificationAttributePresenter { - presenter!: AnyComponent -} - @Model(notification.class.DocUpdates, core.class.Doc, DOMAIN_NOTIFICATION) export class TDocUpdates extends TDoc implements DocUpdates { @Index(IndexKind.Indexed) @@ -232,58 +199,13 @@ export class TDocNotifyContext extends TDoc implements DocNotifyContext { lastUpdateTimestamp?: Timestamp } -@Model(notification.class.ActivityMessage, core.class.AttachedDoc, DOMAIN_NOTIFICATION) -export class TActivityMessage extends TAttachedDoc implements ActivityMessage { - @Prop(TypeBoolean(), notification.string.Pinned) - @Index(IndexKind.Indexed) - isPinned?: boolean - - @Prop(PropCollection(chunter.class.Reaction), chunter.string.Reactions) - reactions?: number -} - -@Model(notification.class.DocUpdateMessage, notification.class.ActivityMessage, DOMAIN_NOTIFICATION) -export class TDocUpdateMessage extends TActivityMessage implements DocUpdateMessage { - @Prop(TypeRef(core.class.Doc), core.string.Object) - @Index(IndexKind.Indexed) - objectId!: Ref - - @Prop(TypeRef(core.class.Class), core.string.Class) - @Index(IndexKind.Indexed) - objectClass!: Ref> - - @Prop(TypeRef(core.class.TxCUD), core.string.Object) - @Index(IndexKind.Indexed) - txId!: Ref> - - action!: DocUpdateAction - updateCollection?: string - attributeUpdates?: DocAttributeUpdates -} - -@Model(notification.class.ChatMessage, notification.class.ActivityMessage, DOMAIN_NOTIFICATION) -export class TChatMessage extends TActivityMessage implements ChatMessage { - @Prop(TypeMarkup(), chunter.string.Message) - @Index(IndexKind.FullText) - message!: string - - @Prop(PropCollection(attachment.class.Attachment), attachment.string.Attachments, { - shortLabel: attachment.string.Files - }) - attachments?: number - - @Prop(TypeBoolean(), core.string.Boolean) - @Index(IndexKind.Indexed) - isEdited?: boolean -} - @Model(notification.class.InboxNotification, core.class.Doc, DOMAIN_NOTIFICATION) export class TInboxNotification extends TDoc implements InboxNotification { - @Prop(TypeRef(notification.class.ActivityMessage), core.string.AttachedTo) + @Prop(TypeRef(activity.class.ActivityMessage), core.string.AttachedTo) @Index(IndexKind.Indexed) attachedTo!: Ref - @Prop(TypeRef(notification.class.ActivityMessage), core.string.AttachedToClass) + @Prop(TypeRef(activity.class.ActivityMessage), core.string.AttachedToClass) @Index(IndexKind.Indexed) attachedToClass!: Ref> @@ -300,54 +222,6 @@ export class TInboxNotification extends TDoc implements InboxNotification { isViewed!: boolean } -@Model(notification.class.DocUpdateMessageViewlet, core.class.Doc, DOMAIN_MODEL) -export class TDocUpdateMessageViewlet extends TDoc implements DocUpdateMessageViewlet { - @Prop(TypeRef(core.class.Doc), core.string.Class) - @Index(IndexKind.Indexed) - objectClass!: Ref> - - @Prop(TypeString(), core.string.String) - @Index(IndexKind.Indexed) - action!: DocUpdateAction - - label?: IntlString - labelComponent?: AnyComponent - - valueAttr?: string - - icon?: Asset - component?: AnyComponent - config?: DocUpdateMessageViewletAttributesConfig - hideIfRemoved?: boolean - onlyWithParent?: boolean -} - -@Model(notification.class.ChatMessageViewlet, core.class.Doc, DOMAIN_MODEL) -export class TChatMessageViewlet extends TDoc implements ChatMessageViewlet { - @Prop(TypeRef(core.class.Doc), core.string.Class) - @Index(IndexKind.Indexed) - objectClass!: Ref> - - label?: IntlString - hidden?: boolean - onlyWithParent?: boolean -} - -@Model(notification.class.ActivityMessageExtension, core.class.Doc, DOMAIN_MODEL) -export class TActivityMessageExtension extends TDoc implements ActivityMessageExtension { - @Prop(TypeRef(notification.class.ActivityMessage), core.string.Class) - @Index(IndexKind.Indexed) - ofMessage!: Ref> - - components!: { kind: ActivityMessageExtensionKind, component: AnyComponent }[] -} - -@Model(notification.class.ActivityMessagesFilter, core.class.Doc, DOMAIN_MODEL) -export class TActivityMessagesFilter extends TDoc implements ActivityMessagesFilter { - label!: IntlString - filter!: Resource<(message: ActivityMessage, _class?: Ref) => boolean> -} - export function createModel (builder: Builder): void { builder.createModel( TNotification, @@ -362,17 +236,7 @@ export function createModel (builder: Builder): void { TNotificationObjectPresenter, TNotificationPreview, TDocNotifyContext, - TDocUpdateMessage, - TChatMessage, - TActivityMessage, - TInboxNotification, - TDocUpdateMessageViewlet, - TActivityMessageExtension, - TChatMessageViewlet, - TActivityMessagesFilter, - TActivityDoc, - TNotificationObjectPreposition, - TNotificationAttributePresenter + TInboxNotification ) // Temporarily disabled, we should think about it @@ -449,21 +313,21 @@ export function createModel (builder: Builder): void { { id: 'all', component: notification.component.NewInbox, - icon: notification.icon.Activity, - label: notification.string.AllActivity, + icon: activity.icon.Activity, + label: activity.string.AllActivity, componentProps: { type: 'all', - label: notification.string.AllActivity + label: activity.string.AllActivity } }, { id: 'reactions', component: notification.component.NewInbox, - icon: notification.icon.Emoji, - label: notification.string.Reactions, + icon: activity.icon.Emoji, + label: activity.string.Reactions, componentProps: { - _class: chunter.class.Reaction, - label: notification.string.Reactions + _class: activity.class.Reaction, + label: activity.string.Reactions } } ] @@ -597,7 +461,67 @@ export function createModel (builder: Builder): void { notification.ids.TxDmCreation ) - buildActivityMessages(builder) + builder.createDoc( + activity.class.DocUpdateMessageViewlet, + core.space.Model, + { + objectClass: notification.mixin.Collaborators, + action: 'update', + icon: notification.icon.Notifications, + component: notification.activity.TxCollaboratorsChange, + label: notification.string.ChangeCollaborators + }, + notification.ids.NotificationCollaboratorsChanged + ) + + builder.mixin(notification.mixin.Collaborators, core.class.Class, view.mixin.ActivityAttributePresenter, { + presenter: notification.component.NotificationCollaboratorsChanged + }) + + createAction( + builder, + { + action: notification.actionImpl.MarkAsReadInboxNotification, + label: notification.string.MarkAsRead, + icon: notification.icon.Notifications, + input: 'focus', + visibilityTester: notification.function.HasInboxNotifications, + category: notification.category.Notification, + target: activity.class.ActivityMessage, + context: { mode: 'context', application: notification.app.Notification, group: 'edit' } + }, + notification.action.MarkAsReadInboxNotification + ) + + createAction( + builder, + { + action: notification.actionImpl.MarkAsUnreadInboxNotification, + label: notification.string.MarkAsUnread, + icon: notification.icon.Track, + input: 'focus', + visibilityTester: notification.function.HasntInboxNotifications, + category: notification.category.Notification, + target: activity.class.ActivityMessage, + context: { mode: 'context', application: notification.app.Notification, group: 'edit' } + }, + notification.action.MarkAsUnreadInboxNotification + ) + + createAction( + builder, + { + action: notification.actionImpl.DeleteInboxNotification, + label: notification.string.Archive, + icon: view.icon.Archive, + input: 'focus', + keyBinding: ['Backspace'], + category: notification.category.Notification, + target: activity.class.ActivityMessage, + context: { mode: ['context', 'browser'], group: 'edit' } + }, + notification.action.DeleteInboxNotification + ) } export function generateClassNotificationTypes ( diff --git a/models/notification/src/plugin.ts b/models/notification/src/plugin.ts index 37dcd9e6b02..d78123d83b7 100644 --- a/models/notification/src/plugin.ts +++ b/models/notification/src/plugin.ts @@ -15,16 +15,12 @@ // import { type Doc, type Ref } from '@hcengineering/core' -import notification, { - type ActivityMessageExtension, - type DocUpdateMessageViewlet, - notificationId -} from '@hcengineering/notification' +import notification, { notificationId } from '@hcengineering/notification' import { type IntlString, type Resource, mergeIds } from '@hcengineering/platform' import { type AnyComponent } from '@hcengineering/ui/src/types' import { type Action, type ActionCategory, type ViewAction } from '@hcengineering/view' import { type Application } from '@hcengineering/workbench' -import { type TxViewlet } from '@hcengineering/activity' +import { type DocUpdateMessageViewlet, type TxViewlet } from '@hcengineering/activity' export default mergeIds(notificationId, notification, { string: { @@ -35,11 +31,7 @@ export default mergeIds(notificationId, notification, { Archive: '' as IntlString, MarkAsUnread: '' as IntlString, MarkAsRead: '' as IntlString, - ChangeCollaborators: '' as IntlString, - AllActivity: '' as IntlString, - Threads: '' as IntlString, - Mentions: '' as IntlString, - Reactions: '' as IntlString + ChangeCollaborators: '' as IntlString }, app: { Notification: '' as Ref, @@ -51,9 +43,7 @@ export default mergeIds(notificationId, notification, { ids: { TxCollaboratorsChange: '' as Ref, TxDmCreation: '' as Ref, - NotificationCollaboratorsChanged: '' as Ref, - DocUpdateMessagePinExtension: '' as Ref, - ChatMessagePinExtension: '' as Ref + NotificationCollaboratorsChanged: '' as Ref }, component: { NotificationSettings: '' as AnyComponent, @@ -82,7 +72,6 @@ export default mergeIds(notificationId, notification, { MarkAsUnread: '' as ViewAction, MarkAsUnreadInboxNotification: '' as ViewAction, MarkAsReadInboxNotification: '' as ViewAction, - DeleteInboxNotification: '' as ViewAction, - DeleteChatMessage: '' as ViewAction + DeleteInboxNotification: '' as ViewAction } }) diff --git a/models/recruit/package.json b/models/recruit/package.json index 76b224dce0e..76e40529ccd 100644 --- a/models/recruit/package.json +++ b/models/recruit/package.json @@ -26,6 +26,8 @@ }, "dependencies": { "@anticrm/skillset": "^0.6.0", + "@hcengineering/activity": "^0.6.0", + "@hcengineering/chunter": "^0.6.12", "@hcengineering/contact": "^0.6.20", "@hcengineering/core": "^0.6.28", "@hcengineering/model": "^0.6.7", diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index a6a42a3f326..8e3fe4a3570 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -56,6 +56,7 @@ import { } from '@hcengineering/recruit' import setting from '@hcengineering/setting' import { type KeyBinding, type ViewOptionModel, type ViewOptionsModel } from '@hcengineering/view' +import activity from '@hcengineering/activity' import recruit from './plugin' import { createReviewModel, reviewTableConfig, reviewTableOptions } from './review' @@ -85,7 +86,7 @@ export class TVacancy extends TProject implements Vacancy { @Prop(TypeRef(contact.class.Organization), recruit.string.Company, { icon: contact.icon.Company }) company?: Ref - @Prop(Collection(notification.class.ChatMessage), notification.string.Comments) + @Prop(Collection(chunter.class.ChatMessage), chunter.string.Comments) comments?: number @Prop(TypeString(), recruit.string.Vacancy) @@ -197,18 +198,33 @@ export class TApplicantMatch extends TAttachedDoc implements ApplicantMatch { export function createModel (builder: Builder): void { builder.createModel(TVacancy, TCandidates, TCandidate, TApplicant, TReview, TOpinion, TVacancyList, TApplicantMatch) - builder.mixin(recruit.class.Vacancy, core.class.Class, notification.mixin.ActivityDoc, { + builder.mixin(recruit.class.Vacancy, core.class.Class, activity.mixin.ActivityDoc, { ignoreCollections: ['comments'] }) - builder.mixin(recruit.class.Applicant, core.class.Class, notification.mixin.ActivityDoc, { + builder.mixin(recruit.class.Applicant, core.class.Class, activity.mixin.ActivityDoc, { ignoreCollections: ['comments'] }) - builder.mixin(recruit.class.Review, core.class.Class, notification.mixin.ActivityDoc, {}) + builder.mixin(recruit.class.Review, core.class.Class, activity.mixin.ActivityDoc, {}) - builder.mixin(recruit.mixin.Candidate, core.class.Class, notification.mixin.ActivityDoc, { + builder.mixin(recruit.mixin.Candidate, core.class.Class, activity.mixin.ActivityDoc, { ignoreCollections: ['comments'] }) + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: recruit.class.Vacancy, + components: { input: chunter.component.ChatMessageInput } + }) + + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: recruit.class.Applicant, + components: { input: chunter.component.ChatMessageInput } + }) + + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: recruit.class.Review, + components: { input: chunter.component.ChatMessageInput } + }) + builder.mixin(recruit.class.Vacancy, core.class.Class, workbench.mixin.SpaceView, { view: { class: recruit.class.Applicant, @@ -1585,7 +1601,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: recruit.class.Vacancy, @@ -1595,7 +1611,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: recruit.class.Applicant, @@ -1605,7 +1621,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: recruit.class.Review, @@ -1625,7 +1641,7 @@ export function createModel (builder: Builder): void { propagate: [recruit.class.Applicant], propagateClasses: [ tags.class.TagReference, - notification.class.ChatMessage, + chunter.class.ChatMessage, attachment.class.Attachment, contact.class.Channel ] @@ -1679,7 +1695,7 @@ export function createModel (builder: Builder): void { }) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: recruit.class.Applicant, @@ -1690,7 +1706,7 @@ export function createModel (builder: Builder): void { } } }, - recruit.ids.NotificationApplicantUpdated + recruit.ids.ApplicantUpdatedActivityViewlet ) createAction( diff --git a/models/recruit/src/plugin.ts b/models/recruit/src/plugin.ts index c37ae8f61fb..94791c3762f 100644 --- a/models/recruit/src/plugin.ts +++ b/models/recruit/src/plugin.ts @@ -14,12 +14,7 @@ // import type { Client, Doc, Ref } from '@hcengineering/core' -import { - type ChatMessageViewlet, - type DocUpdateMessageViewlet, - type NotificationGroup, - type NotificationType -} from '@hcengineering/notification' +import { type NotificationGroup, type NotificationType } from '@hcengineering/notification' import type { IntlString, Resource, Status } from '@hcengineering/platform' import { mergeIds } from '@hcengineering/platform' import { recruitId } from '@hcengineering/recruit' @@ -27,6 +22,8 @@ import recruit from '@hcengineering/recruit-resources/src/plugin' import { type ProjectType } from '@hcengineering/task' import type { AnyComponent, Location } from '@hcengineering/ui/src/types' import type { Action, ActionCategory, ViewAction, ViewQueryAction, Viewlet } from '@hcengineering/view' +import { type DocUpdateMessageViewlet } from '@hcengineering/activity' +import { type ChatMessageViewlet } from '@hcengineering/chunter' export default mergeIds(recruitId, recruit, { action: { @@ -88,7 +85,7 @@ export default mergeIds(recruitId, recruit, { AssigneeNotification: '' as Ref, ApplicationCreateNotification: '' as Ref, ReviewCreateNotification: '' as Ref, - NotificationApplicantUpdated: '' as Ref, + ApplicantUpdatedActivityViewlet: '' as Ref, ApplicantChatMessageViewlet: '' as Ref, VacancyChatMessageViewlet: '' as Ref, ReviewChatMessageViewlet: '' as Ref diff --git a/models/recruit/src/review-model.ts b/models/recruit/src/review-model.ts index b640315f44a..5941c21158e 100644 --- a/models/recruit/src/review-model.ts +++ b/models/recruit/src/review-model.ts @@ -7,8 +7,9 @@ import contact from '@hcengineering/model-contact' import core, { TAttachedDoc } from '@hcengineering/model-core' import task from '@hcengineering/model-task' import { type Applicant, type Candidate, type Opinion, type Review } from '@hcengineering/recruit' +import chunter from '@hcengineering/model-chunter' + import recruit from './plugin' -import notification from '@hcengineering/notification' @Model(recruit.class.Review, calendar.class.Event) @UX(recruit.string.Review, recruit.icon.Review, 'RVE', 'number') @@ -47,7 +48,7 @@ export class TOpinion extends TAttachedDoc implements Opinion { @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, { shortLabel: attachment.string.Files }) attachments?: number - @Prop(Collection(notification.class.ChatMessage), notification.string.Comments) + @Prop(Collection(chunter.class.ChatMessage), chunter.string.Comments) comments?: number @Prop(TypeMarkup(), recruit.string.Description) diff --git a/models/request/src/index.ts b/models/request/src/index.ts index 1e7fd89d3f6..61bccac5c69 100644 --- a/models/request/src/index.ts +++ b/models/request/src/index.ts @@ -30,7 +30,7 @@ import { TypeString, UX } from '@hcengineering/model' -import { TComment } from '@hcengineering/model-chunter' +import chunter, { TComment } from '@hcengineering/model-chunter' import core, { TAttachedDoc, TClass } from '@hcengineering/model-core' import { generateClassNotificationTypes } from '@hcengineering/model-notification' import view from '@hcengineering/model-view' @@ -72,11 +72,11 @@ export class TRequest extends TAttachedDoc implements Request { @ReadOnly() rejected?: Ref - @Prop(Collection(notification.class.ChatMessage), notification.string.Comments) + @Prop(Collection(chunter.class.ChatMessage), chunter.string.Comments) comments?: number } -@Mixin(request.mixin.RequestDecisionComment, notification.class.ChatMessage) +@Mixin(request.mixin.RequestDecisionComment, chunter.class.ChatMessage) export class TRequestDecisionComment extends TComment implements RequestDecisionComment {} @Mixin(request.mixin.RequestPresenter, core.class.Class) diff --git a/models/server-chunter/src/index.ts b/models/server-chunter/src/index.ts index b5d14d09d00..299a747d702 100644 --- a/models/server-chunter/src/index.ts +++ b/models/server-chunter/src/index.ts @@ -33,7 +33,7 @@ export function createModel (builder: Builder): void { }) builder.mixin, ObjectDDParticipant>( - notification.class.ChatMessage, + chunter.class.ChatMessage, core.class.Class, serverCore.mixin.ObjectDDParticipant, { diff --git a/models/server-notification/package.json b/models/server-notification/package.json index 56ea5b141dc..6da58ee942b 100644 --- a/models/server-notification/package.json +++ b/models/server-notification/package.json @@ -25,8 +25,10 @@ "prettier-plugin-svelte": "^3.1.0" }, "dependencies": { + "@hcengineering/activity": "^0.6.0", "@hcengineering/core": "^0.6.28", "@hcengineering/model": "^0.6.7", + "@hcengineering/model-chunter": "^0.6.0", "@hcengineering/model-core": "^0.6.0", "@hcengineering/model-notification": "^0.6.0", "@hcengineering/notification": "^0.6.16", diff --git a/models/server-notification/src/index.ts b/models/server-notification/src/index.ts index 509b4765252..42c3ab8531b 100644 --- a/models/server-notification/src/index.ts +++ b/models/server-notification/src/index.ts @@ -30,6 +30,7 @@ import serverNotification, { type TypeMatch, type NotificationContentProvider } from '@hcengineering/server-notification' +import chunter from '@hcengineering/model-chunter' export { serverNotificationId } from '@hcengineering/server-notification' export { notificationServerOperation } from './migration' @@ -68,7 +69,7 @@ export function createModel (builder: Builder): void { // trigger: serverNotification.trigger.OnReactionChanged, // txMatch: { // collection: 'reactions', - // objectClass: notification.class.ActivityMessage, + // objectClass: activity.class.ActivityMessage, // _class: core.class.TxCollectionCUD // } // }) @@ -80,7 +81,7 @@ export function createModel (builder: Builder): void { builder.createDoc(serverCore.class.Trigger, core.space.Model, { trigger: serverNotification.trigger.OnChatMessageSent, txMatch: { - objectClass: notification.class.ChatMessage + objectClass: chunter.class.ChatMessage } }) diff --git a/models/server-notification/src/migration.ts b/models/server-notification/src/migration.ts index 907e1320023..f587c2cd0e3 100644 --- a/models/server-notification/src/migration.ts +++ b/models/server-notification/src/migration.ts @@ -13,24 +13,25 @@ // limitations under the License. // -import core, { - SortingOrder, +import { TxFactory, toFindResult, - toIdMap, - type AttachedDoc, - type Class, + type TxCUD, type Doc, + type TxCreateDoc, + SortingOrder, + TxProcessor, type Ref, - type TxCUD, + toIdMap, type TxCollectionCUD, - type TxCreateDoc, - TxProcessor + type AttachedDoc, + type Class } from '@hcengineering/core' import { type MigrateOperation, type MigrationClient, type MigrationIterator, tryMigrate } from '@hcengineering/model' -import notification, { type DocUpdateMessage } from '@hcengineering/notification' -import { getAllObjectTransactions, type DocObjectCache, serverNotificationId } from '@hcengineering/server-notification' -import { generateDocUpdateMessages, type NotificationControl } from '@hcengineering/server-notification-resources' +import core from '@hcengineering/model-core' +import { type DocObjectCache, getAllObjectTransactions, serverNotificationId } from '@hcengineering/server-notification' +import { type NotificationControl, generateDocUpdateMessages } from '@hcengineering/server-notification-resources' +import activity, { type DocUpdateMessage } from '@hcengineering/activity' function getNotificationControl (client: MigrationClient): NotificationControl { const txFactory = new TxFactory(core.account.System, false) @@ -70,10 +71,10 @@ async function generateDocUpdateMessageByTx ( } async function createDocUpdateMessages (client: MigrationClient): Promise { - const activityDocs = await client.model.findAll(notification.mixin.ActivityDoc, { - _id: { $nin: [notification.class.DocUpdateMessage, notification.class.ChatMessage] } - }) - const activityDocClasses = activityDocs.map(({ _id }) => _id) + const activityDocs = await client.model.findAll(activity.mixin.ActivityDoc, {}) + const activityDocClasses = activityDocs + .map(({ _id }) => _id) + .filter((_class) => !client.hierarchy.isDerived(_class, activity.class.ActivityMessage)) const notificationControl = getNotificationControl(client) diff --git a/models/server-openai/package.json b/models/server-openai/package.json index 9296ed6fb22..1f2bb6cbb1e 100644 --- a/models/server-openai/package.json +++ b/models/server-openai/package.json @@ -27,9 +27,9 @@ "dependencies": { "@hcengineering/core": "^0.6.28", "@hcengineering/model": "^0.6.7", + "@hcengineering/model-chunter": "^0.6.0", "@hcengineering/model-core": "^0.6.0", "@hcengineering/model-recruit": "^0.6.0", - "@hcengineering/notification": "^0.6.16", "@hcengineering/openai": "^0.6.0", "@hcengineering/platform": "^0.6.9", "@hcengineering/server-core": "^0.6.1" diff --git a/models/server-openai/src/index.ts b/models/server-openai/src/index.ts index be700f43acc..7a08959f136 100644 --- a/models/server-openai/src/index.ts +++ b/models/server-openai/src/index.ts @@ -23,7 +23,7 @@ import openai, { type OpenAIConfiguration } from '@hcengineering/openai/src/plug import serverCore from '@hcengineering/server-core' import recruit from '@hcengineering/model-recruit' -import notification from '@hcengineering/notification' +import chunter from '@hcengineering/model-chunter' export { openAIId } from '@hcengineering/openai/src/plugin' @@ -49,7 +49,7 @@ export function createModel (builder: Builder): void { builder.createDoc(serverCore.class.Trigger, core.space.Model, { trigger: openai.trigger.AsyncOnGPTRequest, txMatch: { - objectClass: { $in: [notification.class.ChatMessage, recruit.class.ApplicantMatch] }, + objectClass: { $in: [chunter.class.ChatMessage, recruit.class.ApplicantMatch] }, _class: core.class.TxCreateDoc } }) diff --git a/models/setting/src/index.ts b/models/setting/src/index.ts index 6f14c78fb28..f16cbfe21dc 100644 --- a/models/setting/src/index.ts +++ b/models/setting/src/index.ts @@ -329,7 +329,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: setting.class.Integration, @@ -338,7 +338,7 @@ export function createModel (builder: Builder): void { action: 'update', hideIfRemoved: true }, - setting.ids.UpdateIntegrationNotificationViewlet + setting.ids.UpdateIntegrationActivityViewlet ) builder.mixin(core.class.TypeString, core.class.Class, view.mixin.ObjectEditor, { diff --git a/models/setting/src/plugin.ts b/models/setting/src/plugin.ts index 41729dc3018..ccaa9cb3392 100644 --- a/models/setting/src/plugin.ts +++ b/models/setting/src/plugin.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import type { TxViewlet } from '@hcengineering/activity' +import type { DocUpdateMessageViewlet, TxViewlet } from '@hcengineering/activity' import { type Doc, type Ref } from '@hcengineering/core' import { type IntlString, mergeIds, type Resource } from '@hcengineering/platform' import { settingId } from '@hcengineering/setting' @@ -21,11 +21,7 @@ import setting from '@hcengineering/setting-resources/src/plugin' import { type AnyComponent } from '@hcengineering/ui/src/types' import { type Action, type ActionCategory, type ViewAction } from '@hcengineering/view' import { type TemplateFieldFunc } from '@hcengineering/templates' -import { - type DocUpdateMessageViewlet, - type NotificationGroup, - type NotificationType -} from '@hcengineering/notification' +import { type NotificationGroup, type NotificationType } from '@hcengineering/notification' export default mergeIds(settingId, setting, { activity: { @@ -37,7 +33,7 @@ export default mergeIds(settingId, setting, { Configure: '' as Ref, SettingNotificationGroup: '' as Ref, IntegrationDisabledNotification: '' as Ref, - UpdateIntegrationNotificationViewlet: '' as Ref + UpdateIntegrationActivityViewlet: '' as Ref }, component: { EnumSetting: '' as AnyComponent, diff --git a/models/task/package.json b/models/task/package.json index 038f029eae2..cddd74705b3 100644 --- a/models/task/package.json +++ b/models/task/package.json @@ -29,13 +29,13 @@ "@hcengineering/core": "^0.6.28", "@hcengineering/model": "^0.6.7", "@hcengineering/model-attachment": "^0.6.0", + "@hcengineering/model-chunter": "^0.6.0", "@hcengineering/model-contact": "^0.6.1", "@hcengineering/model-core": "^0.6.0", "@hcengineering/model-presentation": "^0.6.0", "@hcengineering/model-tags": "^0.6.0", "@hcengineering/model-view": "^0.6.0", "@hcengineering/model-workbench": "^0.6.1", - "@hcengineering/notification": "^0.6.16", "@hcengineering/platform": "^0.6.9", "@hcengineering/tags": "^0.6.12", "@hcengineering/task": "^0.6.13", diff --git a/models/task/src/index.ts b/models/task/src/index.ts index db5224f70c2..d65735874bd 100644 --- a/models/task/src/index.ts +++ b/models/task/src/index.ts @@ -59,8 +59,9 @@ import { } from '@hcengineering/task' import type { AnyComponent } from '@hcengineering/ui/src/types' import { type ViewAction } from '@hcengineering/view' +import chunter from '@hcengineering/model-chunter' + import task from './plugin' -import notification from '@hcengineering/notification' export { taskId } from '@hcengineering/task' export { createProjectType, createSequence, taskOperation } from './migration' @@ -95,7 +96,7 @@ export class TTask extends TAttachedDoc implements Task { @Prop(Collection(tags.class.TagReference, task.string.TaskLabels), task.string.TaskLabels) labels?: number - @Prop(Collection(notification.class.ChatMessage), notification.string.Comments) + @Prop(Collection(chunter.class.ChatMessage), chunter.string.Comments) comments?: number @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, { shortLabel: attachment.string.Files }) diff --git a/models/task/src/plugin.ts b/models/task/src/plugin.ts index 5a5a5e673cc..a8d397cd886 100644 --- a/models/task/src/plugin.ts +++ b/models/task/src/plugin.ts @@ -21,7 +21,6 @@ import { taskId } from '@hcengineering/task' import task from '@hcengineering/task-resources/src/plugin' import type { AnyComponent } from '@hcengineering/ui/src/types' import type { Action, ActionCategory, ViewAction, Viewlet } from '@hcengineering/view' -import {} from '@hcengineering/notification' export default mergeIds(taskId, task, { action: { diff --git a/models/telegram/src/index.ts b/models/telegram/src/index.ts index 0bef9cb66f7..0271ba1d8fb 100644 --- a/models/telegram/src/index.ts +++ b/models/telegram/src/index.ts @@ -134,7 +134,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: telegram.class.Message, @@ -143,7 +143,7 @@ export function createModel (builder: Builder): void { component: telegram.notification.NotificationMessageCreated, label: telegram.string.SharedMessages }, - telegram.ids.NotificationMessageCreated + telegram.ids.TelegramMessageCreatedActivityViewlet ) builder.createDoc( @@ -191,7 +191,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: telegram.class.SharedMessages, @@ -201,7 +201,7 @@ export function createModel (builder: Builder): void { label: telegram.string.SharedMessages, hideIfRemoved: true }, - telegram.ids.NotificationMessageShared + telegram.ids.TelegramMessageSharedActivityViewlet ) builder.createDoc( diff --git a/models/telegram/src/plugin.ts b/models/telegram/src/plugin.ts index 6bc7985776c..9d6229c3ac9 100644 --- a/models/telegram/src/plugin.ts +++ b/models/telegram/src/plugin.ts @@ -19,9 +19,9 @@ import { type IntlString, type Resource, mergeIds } from '@hcengineering/platfor import { telegramId } from '@hcengineering/telegram' import telegram from '@hcengineering/telegram-resources/src/plugin' import type { AnyComponent } from '@hcengineering/ui/src/types' -import type { TxViewlet } from '@hcengineering/activity' +import type { DocUpdateMessageViewlet, TxViewlet } from '@hcengineering/activity' import { type TemplateFieldFunc } from '@hcengineering/templates' -import { type DocUpdateMessageViewlet, type NotificationGroup } from '@hcengineering/notification' +import { type NotificationGroup } from '@hcengineering/notification' export default mergeIds(telegramId, telegram, { string: { @@ -43,8 +43,8 @@ export default mergeIds(telegramId, telegram, { TxSharedCreate: '' as Ref, NewMessageNotificationViewlet: '' as Ref, NotificationGroup: '' as Ref, - NotificationMessageShared: '' as Ref, - NotificationMessageCreated: '' as Ref + TelegramMessageSharedActivityViewlet: '' as Ref, + TelegramMessageCreatedActivityViewlet: '' as Ref }, function: { GetCurrentEmployeeTG: '' as Resource, diff --git a/models/tracker/package.json b/models/tracker/package.json index ca89a082f5e..0b1e224091e 100644 --- a/models/tracker/package.json +++ b/models/tracker/package.json @@ -26,6 +26,7 @@ }, "dependencies": { "@hcengineering/activity": "^0.6.0", + "@hcengineering/chunter": "^0.6.12", "@hcengineering/contact": "^0.6.20", "@hcengineering/core": "^0.6.28", "@hcengineering/model": "^0.6.7", diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index d8d3566e61c..3c940108078 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -22,11 +22,12 @@ import workbench from '@hcengineering/model-workbench' import notification from '@hcengineering/notification' import setting from '@hcengineering/setting' import { trackerId } from '@hcengineering/tracker' -import tracker from './plugin' - import { generateClassNotificationTypes } from '@hcengineering/model-notification' import presentation from '@hcengineering/model-presentation' import { PaletteColorIndexes } from '@hcengineering/ui/src/colors' +import chunter from '@hcengineering/chunter' + +import tracker from './plugin' import { createActions as defineActions } from './actions' import { definePresenters } from './presenters' import { @@ -445,20 +446,40 @@ export function createModel (builder: Builder): void { TTypeRemainingTime ) - builder.mixin(tracker.class.Project, core.class.Class, notification.mixin.ActivityDoc, {}) - builder.mixin(tracker.class.Issue, core.class.Class, notification.mixin.ActivityDoc, { + builder.mixin(tracker.class.Project, core.class.Class, activity.mixin.ActivityDoc, {}) + builder.mixin(tracker.class.Issue, core.class.Class, activity.mixin.ActivityDoc, { ignoreCollections: ['comments'] }) - builder.mixin(tracker.class.Milestone, core.class.Class, notification.mixin.ActivityDoc, { + builder.mixin(tracker.class.Milestone, core.class.Class, activity.mixin.ActivityDoc, { ignoreCollections: ['comments'] }) - builder.mixin(tracker.class.Component, core.class.Class, notification.mixin.ActivityDoc, { + builder.mixin(tracker.class.Component, core.class.Class, activity.mixin.ActivityDoc, { ignoreCollections: ['comments'] }) - builder.mixin(tracker.class.IssueTemplate, core.class.Class, notification.mixin.ActivityDoc, { + builder.mixin(tracker.class.IssueTemplate, core.class.Class, activity.mixin.ActivityDoc, { ignoreCollections: ['comments'] }) + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: tracker.class.Issue, + components: { input: chunter.component.ChatMessageInput } + }) + + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: tracker.class.Milestone, + components: { input: chunter.component.ChatMessageInput } + }) + + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: tracker.class.Component, + components: { input: chunter.component.ChatMessageInput } + }) + + builder.createDoc(activity.class.ActivityExtension, core.space.Model, { + ofClass: tracker.class.IssueTemplate, + components: { input: chunter.component.ChatMessageInput } + }) + defineViewlets(builder) defineStatusCategories(builder) @@ -517,7 +538,7 @@ export function createModel (builder: Builder): void { ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: tracker.class.Issue, @@ -535,11 +556,11 @@ export function createModel (builder: Builder): void { } } }, - tracker.ids.NotificationIssueUpdated + tracker.ids.IssueUpdatedActivityViewlet ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: tracker.class.Issue, @@ -547,11 +568,11 @@ export function createModel (builder: Builder): void { icon: tracker.icon.Issue, valueAttr: 'title' }, - tracker.ids.NotificationIssueCreated + tracker.ids.IssueCreatedActivityViewlet ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: tracker.class.Issue, @@ -559,11 +580,11 @@ export function createModel (builder: Builder): void { icon: tracker.icon.Issue, valueAttr: 'title' }, - tracker.ids.NotificationIssueRemoved + tracker.ids.IssueRemovedActivityViewlet ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: tracker.class.Milestone, @@ -574,11 +595,11 @@ export function createModel (builder: Builder): void { } } }, - tracker.ids.NotificationMilestoneUpdated + tracker.ids.MilestionUpdatedActivityViewlet ) builder.createDoc( - notification.class.DocUpdateMessageViewlet, + activity.class.DocUpdateMessageViewlet, core.space.Model, { objectClass: tracker.class.IssueTemplate, @@ -589,7 +610,7 @@ export function createModel (builder: Builder): void { } } }, - tracker.ids.NotificationIssueTemplateUpdated + tracker.ids.IssueTemplateUpdatedActivityViewlet ) defineApplication(builder, { myIssuesId, allIssuesId, issuesId, componentsId, milestonesId, templatesId }) @@ -625,41 +646,41 @@ export function createModel (builder: Builder): void { }) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: tracker.class.Issue, - label: notification.string.LeftComment + label: chunter.string.LeftComment }, tracker.ids.IssueChatMessageViewlet ) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: tracker.class.IssueTemplate, - label: notification.string.LeftComment + label: chunter.string.LeftComment }, tracker.ids.IssueTemplateChatMessageViewlet ) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: tracker.class.Component, - label: notification.string.LeftComment + label: chunter.string.LeftComment }, tracker.ids.ComponentChatMessageViewlet ) builder.createDoc( - notification.class.ChatMessageViewlet, + chunter.class.ChatMessageViewlet, core.space.Model, { objectClass: tracker.class.Milestone, - label: notification.string.LeftComment + label: chunter.string.LeftComment }, tracker.ids.MilestoneChatMessageViewlet ) diff --git a/models/tracker/src/plugin.ts b/models/tracker/src/plugin.ts index 89d1b0abefe..1cd9f61d830 100644 --- a/models/tracker/src/plugin.ts +++ b/models/tracker/src/plugin.ts @@ -22,13 +22,9 @@ import tracker from '@hcengineering/tracker-resources/src/plugin' import type { AnyComponent } from '@hcengineering/ui/src/types' import { type Action, type ViewAction, type Viewlet } from '@hcengineering/view' import { type Application } from '@hcengineering/workbench' -import { type TxViewlet } from '@hcengineering/activity' -import { - type ChatMessageViewlet, - type DocUpdateMessageViewlet, - type NotificationGroup, - type NotificationType -} from '@hcengineering/notification' +import { type DocUpdateMessageViewlet, type TxViewlet } from '@hcengineering/activity' +import { type NotificationGroup, type NotificationType } from '@hcengineering/notification' +import { type ChatMessageViewlet } from '@hcengineering/chunter' export default mergeIds(trackerId, tracker, { string: { @@ -81,11 +77,11 @@ export default mergeIds(trackerId, tracker, { TrackerNotificationGroup: '' as Ref, AssigneeNotification: '' as Ref, BaseProjectType: '' as Ref, - NotificationIssueUpdated: '' as Ref, - NotificationIssueCreated: '' as Ref, - NotificationIssueRemoved: '' as Ref, - NotificationMilestoneUpdated: '' as Ref, - NotificationIssueTemplateUpdated: '' as Ref, + IssueUpdatedActivityViewlet: '' as Ref, + IssueCreatedActivityViewlet: '' as Ref, + IssueRemovedActivityViewlet: '' as Ref, + MilestionUpdatedActivityViewlet: '' as Ref, + IssueTemplateUpdatedActivityViewlet: '' as Ref, IssueChatMessageViewlet: '' as Ref, IssueTemplateChatMessageViewlet: '' as Ref, ComponentChatMessageViewlet: '' as Ref, diff --git a/models/tracker/src/types.ts b/models/tracker/src/types.ts index 249ede0161c..bf3c9a54b21 100644 --- a/models/tracker/src/types.ts +++ b/models/tracker/src/types.ts @@ -64,7 +64,7 @@ import { type TimeSpendReport } from '@hcengineering/tracker' import tracker from './plugin' -import notification from '@hcengineering/notification' +import chunter from '@hcengineering/chunter' export const DOMAIN_TRACKER = 'tracker' as Domain @@ -288,7 +288,7 @@ export class TIssueTemplate extends TDoc implements IssueTemplate { @Prop(ArrOf(TypeRef(tracker.class.IssueTemplate)), tracker.string.IssueTemplate) children!: IssueTemplateChild[] - @Prop(Collection(notification.class.ChatMessage), tracker.string.Comments) + @Prop(Collection(chunter.class.ChatMessage), tracker.string.Comments) comments!: number @Prop(Collection(attachment.class.Attachment), tracker.string.Attachments) @@ -336,7 +336,7 @@ export class TComponent extends TDoc implements Component { @Prop(TypeRef(contact.mixin.Employee), tracker.string.ComponentLead) lead!: Ref | null - @Prop(Collection(notification.class.ChatMessage), notification.string.Comments) + @Prop(Collection(chunter.class.ChatMessage), chunter.string.Comments) comments!: number @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, { shortLabel: attachment.string.Files }) @@ -362,7 +362,7 @@ export class TMilestone extends TDoc implements Milestone { @Index(IndexKind.Indexed) status!: MilestoneStatus - @Prop(Collection(notification.class.ChatMessage), notification.string.Comments) + @Prop(Collection(chunter.class.ChatMessage), chunter.string.Comments) comments!: number @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, { shortLabel: attachment.string.Files }) diff --git a/models/view/src/index.ts b/models/view/src/index.ts index 1b84435ca69..0e8c98dc670 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -85,7 +85,6 @@ import { type Viewlet, type ViewletDescriptor, type ViewletPreference, - type NotificationAttributePresenter, type ObjectIdentifier } from '@hcengineering/view' @@ -127,9 +126,6 @@ export function classPresenter ( builder.mixin(_class, core.class.Class, view.mixin.ActivityAttributePresenter, { presenter: activity }) - builder.mixin(_class, core.class.Class, view.mixin.NotificationAttributePresenter, { - presenter: activity - }) } } @@ -210,11 +206,6 @@ export class TActivityAttributePresenter extends TClass implements ActivityAttri presenter!: AnyComponent } -@Mixin(view.mixin.NotificationAttributePresenter, core.class.Class) -export class TNotificationAttributePresenter extends TClass implements NotificationAttributePresenter { - presenter!: AnyComponent -} - @Mixin(view.mixin.SpacePresenter, core.class.Class) export class TSpacePresenter extends TClass implements SpacePresenter { presenter!: AnyComponent @@ -424,7 +415,6 @@ export function createModel (builder: Builder): void { TAttributePresenter, TAttributeFilterPresenter, TActivityAttributePresenter, - TNotificationAttributePresenter, TListItemPresenter, TCollectionEditor, TCollectionPresenter, @@ -479,8 +469,7 @@ export function createModel (builder: Builder): void { core.class.TypeMarkup, view.component.MarkupPresenter, view.component.MarkupEditor, - view.component.MarkupEditorPopup, - view.component.MarkupDiffPresenter + view.component.MarkupEditorPopup ) builder.mixin(core.class.TypeMarkup, core.class.Class, view.mixin.InlineAttributEditor, { diff --git a/packages/platform/package.json b/packages/platform/package.json index 1025db4c4b3..4ff9af92371 100644 --- a/packages/platform/package.json +++ b/packages/platform/package.json @@ -20,19 +20,19 @@ }, "devDependencies": { "@hcengineering/platform-rig": "^0.6.0", + "@types/jest": "^29.5.5", "@typescript-eslint/eslint-plugin": "^6.11.0", - "eslint-plugin-import": "^2.26.0", - "eslint-plugin-promise": "^6.1.1", - "eslint-plugin-n": "^15.4.0", - "eslint": "^8.54.0", "@typescript-eslint/parser": "^6.11.0", + "eslint": "^8.54.0", "eslint-config-standard-with-typescript": "^40.0.0", - "prettier": "^3.1.0", - "typescript": "^5.2.2", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-n": "^15.4.0", + "eslint-plugin-promise": "^6.1.1", "jest": "^29.7.0", + "prettier": "^3.1.0", + "prettier-plugin-svelte": "^3.1.0", "ts-jest": "^29.1.1", - "@types/jest": "^29.5.5", - "prettier-plugin-svelte": "^3.1.0" + "typescript": "^5.2.2" }, "dependencies": { "intl-messageformat": "^9.7.1" diff --git a/plugins/activity-assets/assets/icons.svg b/plugins/activity-assets/assets/icons.svg index 6c066576580..8d934431969 100644 --- a/plugins/activity-assets/assets/icons.svg +++ b/plugins/activity-assets/assets/icons.svg @@ -4,4 +4,9 @@ + + + diff --git a/plugins/activity-assets/lang/en.json b/plugins/activity-assets/lang/en.json index a4bb7f45cfe..dd513873d77 100644 --- a/plugins/activity-assets/lang/en.json +++ b/plugins/activity-assets/lang/en.json @@ -3,15 +3,31 @@ "Activity": "Activity", "Added": "added", "All": "All", + "AllActivity": "All activity", + "Attributes": "Attributes", "Changed": "changed", "CollectionUpdated": "Update {collection}", + "Created": "Created", "DocAdded": "added {_class}", "DocCreated": "created {_class}", "DocDeleted": "deleted {_class}", - "Edited": "edited", + "Edit": "Edit", + "Edited": "Edited", + "Emoji": "Emoji", + "For": "For", "From": "from", + "In": "In", + "New": "New", + "NewestFirst": "Newest first", + "Pinned": "Pinned", + "Reacted": "Reacted", + "Reactions": "Reactions", "Removed": "removed", + "Set": "set", "To": "to", - "Unset": "unset" + "Unset": "Unset", + "Update": "Update", + "Updated": "Updated", + "UpdatedCollection": "Updated" } } \ No newline at end of file diff --git a/plugins/activity-assets/lang/ru.json b/plugins/activity-assets/lang/ru.json index ac2bfcfd878..e52187ab237 100644 --- a/plugins/activity-assets/lang/ru.json +++ b/plugins/activity-assets/lang/ru.json @@ -1,17 +1,33 @@ { "string": { "Activity": "Активность", - "Added": "добавила(а)", + "Added": "Добавила(а)", "All": "Все", - "Changed": "изменил(а)", + "AllActivity": "Вся активнось", + "Attributes": "Атрибуты", + "Changed": "Изменил(а)", "CollectionUpdated": "Обновлена {collection}", + "Created": "Создал(a)", "DocAdded": "добавил(а) {_class}", "DocCreated": "создал(а) {_class}", "DocDeleted": "удалил(а) {_class}", - "Edited": "отредактировал(а)", + "Edit": "Редактировать", + "Edited": "Изменено", + "Emoji": "Эмодзи", + "For": "Для", "From": "из", - "Removed": "удалил(а)", + "In": "В", + "New": "Новые", + "NewestFirst": "Сначала новые", + "Pinned": "Закрепленные", + "Reacted": "Отреагировал(а)", + "Reactions": "Реакции", + "Removed": "Удалил(а)", + "Set": "установлен", "To": "на", - "Unset": "сбросил" + "Unset": "Cбросил", + "Update": "Обновить", + "Updated": "Обновил(а)", + "UpdatedCollection": "Обновленные" } } \ No newline at end of file diff --git a/plugins/activity-assets/src/index.ts b/plugins/activity-assets/src/index.ts index 3a929515995..26b1d31b03b 100644 --- a/plugins/activity-assets/src/index.ts +++ b/plugins/activity-assets/src/index.ts @@ -18,5 +18,6 @@ import { loadMetadata } from '@hcengineering/platform' const icons = require('../assets/icons.svg') as string // eslint-disable-line loadMetadata(activity.icon, { - Activity: `${icons}#activity` + Activity: `${icons}#activity`, + Emoji: `${icons}#emoji` }) diff --git a/plugins/activity-resources/package.json b/plugins/activity-resources/package.json index b5d6bd40f37..1fad9e7d25d 100644 --- a/plugins/activity-resources/package.json +++ b/plugins/activity-resources/package.json @@ -36,6 +36,8 @@ }, "dependencies": { "@hcengineering/activity": "^0.6.0", + "@hcengineering/contact": "^0.6.20", + "@hcengineering/contact-resources": "^0.6.0", "@hcengineering/core": "^0.6.28", "@hcengineering/notification": "^0.6.16", "@hcengineering/platform": "^0.6.9", diff --git a/plugins/notification-resources/src/activityMessagesUtils.ts b/plugins/activity-resources/src/activityMessagesUtils.ts similarity index 85% rename from plugins/notification-resources/src/activityMessagesUtils.ts rename to plugins/activity-resources/src/activityMessagesUtils.ts index d9b6ff38ae0..42bdb8fb8bb 100644 --- a/plugins/notification-resources/src/activityMessagesUtils.ts +++ b/plugins/activity-resources/src/activityMessagesUtils.ts @@ -28,19 +28,8 @@ import core, { type TxCUD, type TxMixin, TxProcessor, - type TxUpdateDoc, - type WithLookup + type TxUpdateDoc } from '@hcengineering/core' -import notification, { - type ActivityMessage, - type ChatMessage, - type DisplayActivityMessage, - type DisplayDocUpdateMessage, - type DocAttributeUpdates, - type DocNotifyContext, - type DocUpdateMessage, - type InboxNotification -} from '@hcengineering/notification' import view, { type AttributeModel } from '@hcengineering/view' import { getClient, getFiltredKeys } from '@hcengineering/presentation' import { getAttributePresenter, getDocLinkTitle } from '@hcengineering/view-resources' @@ -49,6 +38,13 @@ import { type IntlString } from '@hcengineering/platform' import { type AnyComponent } from '@hcengineering/ui' import { get } from 'svelte/store' import { personAccountByIdStore } from '@hcengineering/contact-resources' +import activity, { + type ActivityMessage, + type DisplayActivityMessage, + type DisplayDocUpdateMessage, + type DocAttributeUpdates, + type DocUpdateMessage +} from '@hcengineering/activity' // Use 5 minutes to combine similar messages const combineThresholdMs = 5 * 60 * 1000 @@ -131,7 +127,7 @@ export function getCollectionAttribute ( return undefined } -export async function getNotificationObject ( +export async function getActivityObject ( client: Client, objectId: Ref, objectClass: Ref> @@ -176,65 +172,20 @@ export async function getAttributeModel ( attrObjectClass, attrKey, { key: attrKey }, - view.mixin.NotificationAttributePresenter + view.mixin.ActivityAttributePresenter ) } catch (e) { // ignore error } } -function activityMessagesComparator (message1: ActivityMessage, message2: ActivityMessage): number { +export function activityMessagesComparator (message1: ActivityMessage, message2: ActivityMessage): number { const time1 = getMessageTime(message1) const time2 = getMessageTime(message2) return time1 - time2 } -export function getDisplayActivityMessagesByNotifications ( - inboxNotifications: Array>, - docNotifyContextById: Map, DocNotifyContext>, - filter: 'all' | 'read' | 'unread', - objectClass?: Ref> -): DisplayActivityMessage[] { - const messages = inboxNotifications - .filter(({ docNotifyContext, isViewed }) => { - const update = docNotifyContextById.get(docNotifyContext) - const isVisible = update !== undefined && !update.hidden - - if (!isVisible) { - return false - } - - switch (filter) { - case 'unread': - return !isViewed - case 'all': - return true - case 'read': - return !!isViewed - } - - return false - }) - .map(({ $lookup }) => $lookup?.attachedTo) - .filter((message): message is ActivityMessage => { - if (message === undefined) { - return false - } - if (objectClass === undefined) { - return true - } - if (message._class === notification.class.ChatMessage) { - return false - } - - return (message as DocUpdateMessage).objectClass === objectClass - }) - .sort(activityMessagesComparator) - - return combineActivityMessages(messages, SortingOrder.Descending) -} - function getMessageTime (message: ActivityMessage): number { return message.createdOn ?? message.modifiedOn } @@ -265,15 +216,13 @@ export function combineActivityMessages ( messages: ActivityMessage[], sortingOrder: SortingOrder = SortingOrder.Ascending ): DisplayActivityMessage[] { - const chatMessages = messages.filter( - (message): message is ChatMessage => message._class === notification.class.ChatMessage - ) + const uncombinedMessages = messages.filter((message) => message._class !== activity.class.DocUpdateMessage) const docUpdateMessages = combineByCreateThreshold( - messages.filter((message): message is DocUpdateMessage => message._class === notification.class.DocUpdateMessage) + messages.filter((message): message is DocUpdateMessage => message._class === activity.class.DocUpdateMessage) ) - const result: DisplayActivityMessage[] = [...chatMessages] + const result: DisplayActivityMessage[] = [...uncombinedMessages] const groupedByType: Map = groupByArray(docUpdateMessages, getDocUpdateMessageKey) @@ -473,17 +422,13 @@ function getAttributeUpdatesKey (message: DocUpdateMessage): string { } export function attributesFilter (message: ActivityMessage, _class?: Ref): boolean { - if (message._class === notification.class.DocUpdateMessage) { + if (message._class === activity.class.DocUpdateMessage) { return (message as DocUpdateMessage).objectClass === _class } return false } -export function chatMessagesFilter (message: ActivityMessage): boolean { - return message._class === notification.class.ChatMessage -} - export function pinnedFilter (message: ActivityMessage, _class?: Ref): boolean { return message.isPinned === true } @@ -506,9 +451,9 @@ export async function getLinkData ( let linkObject: Doc | undefined - if (hierarchy.isDerived(message.attachedToClass, notification.class.ActivityMessage)) { + if (hierarchy.isDerived(message.attachedToClass, activity.class.ActivityMessage)) { linkObject = parentObject - } else if (message._class === notification.class.DocUpdateMessage) { + } else if (message._class === activity.class.DocUpdateMessage) { linkObject = (message as DocUpdateMessage).action === 'update' ? object : parentObject ?? object } else { linkObject = parentObject ?? object @@ -524,13 +469,12 @@ export async function getLinkData ( const title = await getDocLinkTitle(client, linkObject._id, linkObject._class, linkObject) - const preposition = hierarchy.classHierarchyMixin(linkObject._class, notification.mixin.NotificationObjectPreposition) - ?.preposition + const preposition = hierarchy.classHierarchyMixin(linkObject._class, activity.mixin.ActivityDoc)?.preposition const panelComponent = hierarchy.classHierarchyMixin(linkObject._class, view.mixin.ObjectPanel) return { title, - preposition: preposition ?? notification.string.In, + preposition: preposition ?? activity.string.In, panelComponent: panelComponent?.component ?? view.component.EditDoc, object: linkObject } diff --git a/plugins/activity-resources/src/components/Activity.svelte b/plugins/activity-resources/src/components/Activity.svelte index 2348a2c1e0e..9062941d64e 100644 --- a/plugins/activity-resources/src/components/Activity.svelte +++ b/plugins/activity-resources/src/components/Activity.svelte @@ -13,14 +13,14 @@ // limitations under the License. --> -{#if isVisible} - +{#if extension} + {/if} diff --git a/plugins/activity-resources/src/components/ActivityFilter.svelte b/plugins/activity-resources/src/components/ActivityFilter.svelte index b046fe09fb0..ad2d8be7b17 100644 --- a/plugins/activity-resources/src/components/ActivityFilter.svelte +++ b/plugins/activity-resources/src/components/ActivityFilter.svelte @@ -18,12 +18,13 @@ import { getResource } from '@hcengineering/platform' import { getClient } from '@hcengineering/presentation' import { ActionIcon, eventToHTMLElement, Icon, Label, showPopup } from '@hcengineering/ui' - import notification, { ActivityMessage, ActivityMessagesFilter } from '@hcengineering/notification' + import { ActivityMessage, ActivityMessagesFilter } from '@hcengineering/activity' import activity from '../plugin' import FilterPopup from './FilterPopup.svelte' import IconClose from './icons/Close.svelte' import IconFilter from './icons/Filter.svelte' + import { sortActivityMessages } from '../activityMessagesUtils' export let messages: ActivityMessage[] export let object: Doc @@ -40,7 +41,7 @@ $: localStorage.setItem('activity-filter', JSON.stringify(selectedFiltersRefs)) $: localStorage.setItem('activity-newest-first', JSON.stringify(isNewestFirst)) - client.findAll(notification.class.ActivityMessagesFilter, {}).then((res) => { + client.findAll(activity.class.ActivityMessagesFilter, {}).then((res) => { filters = res if (saved !== null && saved !== undefined) { @@ -83,9 +84,7 @@ selected: Ref[] | 'All', sortOrder: SortingOrder ): Promise { - const sortMessagesFn = await getResource(notification.function.SortActivityMessages) - - const sortedMessages = sortMessagesFn(messages, sortOrder).sort(({ isPinned }) => + const sortedMessages = sortActivityMessages(messages, sortOrder).sort(({ isPinned }) => isPinned && sortOrder === SortingOrder.Ascending ? -1 : 1 ) diff --git a/plugins/activity-resources/src/components/FilterPopup.svelte b/plugins/activity-resources/src/components/FilterPopup.svelte index a48df871746..2cada93358b 100644 --- a/plugins/activity-resources/src/components/FilterPopup.svelte +++ b/plugins/activity-resources/src/components/FilterPopup.svelte @@ -17,7 +17,7 @@ import { IntlString } from '@hcengineering/platform' import { Label, resizeObserver, CheckBox, MiniToggle } from '@hcengineering/ui' import { Doc, Ref } from '@hcengineering/core' - import notification, { ActivityMessagesFilter } from '@hcengineering/notification' + import { ActivityMessagesFilter } from '@hcengineering/activity' import activity from '../plugin' @@ -132,7 +132,7 @@
{ dispatch('update', { action: 'toggle', value: activityOrderNewestFirst }) }} diff --git a/plugins/notification-resources/src/components/activity-message/ActivityMessageExtension.svelte b/plugins/activity-resources/src/components/activity-message/ActivityMessageExtension.svelte similarity index 96% rename from plugins/notification-resources/src/components/activity-message/ActivityMessageExtension.svelte rename to plugins/activity-resources/src/components/activity-message/ActivityMessageExtension.svelte index e11afb30af9..f2f2777f840 100644 --- a/plugins/notification-resources/src/components/activity-message/ActivityMessageExtension.svelte +++ b/plugins/activity-resources/src/components/activity-message/ActivityMessageExtension.svelte @@ -13,7 +13,7 @@ // limitations under the License. --> {#if presenter} diff --git a/plugins/notification-resources/src/components/doc-update-message/DocUpdateMessageContent.svelte b/plugins/activity-resources/src/components/doc-update-message/DocUpdateMessageContent.svelte similarity index 91% rename from plugins/notification-resources/src/components/doc-update-message/DocUpdateMessageContent.svelte rename to plugins/activity-resources/src/components/doc-update-message/DocUpdateMessageContent.svelte index 800525f4da3..29809c6c01f 100644 --- a/plugins/notification-resources/src/components/doc-update-message/DocUpdateMessageContent.svelte +++ b/plugins/activity-resources/src/components/doc-update-message/DocUpdateMessageContent.svelte @@ -15,16 +15,13 @@ @@ -54,11 +52,11 @@ {#if hasDifferentActions} -