From 1e9fea356ea31c0095ffe7e07996ab638f628a16 Mon Sep 17 00:00:00 2001 From: Kristina Date: Tue, 18 Jun 2024 16:21:51 +0400 Subject: [PATCH] UBERF-7239: Support short/custom links in inbox/chat/planner (#5815) Signed-off-by: Kristina Fefelova --- models/document/src/index.ts | 5 + models/recruit/src/index.ts | 20 +++ models/recruit/src/plugin.ts | 3 +- models/server-document/package.json | 3 +- models/server-document/src/index.ts | 5 + models/server-recruit/package.json | 3 +- models/server-recruit/src/index.ts | 17 +++ models/server-tracker/package.json | 4 +- models/server-tracker/src/index.ts | 5 + models/server-view/package.json | 5 +- models/server-view/src/index.ts | 17 ++- models/tracker/src/index.ts | 5 + models/view/src/index.ts | 12 +- packages/ui/src/panelup.ts | 4 +- .../src/components/chat/Chat.svelte | 47 ++++--- .../chat/navigator/ChatNavGroup.svelte | 3 +- .../chat/navigator/ChatNavItem.svelte | 7 +- .../chat/navigator/ChatNavigator.svelte | 3 +- plugins/chunter-resources/src/navigation.ts | 91 ++++++++++---- plugins/chunter-resources/src/utils.ts | 48 +++---- plugins/document-resources/src/index.ts | 14 ++- plugins/document-resources/src/plugin.ts | 6 +- plugins/document-resources/src/utils.ts | 17 ++- .../src/components/Guest.svelte | 19 ++- .../src/components/inbox/Inbox.svelte | 70 ++--------- plugins/notification-resources/src/utils.ts | 119 ++++++++++++++++-- plugins/notification/src/index.ts | 1 - plugins/recruit-resources/src/index.ts | 4 +- plugins/recruit-resources/src/plugin.ts | 2 +- plugins/recruit-resources/src/utils.ts | 47 ++++++- .../src/components/ToDos.svelte | 1 - .../src/components/WorkItemPresenter.svelte | 10 +- .../components/issues/edit/EditIssue.svelte | 42 ++++--- plugins/tracker-resources/src/index.ts | 2 + plugins/tracker-resources/src/issues.ts | 9 +- plugins/tracker-resources/src/plugin.ts | 7 +- .../src/components/EditDoc.svelte | 35 ++++-- plugins/view-resources/src/utils.ts | 53 +++++++- plugins/view/src/index.ts | 5 +- plugins/view/src/types.ts | 5 + plugins/{notification => view}/src/utils.ts | 4 +- .../src/components/Workbench.svelte | 19 ++- .../document-resources/src/index.ts | 7 +- server-plugins/document/package.json | 1 + server-plugins/document/src/index.ts | 4 +- .../notification-resources/package.json | 1 + .../notification-resources/src/index.ts | 28 +++-- server-plugins/recruit-resources/src/index.ts | 3 +- server-plugins/recruit/package.json | 3 +- server-plugins/recruit/src/index.ts | 4 +- server-plugins/tracker-resources/src/index.ts | 7 +- server-plugins/tracker/package.json | 3 +- server-plugins/tracker/src/index.ts | 4 +- server-plugins/view/package.json | 1 + server-plugins/view/src/index.ts | 10 +- 55 files changed, 630 insertions(+), 244 deletions(-) rename plugins/{notification => view}/src/utils.ts (85%) diff --git a/models/document/src/index.ts b/models/document/src/index.ts index ce4dd7eddf..4c577d450d 100644 --- a/models/document/src/index.ts +++ b/models/document/src/index.ts @@ -301,6 +301,11 @@ function defineDocument (builder: Builder): void { encode: document.function.GetObjectLinkFragment }) + builder.mixin(document.class.Document, core.class.Class, view.mixin.LinkIdProvider, { + encode: document.function.GetDocumentLinkId, + decode: document.function.ParseDocumentId + }) + builder.mixin(document.class.Document, core.class.Class, view.mixin.ObjectIcon, { component: document.component.DocumentIcon }) diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index c1e6c7aaa9..d2e7f53a83 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -932,6 +932,26 @@ export function createModel (builder: Builder): void { encode: recruit.function.GetIdObjectLinkFragment }) + builder.mixin(recruit.class.Applicant, core.class.Class, view.mixin.LinkIdProvider, { + encode: recruit.function.IdProvider, + decode: recruit.function.ParseLinkId + }) + + builder.mixin(recruit.class.Opinion, core.class.Class, view.mixin.LinkIdProvider, { + encode: recruit.function.IdProvider, + decode: recruit.function.ParseLinkId + }) + + builder.mixin(recruit.class.Review, core.class.Class, view.mixin.LinkIdProvider, { + encode: recruit.function.IdProvider, + decode: recruit.function.ParseLinkId + }) + + builder.mixin(recruit.class.Vacancy, core.class.Class, view.mixin.LinkIdProvider, { + encode: recruit.function.IdProvider, + decode: recruit.function.ParseLinkId + }) + builder.createDoc( view.class.ActionCategory, core.space.Model, diff --git a/models/recruit/src/plugin.ts b/models/recruit/src/plugin.ts index 2931af86b4..13c0f704db 100644 --- a/models/recruit/src/plugin.ts +++ b/models/recruit/src/plugin.ts @@ -58,7 +58,8 @@ export default mergeIds(recruitId, recruit, { GetTalentId: '' as Resource<(doc: Doc, props: Record) => Promise>, HideDoneState: '' as ViewQueryAction, HideArchivedVacancies: '' as ViewQueryAction, - ApplicantHasEmail: '' as Resource + ApplicantHasEmail: '' as Resource, + ParseLinkId: '' as Resource<(id: string) => Promise | undefined>> }, string: { ApplicationsShort: '' as IntlString, diff --git a/models/server-document/package.json b/models/server-document/package.json index c7ae3c364a..c107c49dc8 100644 --- a/models/server-document/package.json +++ b/models/server-document/package.json @@ -35,6 +35,7 @@ "@hcengineering/server-notification": "^0.6.1", "@hcengineering/model-core": "^0.6.0", "@hcengineering/document": "^0.6.0", - "@hcengineering/server-document": "^0.6.0" + "@hcengineering/server-document": "^0.6.0", + "@hcengineering/server-view": "^0.6.0" } } diff --git a/models/server-document/src/index.ts b/models/server-document/src/index.ts index 971165e197..4ceb709be7 100644 --- a/models/server-document/src/index.ts +++ b/models/server-document/src/index.ts @@ -10,6 +10,7 @@ import document from '@hcengineering/document' import serverCore from '@hcengineering/server-core' import serverDocument from '@hcengineering/server-document' import serverNotification from '@hcengineering/server-notification' +import serverView from '@hcengineering/server-view' export { serverDocumentId } from '@hcengineering/server-document' @@ -22,6 +23,10 @@ export function createModel (builder: Builder): void { presenter: serverDocument.function.DocumentTextPresenter }) + builder.mixin(document.class.Document, core.class.Class, serverView.mixin.ServerLinkIdProvider, { + encode: serverDocument.function.DocumentLinkIdProvider + }) + builder.mixin(document.class.Document, core.class.Class, serverCore.mixin.SearchPresenter, { searchConfig: { iconConfig: { diff --git a/models/server-recruit/package.json b/models/server-recruit/package.json index f1fd2509a9..2265c450e1 100644 --- a/models/server-recruit/package.json +++ b/models/server-recruit/package.json @@ -37,6 +37,7 @@ "@hcengineering/server-core": "^0.6.1", "@hcengineering/model-recruit": "^0.6.0", "@hcengineering/notification": "^0.6.23", - "@hcengineering/server-notification": "^0.6.1" + "@hcengineering/server-notification": "^0.6.1", + "@hcengineering/server-view": "^0.6.0" } } diff --git a/models/server-recruit/src/index.ts b/models/server-recruit/src/index.ts index c33b390368..1ffa4c9bd7 100644 --- a/models/server-recruit/src/index.ts +++ b/models/server-recruit/src/index.ts @@ -23,6 +23,7 @@ import serverNotification from '@hcengineering/server-notification' import serverRecruit from '@hcengineering/server-recruit' import serverContact from '@hcengineering/server-contact' import contact from '@hcengineering/contact' +import serverView from '@hcengineering/server-view' export { serverRecruitId } from '@hcengineering/server-recruit' @@ -43,6 +44,22 @@ export function createModel (builder: Builder): void { presenter: serverRecruit.function.VacancyTextPresenter }) + builder.mixin(recruit.class.Applicant, core.class.Class, serverView.mixin.ServerLinkIdProvider, { + encode: serverRecruit.function.LinkIdProvider + }) + + builder.mixin(recruit.class.Opinion, core.class.Class, serverView.mixin.ServerLinkIdProvider, { + encode: serverRecruit.function.LinkIdProvider + }) + + builder.mixin(recruit.class.Review, core.class.Class, serverView.mixin.ServerLinkIdProvider, { + encode: serverRecruit.function.LinkIdProvider + }) + + builder.mixin(recruit.class.Vacancy, core.class.Class, serverView.mixin.ServerLinkIdProvider, { + encode: serverRecruit.function.LinkIdProvider + }) + builder.createDoc(serverCore.class.Trigger, core.space.Model, { trigger: serverRecruit.trigger.OnRecruitUpdate }) diff --git a/models/server-tracker/package.json b/models/server-tracker/package.json index ecc154547d..7c3ed4f863 100644 --- a/models/server-tracker/package.json +++ b/models/server-tracker/package.json @@ -36,6 +36,8 @@ "@hcengineering/server-notification": "^0.6.1", "@hcengineering/model-tracker": "^0.6.0", "@hcengineering/server-tracker": "^0.6.0", - "@hcengineering/contact": "^0.6.24" + "@hcengineering/contact": "^0.6.24", + "@hcengineering/model-core": "^0.6.0", + "@hcengineering/server-view": "^0.6.0" } } diff --git a/models/server-tracker/src/index.ts b/models/server-tracker/src/index.ts index 3ce5a79c3a..8796d1f85e 100644 --- a/models/server-tracker/src/index.ts +++ b/models/server-tracker/src/index.ts @@ -21,6 +21,7 @@ import serverCore from '@hcengineering/server-core' import serverNotification from '@hcengineering/server-notification' import serverTracker from '@hcengineering/server-tracker' import contact from '@hcengineering/contact' +import serverView from '@hcengineering/server-view' export { serverTrackerId } from '@hcengineering/server-tracker' @@ -37,6 +38,10 @@ export function createModel (builder: Builder): void { presenter: serverTracker.function.IssueNotificationContentProvider }) + builder.mixin(tracker.class.Issue, core.class.Class, serverView.mixin.ServerLinkIdProvider, { + encode: serverTracker.function.IssueLinkIdProvider + }) + builder.mixin(tracker.class.Issue, core.class.Class, serverCore.mixin.SearchPresenter, { searchConfig: { iconConfig: { diff --git a/models/server-view/package.json b/models/server-view/package.json index 6c072e0e74..832090612b 100644 --- a/models/server-view/package.json +++ b/models/server-view/package.json @@ -30,8 +30,9 @@ "dependencies": { "@hcengineering/core": "^0.6.32", "@hcengineering/model": "^0.6.11", + "@hcengineering/model-core": "^0.6.0", "@hcengineering/platform": "^0.6.11", - "@hcengineering/server-view": "^0.6.0", - "@hcengineering/server-core": "^0.6.1" + "@hcengineering/server-core": "^0.6.1", + "@hcengineering/server-view": "^0.6.0" } } diff --git a/models/server-view/src/index.ts b/models/server-view/src/index.ts index c405e6c8f2..dec068e8f0 100644 --- a/models/server-view/src/index.ts +++ b/models/server-view/src/index.ts @@ -13,14 +13,23 @@ // limitations under the License. // -import core from '@hcengineering/core' -import { type Builder } from '@hcengineering/model' -import serverCore from '@hcengineering/server-core' -import serverView from '@hcengineering/server-view' +import core, { type Doc } from '@hcengineering/core' +import { type Builder, Mixin } from '@hcengineering/model' +import serverCore, { type TriggerControl } from '@hcengineering/server-core' +import serverView, { type ServerLinkIdProvider } from '@hcengineering/server-view' +import { TClass } from '@hcengineering/model-core' +import { type Resource } from '@hcengineering/platform' export { serverViewId } from '@hcengineering/server-view' +@Mixin(serverView.mixin.ServerLinkIdProvider, core.class.Class) +export class TServerLinkIdProvider extends TClass implements ServerLinkIdProvider { + encode!: Resource<(doc: Doc, control: TriggerControl) => Promise> +} + export function createModel (builder: Builder): void { + builder.createModel(TServerLinkIdProvider) + builder.createDoc(serverCore.class.Trigger, core.space.Model, { trigger: serverView.trigger.OnCustomAttributeRemove }) diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index 5840b623f5..75b87f5a3c 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -438,6 +438,11 @@ export function createModel (builder: Builder): void { builder.mixin(tracker.class.Component, core.class.Class, activity.mixin.ActivityDoc, {}) builder.mixin(tracker.class.IssueTemplate, core.class.Class, activity.mixin.ActivityDoc, {}) + builder.mixin(tracker.class.Issue, core.class.Class, view.mixin.LinkIdProvider, { + encode: tracker.function.GetIssueId, + decode: tracker.function.GetIssueIdByIdentifier + }) + builder.createDoc(activity.class.ActivityMessageControl, core.space.Model, { objectClass: tracker.class.Issue, skip: [ diff --git a/models/view/src/index.ts b/models/view/src/index.ts index 8b378b6a8b..8f85ea5c85 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -90,7 +90,8 @@ import { type ObjectIcon, type ObjectTooltip, type AttrPresenter, - type AttributeCategory + type AttributeCategory, + type LinkIdProvider } from '@hcengineering/view' import view from './plugin' @@ -352,6 +353,12 @@ export class TLinkProvider extends TClass implements LinkProvider { encode!: Resource<(doc: Doc, props: Record) => Promise> } +@Mixin(view.mixin.LinkIdProvider, core.class.Class) +export class TLinkIdProvider extends TClass implements LinkIdProvider { + encode!: Resource<(doc: Doc) => Promise> + decode!: Resource<(id: string) => Promise | undefined>> +} + @Mixin(view.mixin.ObjectPanel, core.class.Class) export class TObjectPanel extends TClass implements ObjectPanel { component!: AnyComponent @@ -450,7 +457,8 @@ export function createModel (builder: Builder): void { TObjectIdentifier, TObjectTooltip, TObjectIcon, - TAttrPresenter + TAttrPresenter, + TLinkIdProvider ) classPresenter( diff --git a/packages/ui/src/panelup.ts b/packages/ui/src/panelup.ts index 253f9903f2..f710d7d384 100644 --- a/packages/ui/src/panelup.ts +++ b/packages/ui/src/panelup.ts @@ -53,12 +53,12 @@ export function openPanel ( }) } -export function closePanel (shoulRedirect: boolean = true): void { +export function closePanel (shouldRedirect: boolean = true): void { currentLocation = undefined panelstore.update(() => { return { panel: undefined } }) - if (shoulRedirect) { + if (shouldRedirect) { const loc = getLocation() loc.fragment = undefined navigate(loc) diff --git a/plugins/chunter-resources/src/components/chat/Chat.svelte b/plugins/chunter-resources/src/components/chat/Chat.svelte index 48d6faaf86..a4d69b2b94 100644 --- a/plugins/chunter-resources/src/components/chat/Chat.svelte +++ b/plugins/chunter-resources/src/components/chat/Chat.svelte @@ -14,7 +14,7 @@ --> diff --git a/plugins/tracker-resources/src/components/issues/edit/EditIssue.svelte b/plugins/tracker-resources/src/components/issues/edit/EditIssue.svelte index 93a49816ba..3086a78015 100644 --- a/plugins/tracker-resources/src/components/issues/edit/EditIssue.svelte +++ b/plugins/tracker-resources/src/components/issues/edit/EditIssue.svelte @@ -15,9 +15,7 @@