Skip to content

Commit 38acd73

Browse files
Add personal labels for cards (#8534)
Signed-off-by: Kristina Fefelova <[email protected]>
1 parent 5ac8c16 commit 38acd73

File tree

47 files changed

+433
-221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+433
-221
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 156 additions & 121 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/card/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"@hcengineering/workbench": "^0.6.16",
4646
"@hcengineering/model-workbench": "^0.6.1",
4747
"@hcengineering/card-resources": "^0.6.0",
48-
"@hcengineering/view": "^0.6.13"
48+
"@hcengineering/view": "^0.6.13",
49+
"@hcengineering/tags": "^0.6.16"
4950
}
5051
}

models/card/src/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ const listConfig: (BuildModelKey | string)[] = [
128128
props: { fullSize: true },
129129
displayProps: { key: 'tags', fixed: 'right' }
130130
},
131+
{
132+
key: '',
133+
presenter: card.component.LabelsPresenter,
134+
label: card.string.Labels,
135+
props: { fullSize: true },
136+
displayProps: { fixed: 'right', key: 'labels' }
137+
},
131138
{
132139
key: 'modifiedOn',
133140
displayProps: { fixed: 'right', dividerBefore: true }
@@ -168,6 +175,12 @@ export function createSystemType (
168175
'',
169176
'_class',
170177
{ key: '', presenter: view.component.RolePresenter, label: card.string.Tags, props: { fullSize: true } },
178+
{
179+
key: '',
180+
presenter: card.component.LabelsPresenter,
181+
label: card.string.Labels,
182+
props: { fullSize: true }
183+
},
171184
'modifiedOn'
172185
]
173186
})

models/card/src/migration.ts

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ import {
2020
tryUpgrade,
2121
type MigrateOperation,
2222
type MigrationClient,
23-
type MigrationUpgradeClient
23+
type MigrationUpgradeClient,
24+
createOrUpdate
2425
} from '@hcengineering/model'
2526
import view from '@hcengineering/view'
2627
import card from '.'
28+
import tags from '@hcengineering/tags'
2729

2830
export const cardOperation: MigrateOperation = {
2931
async migrate (client: MigrationClient, mode): Promise<void> {
@@ -56,6 +58,10 @@ export const cardOperation: MigrateOperation = {
5658
const tx = new TxOperations(client, core.account.System)
5759
await createDefaultProject(tx)
5860
}
61+
},
62+
{
63+
state: 'default-labels',
64+
func: defaultLabels
5965
}
6066
])
6167
}
@@ -172,3 +178,48 @@ async function createDefaultProject (tx: TxOperations): Promise<void> {
172178
async function migrateSpaces (client: MigrationClient): Promise<void> {
173179
await client.update(DOMAIN_CARD, { space: core.space.Workspace }, { space: card.space.Default })
174180
}
181+
182+
async function defaultLabels (client: Client): Promise<void> {
183+
const ops = new TxOperations(client, core.account.System)
184+
await createOrUpdate(
185+
ops,
186+
tags.class.TagCategory,
187+
core.space.Workspace,
188+
{
189+
icon: tags.icon.Tags,
190+
label: 'Labels',
191+
targetClass: card.class.Card,
192+
tags: [],
193+
default: true
194+
},
195+
card.category.Labels
196+
)
197+
198+
await createOrUpdate(
199+
ops,
200+
tags.class.TagElement,
201+
core.space.Workspace,
202+
{
203+
title: 'Subscribed',
204+
targetClass: card.class.Card,
205+
description: '',
206+
color: 17, // green
207+
category: card.category.Labels
208+
},
209+
card.label.Subscribed
210+
)
211+
212+
await createOrUpdate(
213+
ops,
214+
tags.class.TagElement,
215+
core.space.Workspace,
216+
{
217+
title: 'New messages',
218+
targetClass: card.class.Card,
219+
description: '',
220+
color: 19, // orange
221+
category: card.category.Labels
222+
},
223+
card.label.NewMessages
224+
)
225+
}

models/card/src/plugin.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { mergeIds, type Resource } from '@hcengineering/platform'
2121
import { type Location, type ResolvedLocation } from '@hcengineering/ui/src/types'
2222
import { type LocationData } from '@hcengineering/workbench'
2323
import { type ActionCategory, type Action, type ViewAction } from '@hcengineering/view'
24+
import { type TagCategory, type TagElement } from '@hcengineering/tags'
2425

2526
export default mergeIds(cardId, card, {
2627
app: {
@@ -36,7 +37,8 @@ export default mergeIds(cardId, card, {
3637
UnsetParent: '' as Ref<Action<Doc, any>>
3738
},
3839
category: {
39-
Card: '' as Ref<ActionCategory>
40+
Card: '' as Ref<ActionCategory>,
41+
Labels: '' as Ref<TagCategory>
4042
},
4143
ids: {
4244
MasterTags: '' as Ref<Doc>,
@@ -51,5 +53,9 @@ export default mergeIds(cardId, card, {
5153
CardTitleProvider: '' as Resource<(client: Client, ref: Ref<Doc>, doc?: Doc) => Promise<string>>,
5254
CardIdProvider: '' as Resource<(client: Client, ref: Ref<Doc>, doc?: Doc) => Promise<string>>,
5355
GetCardLink: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>
56+
},
57+
label: {
58+
Subscribed: '' as Ref<TagElement>,
59+
NewMessages: '' as Ref<TagElement>
5460
}
5561
})

packages/presentation/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
"@hcengineering/analytics": "^0.6.0",
4444
"@hcengineering/client": "^0.6.18",
4545
"@hcengineering/collaborator-client": "^0.6.4",
46-
"@hcengineering/communication-client-query": "0.1.155",
47-
"@hcengineering/communication-sdk-types": "0.1.155",
48-
"@hcengineering/communication-types": "0.1.155",
46+
"@hcengineering/communication-client-query": "0.1.166",
47+
"@hcengineering/communication-sdk-types": "0.1.166",
48+
"@hcengineering/communication-types": "0.1.166",
4949
"@hcengineering/core": "^0.6.32",
5050
"@hcengineering/diffview": "^0.6.0",
5151
"@hcengineering/notification": "^0.6.23",

packages/presentation/src/communication.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ import {
2929
type NotificationContext,
3030
PatchType,
3131
type RichText,
32-
type SocialID
32+
type SocialID,
33+
type CardType,
34+
type Label,
35+
type FindLabelsParams
3336
} from '@hcengineering/communication-types'
3437
import {
3538
type CreateFileEvent,
@@ -42,9 +45,10 @@ import {
4245
type RemoveFileEvent,
4346
type RemoveReactionEvent,
4447
type RequestEvent,
45-
RequestEventType,
4648
type ResponseEvent,
47-
type UpdateNotificationContextEvent
49+
type UpdateNotificationContextEvent,
50+
MessageRequestEventType,
51+
NotificationRequestEventType
4852
} from '@hcengineering/communication-sdk-types'
4953
import {
5054
type Client as PlatformClient,
@@ -59,18 +63,20 @@ import {
5963
createMessagesQuery,
6064
createNotificationContextsQuery,
6165
createNotificationsQuery,
66+
createLabelsQuery,
6267
initLiveQueries
6368
} from '@hcengineering/communication-client-query'
6469

6570
import { getCurrentWorkspaceUuid, getFilesUrl } from './file'
6671

67-
export { createMessagesQuery, createNotificationsQuery, createNotificationContextsQuery }
72+
export { createMessagesQuery, createNotificationsQuery, createNotificationContextsQuery, createLabelsQuery }
6873

6974
interface Connection extends PlatformConnection {
7075
findMessages: (params: FindMessagesParams, queryId?: number) => Promise<Message[]>
7176
findMessagesGroups: (params: FindMessagesGroupsParams) => Promise<MessagesGroup[]>
7277
findNotificationContexts: (params: FindNotificationContextParams, queryId?: number) => Promise<NotificationContext[]>
7378
findNotifications: (params: FindNotificationsParams, queryId?: number) => Promise<Notification[]>
79+
findLabels: (params: FindLabelsParams) => Promise<Label[]>
7480
sendEvent: (event: RequestEvent) => Promise<EventResult>
7581
unsubscribeQuery: (id: number) => Promise<void>
7682
}
@@ -115,7 +121,7 @@ class Client {
115121

116122
async createThread (card: CardID, message: MessageID, thread: CardID): Promise<void> {
117123
const event: CreateThreadEvent = {
118-
type: RequestEventType.CreateThread,
124+
type: MessageRequestEventType.CreateThread,
119125
card,
120126
message,
121127
thread
@@ -124,11 +130,12 @@ class Client {
124130
await this.sendEvent(event)
125131
}
126132

127-
async createMessage (card: CardID, content: RichText): Promise<MessageID> {
133+
async createMessage (card: CardID, cardType: CardType, content: RichText): Promise<MessageID> {
128134
const event: CreateMessageEvent = {
129-
type: RequestEventType.CreateMessage,
135+
type: MessageRequestEventType.CreateMessage,
130136
messageType: MessageType.Message,
131137
card,
138+
cardType,
132139
content,
133140
creator: this.getSocialId()
134141
}
@@ -138,7 +145,7 @@ class Client {
138145

139146
async updateMessage (card: CardID, message: MessageID, content: RichText): Promise<void> {
140147
const event: CreatePatchEvent = {
141-
type: RequestEventType.CreatePatch,
148+
type: MessageRequestEventType.CreatePatch,
142149
patchType: PatchType.update,
143150
card,
144151
message,
@@ -150,7 +157,7 @@ class Client {
150157

151158
async createReaction (card: CardID, message: MessageID, reaction: string): Promise<void> {
152159
const event: CreateReactionEvent = {
153-
type: RequestEventType.CreateReaction,
160+
type: MessageRequestEventType.CreateReaction,
154161
card,
155162
message,
156163
reaction,
@@ -161,7 +168,7 @@ class Client {
161168

162169
async removeReaction (card: CardID, message: MessageID, reaction: string): Promise<void> {
163170
const event: RemoveReactionEvent = {
164-
type: RequestEventType.RemoveReaction,
171+
type: MessageRequestEventType.RemoveReaction,
165172
card,
166173
message,
167174
reaction,
@@ -179,7 +186,7 @@ class Client {
179186
size: number
180187
): Promise<void> {
181188
const event: CreateFileEvent = {
182-
type: RequestEventType.CreateFile,
189+
type: MessageRequestEventType.CreateFile,
183190
card,
184191
message,
185192
blobId,
@@ -193,7 +200,7 @@ class Client {
193200

194201
async removeFile (card: CardID, message: MessageID, blobId: BlobID): Promise<void> {
195202
const event: RemoveFileEvent = {
196-
type: RequestEventType.RemoveFile,
203+
type: MessageRequestEventType.RemoveFile,
197204
card,
198205
message,
199206
blobId,
@@ -204,7 +211,7 @@ class Client {
204211

205212
async updateNotificationContext (context: ContextID, lastView?: Date): Promise<void> {
206213
const event: UpdateNotificationContextEvent = {
207-
type: RequestEventType.UpdateNotificationContext,
214+
type: NotificationRequestEventType.UpdateNotificationContext,
208215
context,
209216
account: this.getAccount(),
210217
lastView
@@ -231,6 +238,10 @@ class Client {
231238
return await this.connection.findNotifications(params, queryId)
232239
}
233240

241+
async findLabels (params: FindLabelsParams): Promise<Label[]> {
242+
return await this.connection.findLabels(params)
243+
}
244+
234245
async unsubscribeQuery (id: number): Promise<void> {
235246
await this.connection.unsubscribeQuery(id)
236247
}

packages/ui-next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@hcengineering/analytics": "^0.6.0",
4343
"@hcengineering/attachment-resources": "^0.6.0",
4444
"@hcengineering/card": "^0.6.0",
45-
"@hcengineering/communication-types": "0.1.155",
45+
"@hcengineering/communication-types": "0.1.166",
4646
"@hcengineering/contact": "^0.6.24",
4747
"@hcengineering/contact-resources": "^0.6.0",
4848
"@hcengineering/core": "^0.6.32",

packages/ui-next/src/components/message/MessageInput.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import { Markup, RateLimiter } from '@hcengineering/core'
1919
import { tick, createEventDispatcher, onDestroy } from 'svelte'
2020
import { uploadFile, deleteFile, getCommunicationClient } from '@hcengineering/presentation'
21-
import { MessageID, CardID } from '@hcengineering/communication-types'
21+
import { MessageID, CardID, CardType } from '@hcengineering/communication-types'
2222
import { AttachmentPresenter } from '@hcengineering/attachment-resources'
2323
2424
import TextInput from '../TextInput.svelte'
@@ -28,6 +28,7 @@
2828
import { type TextInputAction, UploadedFile } from '../../types'
2929
3030
export let cardId: CardID | undefined = undefined
31+
export let cardType: CardType | undefined = undefined
3132
export let messageId: MessageID | undefined = undefined
3233
export let content: Markup | undefined = undefined
3334
export let placeholder: IntlString | undefined = undefined
@@ -66,8 +67,8 @@
6667
}
6768
6869
async function createMessage (markdown: string, files: UploadedFile[]): Promise<void> {
69-
if (cardId === undefined) return
70-
const id = await communicationClient.createMessage(cardId, markdown)
70+
if (cardId === undefined || cardType === undefined) return
71+
const id = await communicationClient.createMessage(cardId, cardType, markdown)
7172
7273
for (const file of files) {
7374
await communicationClient.createFile(cardId, id, file.blobId, file.type, file.filename, file.size)

plugins/activity-resources/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"@hcengineering/ui-next": "^0.6.0",
5252
"@hcengineering/view": "^0.6.13",
5353
"@hcengineering/view-resources": "^0.6.0",
54-
"@hcengineering/communication-types": "0.1.155",
54+
"@hcengineering/communication-types": "0.1.166",
5555
"svelte": "^4.2.19"
5656
}
5757
}

plugins/activity-resources/src/components/NewActivity.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
</div>
9797
{#if showInput}
9898
<div class="ref-input oldest-first">
99-
<MessageInput cardId={object._id} placeholder={activity.string.Message} />
99+
<MessageInput cardId={object._id} cardType={object._class} placeholder={activity.string.Message} />
100100
</div>
101101
{/if}
102102
</svelte:fragment>

plugins/card-assets/lang/cs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"MasterDetailViews": "Zobrazení master-detail",
3636
"SelectType": "Vybrat typ",
3737
"CreateSpace": "Vytvořit prostor",
38-
"NumberTypes": "{count, plural, one {# typ} few {# typy} other {# typů}}"
38+
"NumberTypes": "{count, plural, one {# typ} few {# typy} other {# typů}}",
39+
"Labels": "Štítky"
3940
}
4041
}

plugins/card-assets/lang/de.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"MasterDetailViews": "Master-Detail-Ansichten",
3636
"SelectType": "Typ auswählen",
3737
"CreateSpace": "Raum erstellen",
38-
"NumberTypes": "{count, plural, one {# typ} other {# typen}}"
38+
"NumberTypes": "{count, plural, one {# typ} other {# typen}}",
39+
"Labels": "Labels"
3940
}
4041
}

plugins/card-assets/lang/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"MasterDetailViews": "Master Detail Views",
3636
"SelectType": "Select Type",
3737
"CreateSpace": "Create space",
38-
"NumberTypes": "{count, plural, one {# type} other {# types}}"
38+
"NumberTypes": "{count, plural, one {# type} other {# types}}",
39+
"Labels": "Labels"
3940
}
4041
}

plugins/card-assets/lang/es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"MasterDetailViews": "Vistas Maestro-Detalle",
3636
"SelectType": "Seleccionar tipo",
3737
"CreateSpace": "Crear espacio",
38-
"NumberTypes": "{count, plural, one {# tipo} other {# tipos}}"
38+
"NumberTypes": "{count, plural, one {# tipo} other {# tipos}}",
39+
"Labels": "Etiquetas"
3940
}
4041
}

plugins/card-assets/lang/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"MasterDetailViews": "Vues maître-détail",
3636
"SelectType": "Sélectionner le type",
3737
"CreateSpace": "Créer un espace",
38-
"NumberTypes": "{count, plural, one {# type} other {# types}}"
38+
"NumberTypes": "{count, plural, one {# type} other {# types}}",
39+
"Labels": "Étiquettes"
3940
}
4041
}

0 commit comments

Comments
 (0)