From b618b3c42fc09b05ea5e1bf1f0766197aa01a9f0 Mon Sep 17 00:00:00 2001 From: Kristina Date: Mon, 25 Aug 2025 11:36:59 +0400 Subject: [PATCH] Init directs (#9715) Signed-off-by: Kristina Fefelova --- communication | 2 +- models/card/src/index.ts | 11 +- models/communication/src/types.ts | 56 ++++- models/server-card/package.json | 1 + models/server-card/src/index.ts | 19 ++ packages/theme/styles/_lumia-colors.scss | 6 +- packages/theme/styles/panel.scss | 21 +- packages/ui/src/components/NavGroup.svelte | 5 + packages/ui/src/components/NavItem.svelte | 6 +- plugins/card-assets/lang/cs.json | 5 +- plugins/card-assets/lang/de.json | 3 +- plugins/card-assets/lang/en.json | 5 +- plugins/card-assets/lang/es.json | 5 +- plugins/card-assets/lang/fr.json | 5 +- plugins/card-assets/lang/it.json | 5 +- plugins/card-assets/lang/ja.json | 5 +- plugins/card-assets/lang/pt.json | 5 +- plugins/card-assets/lang/ru.json | 5 +- plugins/card-assets/lang/zh.json | 5 +- .../src/components/CardCollaborators.svelte | 110 ++++++++++ .../src/components/CardIcon.svelte | 8 +- .../src/components/CreateCardPopup.svelte | 196 +++++++++++++++++ .../navigator-next/NavigatorCard.svelte | 4 + .../navigator-next/NavigatorType.svelte | 52 +++-- plugins/card-resources/src/plugin.ts | 3 +- plugins/card-resources/src/types.ts | 2 +- plugins/card-resources/src/utils.ts | 40 +++- plugins/card/src/index.ts | 14 +- plugins/chat-resources/package.json | 1 + .../src/components/ChatNavigation.svelte | 12 +- plugins/communication-assets/lang/cs.json | 5 +- plugins/communication-assets/lang/de.json | 5 +- plugins/communication-assets/lang/en.json | 5 +- plugins/communication-assets/lang/es.json | 5 +- plugins/communication-assets/lang/fr.json | 5 +- plugins/communication-assets/lang/it.json | 5 +- plugins/communication-assets/lang/ja.json | 5 +- plugins/communication-assets/lang/pt.json | 5 +- plugins/communication-assets/lang/ru.json | 5 +- plugins/communication-assets/lang/zh.json | 5 +- .../communication-resources/src/actions.ts | 4 +- .../src/components/CreateDirect.svelte | 56 +++++ .../src/components/DirectIcon.svelte | 183 ++++++++++++++++ plugins/communication-resources/src/index.ts | 11 +- plugins/communication-resources/src/plugin.ts | 13 +- plugins/communication-resources/src/utils.ts | 39 +++- plugins/communication/src/direct.ts | 21 ++ plugins/communication/src/index.ts | 3 +- plugins/communication/src/poll.ts | 34 +++ plugins/communication/src/types.ts | 3 + .../src/components/Avatar.svelte | 3 + .../src/components/AvatarInstance.svelte | 3 + pods/server/src/server.ts | 2 + .../activity-resources/src/newActivity.ts | 5 +- server-plugins/card-resources/package.json | 2 + server-plugins/card-resources/src/index.ts | 203 +++++++++++++++++- server-plugins/card/src/index.ts | 2 + server/server-pipeline/src/communication.ts | 8 + 58 files changed, 1169 insertions(+), 93 deletions(-) create mode 100644 plugins/card-resources/src/components/CardCollaborators.svelte create mode 100644 plugins/card-resources/src/components/CreateCardPopup.svelte create mode 100644 plugins/communication-resources/src/components/CreateDirect.svelte create mode 100644 plugins/communication-resources/src/components/DirectIcon.svelte create mode 100644 plugins/communication/src/direct.ts create mode 100644 plugins/communication/src/poll.ts diff --git a/communication b/communication index f7d1b98df4..407c52ca43 160000 --- a/communication +++ b/communication @@ -1 +1 @@ -Subproject commit f7d1b98df46f277396ba9b22b084adf28203ac84 +Subproject commit 407c52ca437011ab2bb988c2cf7d103d6b83ff8a diff --git a/models/card/src/index.ts b/models/card/src/index.ts index ed2364a393..e123ef4e05 100644 --- a/models/card/src/index.ts +++ b/models/card/src/index.ts @@ -19,6 +19,8 @@ import { type CardSection, type CardSpace, type CardViewDefaults, + type CreateCardExtension, + type CanCreateCardResource, DOMAIN_CARD, type FavoriteCard, type MasterTag, @@ -168,6 +170,12 @@ export class TFavoriteCard extends TPreference implements FavoriteCard { application!: string } +@Mixin(card.mixin.CreateCardExtension, card.class.MasterTag) +export class TCreateCardExtension extends TMasterTag implements CreateCardExtension { + component?: AnyComponent + canCreate?: CanCreateCardResource +} + export * from './migration' const listConfig: (BuildModelKey | string)[] = [ @@ -337,7 +345,8 @@ export function createModel (builder: Builder): void { TRole, TCardSection, TCardViewDefaults, - TFavoriteCard + TFavoriteCard, + TCreateCardExtension ) defineTabs(builder) diff --git a/models/communication/src/types.ts b/models/communication/src/types.ts index 7de5ec70ac..08d8df9e7d 100644 --- a/models/communication/src/types.ts +++ b/models/communication/src/types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { type Builder, Model, TypeAny, TypeNumber } from '@hcengineering/model' +import { ArrOf, type Builder, Model, TypeAny, TypeNumber, TypeRef } from '@hcengineering/model' import core, { TAttachedDoc, TConfiguration, TDoc } from '@hcengineering/model-core' import { type Class, type Domain, DOMAIN_MODEL, type Ref } from '@hcengineering/core' import { type Asset, type IntlString } from '@hcengineering/platform' @@ -25,17 +25,19 @@ import { type Poll, type CustomActivityPresenter, type GuestCommunicationSettings, - type AppletGetTitleFnResource + type AppletGetTitleFnResource, + MessagesNavigationAnchors } from '@hcengineering/communication' import { PaletteColorIndexes } from '@hcengineering/ui/src/colors' import { type AppletType } from '@hcengineering/communication-types' -import { createSystemType } from '@hcengineering/model-card' +import card, { createSystemType } from '@hcengineering/model-card' import type { AnyComponent } from '@hcengineering/ui' -import { type PersonSpace } from '@hcengineering/contact' - -import communication from './plugin' +import contact, { type PersonSpace } from '@hcengineering/contact' import { type Card, type MasterTag } from '@hcengineering/card' import { DOMAIN_SETTING } from '@hcengineering/setting' +import view from '@hcengineering/model-view' + +import communication from './plugin' export const DOMAIN_POLL = 'poll' as Domain @@ -86,6 +88,48 @@ export class TGuestCommunicationSettings extends TConfiguration implements Guest export function buildTypes (builder: Builder): void { builder.createModel(TMessageAction, TApplet, TPollAnswer, TCustomActivityPresenter, TGuestCommunicationSettings) + defineDirect(builder) + definePoll(builder) +} + +function defineDirect (builder: Builder): void { + createSystemType( + builder, + communication.type.Direct, + contact.icon.Contacts, + communication.string.Direct, + communication.string.Directs, + { + defaultSection: communication.ids.CardMessagesSection, + defaultNavigation: MessagesNavigationAnchors.LatestMessages + }, + PaletteColorIndexes.Lavander + ) + + builder.createDoc(core.class.Attribute, core.space.Model, { + name: 'members', + readonly: true, // TODO: remove + attributeOf: communication.type.Direct, + type: ArrOf(TypeRef(contact.class.Person)), + label: communication.string.Members + }) + + builder.mixin(communication.type.Direct, core.class.Class, view.mixin.ObjectIcon, { + component: communication.component.DirectIcon + }) + builder.mixin(communication.type.Direct, core.class.Class, card.mixin.CreateCardExtension, { + component: communication.component.CreateDirect, + canCreate: communication.function.CanCreateDirect, + disableTitle: true, + hideSpace: true + }) + + builder.mixin(communication.type.Direct, core.class.Class, view.mixin.IgnoreActions, { + actions: [view.action.Delete] + }) +} + +function definePoll (builder: Builder): void { createSystemType( builder, communication.type.Poll, diff --git a/models/server-card/package.json b/models/server-card/package.json index eb29b579b9..7bdeb65303 100644 --- a/models/server-card/package.json +++ b/models/server-card/package.json @@ -33,6 +33,7 @@ "@hcengineering/model": "^0.6.11", "@hcengineering/platform": "^0.6.11", "@hcengineering/card": "^0.6.0", + "@hcengineering/communication": "^0.6.0", "@hcengineering/server-card": "^0.6.0", "@hcengineering/server-core": "^0.6.1" } diff --git a/models/server-card/src/index.ts b/models/server-card/src/index.ts index 0d4d909e3e..9008fbee70 100644 --- a/models/server-card/src/index.ts +++ b/models/server-card/src/index.ts @@ -19,6 +19,7 @@ import core from '@hcengineering/core' import serverCore from '@hcengineering/server-core' import serverCard from '@hcengineering/server-card' import card from '@hcengineering/card' +import communication from '@hcengineering/communication' export { serverCardId } from '@hcengineering/server-card' @@ -85,6 +86,24 @@ export function createModel (builder: Builder): void { } }) + builder.createDoc(serverCore.class.Trigger, core.space.Model, { + trigger: serverCard.trigger.OnDirectCreate, + isAsync: false, + txMatch: { + _class: core.class.TxCreateDoc, + objectClass: communication.type.Direct + } + }) + + builder.createDoc(serverCore.class.Trigger, core.space.Model, { + trigger: serverCard.trigger.OnThreadCreate, + isAsync: false, + txMatch: { + _class: core.class.TxCreateDoc, + objectClass: card.class.Card + } + }) + builder.createDoc(serverCore.class.Trigger, core.space.Model, { trigger: serverCard.trigger.OnCardUpdate, isAsync: true, diff --git a/packages/theme/styles/_lumia-colors.scss b/packages/theme/styles/_lumia-colors.scss index dd669f1911..541ce1e218 100644 --- a/packages/theme/styles/_lumia-colors.scss +++ b/packages/theme/styles/_lumia-colors.scss @@ -43,7 +43,7 @@ /* Dark Theme */ .theme-dark { - --global-ui-BackgroundColor: #A5BDFF0D; + --global-ui-BackgroundColor: 1530720D; --global-ui-BorderColor: #A5BDFF1A; --global-ui-hover-BackgroundColor: #A5BDFF1A; --global-ui-active-BackgroundColor: #A5BDFF26; @@ -134,6 +134,8 @@ --love-active-call-filter: blur(17px); --global-offline-color: #d1d5de; + + --avatar-counter-BackgroundColor: #141523 } /* Light Theme */ @@ -229,4 +231,6 @@ --love-active-call-transform: scaleY(0.3) scaleX(0.42); --global-offline-color: #5A667E; + + --avatar-counter-BackgroundColor: #F1F1F5; } diff --git a/packages/theme/styles/panel.scss b/packages/theme/styles/panel.scss index 1a827e7c23..44aca5c82e 100644 --- a/packages/theme/styles/panel.scss +++ b/packages/theme/styles/panel.scss @@ -1,14 +1,14 @@ // // 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. // @@ -115,7 +115,7 @@ background-color: var(--theme-navpanel-selected); border: 1px solid var(--global-subtle-ui-BorderColor); border-radius: var(--extra-small-BorderRadius); - + &.folder { background-color: var(--theme-statusbar-color); border-color: var(--global-surface-01-BorderColor); @@ -131,7 +131,7 @@ color: var(--global-tertiary-TextColor); border-radius: var(--extra-small-BorderRadius); } - &__tools { + &__tools, &__actions { display: none; align-items: center; flex-shrink: 0; @@ -153,6 +153,11 @@ &:hover { .hulyNavGroup-header__tools { display: flex; } } + + &:hover { + .hulyNavGroup-header__actions { display: flex; } + } + &.showMenu, &.highlighted, &.selected { @@ -392,7 +397,7 @@ &__mobile { flex-grow: 1; } - + &__main { flex-grow: 2; flex-basis: 760px; @@ -474,7 +479,7 @@ &__aside { width: 25%; min-width: var(--panel-aside-width); - + &.float { position: absolute; flex-direction: row; @@ -576,7 +581,7 @@ width: 100%; visibility: hidden; } - + .popupPanel-pageFooter { @include watermark; diff --git a/packages/ui/src/components/NavGroup.svelte b/packages/ui/src/components/NavGroup.svelte index 45f8acb356..0bb1680e8e 100644 --- a/packages/ui/src/components/NavGroup.svelte +++ b/packages/ui/src/components/NavGroup.svelte @@ -155,6 +155,11 @@ {/if} + {#if $$slots.actions} +
+ +
+ {/if} {#if selected && type === 'nested-selectable'}
{/if} diff --git a/packages/ui/src/components/NavItem.svelte b/packages/ui/src/components/NavItem.svelte index 14b9bd4551..a9edbd175b 100644 --- a/packages/ui/src/components/NavItem.svelte +++ b/packages/ui/src/components/NavItem.svelte @@ -116,8 +116,10 @@ {/if} {#if visibleIcon || (type === 'type-tag' && color)} -
- {#if type !== 'type-tag' && visibleIcon} +
+ {#if $$slots.icon} + + {:else if type !== 'type-tag' && visibleIcon} {:else if type === 'type-tag'}
diff --git a/plugins/card-assets/lang/cs.json b/plugins/card-assets/lang/cs.json index c7074ef264..860a67b973 100644 --- a/plugins/card-assets/lang/cs.json +++ b/plugins/card-assets/lang/cs.json @@ -39,6 +39,7 @@ "Labels": "Štítky", "Properties": "Vlastnosti", "NoChildren": "Žádné děti", - "ConfigDescription": "Rozšíření pro správu znalostí ve stylu databáze." + "ConfigDescription": "Rozšíření pro správu znalostí ve stylu databáze.", + "AddCollaborators": "Přidat spolupracovníky" } -} \ No newline at end of file +} diff --git a/plugins/card-assets/lang/de.json b/plugins/card-assets/lang/de.json index ed2e7bc770..b90952828c 100644 --- a/plugins/card-assets/lang/de.json +++ b/plugins/card-assets/lang/de.json @@ -39,6 +39,7 @@ "Labels": "Labels", "Properties": "Eigenschaften", "NoChildren": "Keine Kinder", - "ConfigDescription": "Erweiterung für Datenbank-basiertes Wissensmanagement." + "ConfigDescription": "Erweiterung für Datenbank-basiertes Wissensmanagement.", + "AddCollaborators": "Mitarbeiter hinzufügen" } } diff --git a/plugins/card-assets/lang/en.json b/plugins/card-assets/lang/en.json index 29e648d738..466dc57be2 100644 --- a/plugins/card-assets/lang/en.json +++ b/plugins/card-assets/lang/en.json @@ -39,6 +39,7 @@ "Labels": "Labels", "Properties": "Properties", "NoChildren": "No children", - "ConfigDescription": "Extension for database-style knowledge management." + "ConfigDescription": "Extension for database-style knowledge management.", + "AddCollaborators": "Add collaborators" } -} \ No newline at end of file +} diff --git a/plugins/card-assets/lang/es.json b/plugins/card-assets/lang/es.json index 45c80d7eff..6fa79d1980 100644 --- a/plugins/card-assets/lang/es.json +++ b/plugins/card-assets/lang/es.json @@ -39,6 +39,7 @@ "Labels": "Etiquetas", "Properties": "Propiedades", "NoChildren": "No hay hijos", - "ConfigDescription": "Extensión para la gestión del conocimiento al estilo de una base de datos." + "ConfigDescription": "Extensión para la gestión del conocimiento al estilo de una base de datos.", + "AddCollaborators": "Agregar colaboradores" } -} \ No newline at end of file +} diff --git a/plugins/card-assets/lang/fr.json b/plugins/card-assets/lang/fr.json index a9a875f380..93ba3ae1e8 100644 --- a/plugins/card-assets/lang/fr.json +++ b/plugins/card-assets/lang/fr.json @@ -39,6 +39,7 @@ "Labels": "Étiquettes", "Properties": "Propriétés", "NoChildren": "Pas d'enfants", - "ConfigDescription": "Extension pour la gestion des connaissances de style base de données." + "ConfigDescription": "Extension pour la gestion des connaissances de style base de données.", + "AddCollaborators": "Ajouter des collaborateurs" } -} \ No newline at end of file +} diff --git a/plugins/card-assets/lang/it.json b/plugins/card-assets/lang/it.json index 33b67b254d..f76cdfcfa0 100644 --- a/plugins/card-assets/lang/it.json +++ b/plugins/card-assets/lang/it.json @@ -39,6 +39,7 @@ "Properties": "Proprietà", "NoChildren": "Nessun figlio", "NumberTypes": "{count, plural, one {# tipo} other {# tipi}}", - "ConfigDescription": "Estensione per la gestione della conoscenza in stile database." + "ConfigDescription": "Estensione per la gestione della conoscenza in stile database.", + "AddCollaborators": "Aggiungi collaboratori" } -} \ No newline at end of file +} diff --git a/plugins/card-assets/lang/ja.json b/plugins/card-assets/lang/ja.json index 0fb052e535..5f7aae6e84 100644 --- a/plugins/card-assets/lang/ja.json +++ b/plugins/card-assets/lang/ja.json @@ -39,6 +39,7 @@ "Labels": "ラベル", "Properties": "プロパティ", "NoChildren": "子がありません", - "ConfigDescription": "データベーススタイルのナレッジマネジメント用の拡張機能。" + "ConfigDescription": "データベーススタイルのナレッジマネジメント用の拡張機能。", + "AddCollaborators": "コラボレーターを追加" } -} \ No newline at end of file +} diff --git a/plugins/card-assets/lang/pt.json b/plugins/card-assets/lang/pt.json index a63dac2be1..b3a249a991 100644 --- a/plugins/card-assets/lang/pt.json +++ b/plugins/card-assets/lang/pt.json @@ -39,6 +39,7 @@ "Labels": "Etiquetas", "Properties": "Propriedades", "NoChildren": "Sem filhos", - "ConfigDescription": "Extensão para gerenciamento de conhecimento no estilo de banco de dados." + "ConfigDescription": "Extensão para gerenciamento de conhecimento no estilo de banco de dados.", + "AddCollaborators": "Adicionar colaboradores" } -} \ No newline at end of file +} diff --git a/plugins/card-assets/lang/ru.json b/plugins/card-assets/lang/ru.json index f9f58c848f..038a7bf414 100644 --- a/plugins/card-assets/lang/ru.json +++ b/plugins/card-assets/lang/ru.json @@ -39,6 +39,7 @@ "Labels": "Метки", "Properties": "Свойства", "NoChildren": "Нет потомков", - "ConfigDescription": "Расширение для управления знаниями в стиле базы данных." + "ConfigDescription": "Расширение для управления знаниями в стиле базы данных.", + "AddCollaborators": "Добавить сотрудников" } -} \ No newline at end of file +} diff --git a/plugins/card-assets/lang/zh.json b/plugins/card-assets/lang/zh.json index 361139770b..add5438230 100644 --- a/plugins/card-assets/lang/zh.json +++ b/plugins/card-assets/lang/zh.json @@ -39,6 +39,7 @@ "Labels": "标签", "Properties": "属性", "NoChildren": "没有子级", - "ConfigDescription": "用于数据库风格知识管理的扩展。" + "ConfigDescription": "用于数据库风格知识管理的扩展。", + "AddCollaborators": "添加协作者" } -} \ No newline at end of file +} diff --git a/plugins/card-resources/src/components/CardCollaborators.svelte b/plugins/card-resources/src/components/CardCollaborators.svelte new file mode 100644 index 0000000000..8c822d3f2e --- /dev/null +++ b/plugins/card-resources/src/components/CardCollaborators.svelte @@ -0,0 +1,110 @@ + + + +
+
+ dispatch('add')} + /> +
+ + {#each employees as employee, index (employee._id)} +
+
+ + {#if !disableRemoveFor.includes(employee._id)} +
+ { + dispatch('remove', employee._id) + }} + /> +
+ {/if} +
+
+ {/each} +
+
+ + diff --git a/plugins/card-resources/src/components/CardIcon.svelte b/plugins/card-resources/src/components/CardIcon.svelte index 760aedb831..0852083ed4 100644 --- a/plugins/card-resources/src/components/CardIcon.svelte +++ b/plugins/card-resources/src/components/CardIcon.svelte @@ -15,7 +15,7 @@ -{#if editable} +{#if iconMixin && iconMixin._id !== card.class.Card} + +{:else if editable}