Skip to content

Commit

Permalink
UBERF-7239: Support short/custom links in inbox/chat/planner (#5815)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristina Fefelova <[email protected]>
  • Loading branch information
kristina-fefelova authored Jun 18, 2024
1 parent 61a0833 commit 1e9fea3
Show file tree
Hide file tree
Showing 55 changed files with 630 additions and 244 deletions.
5 changes: 5 additions & 0 deletions models/document/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
20 changes: 20 additions & 0 deletions models/recruit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion models/recruit/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export default mergeIds(recruitId, recruit, {
GetTalentId: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<string>>,
HideDoneState: '' as ViewQueryAction,
HideArchivedVacancies: '' as ViewQueryAction,
ApplicantHasEmail: '' as Resource<ViewActionAvailabilityFunction>
ApplicantHasEmail: '' as Resource<ViewActionAvailabilityFunction>,
ParseLinkId: '' as Resource<(id: string) => Promise<Ref<Doc> | undefined>>
},
string: {
ApplicationsShort: '' as IntlString,
Expand Down
3 changes: 2 additions & 1 deletion models/server-document/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
5 changes: 5 additions & 0 deletions models/server-document/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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: {
Expand Down
3 changes: 2 additions & 1 deletion models/server-recruit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
17 changes: 17 additions & 0 deletions models/server-recruit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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
})
Expand Down
4 changes: 3 additions & 1 deletion models/server-tracker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
5 changes: 5 additions & 0 deletions models/server-tracker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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: {
Expand Down
5 changes: 3 additions & 2 deletions models/server-view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
17 changes: 13 additions & 4 deletions models/server-view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>>
}

export function createModel (builder: Builder): void {
builder.createModel(TServerLinkIdProvider)

builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverView.trigger.OnCustomAttributeRemove
})
Expand Down
5 changes: 5 additions & 0 deletions models/tracker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
12 changes: 10 additions & 2 deletions models/view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ import {
type ObjectIcon,
type ObjectTooltip,
type AttrPresenter,
type AttributeCategory
type AttributeCategory,
type LinkIdProvider
} from '@hcengineering/view'

import view from './plugin'
Expand Down Expand Up @@ -352,6 +353,12 @@ export class TLinkProvider extends TClass implements LinkProvider {
encode!: Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>
}

@Mixin(view.mixin.LinkIdProvider, core.class.Class)
export class TLinkIdProvider extends TClass implements LinkIdProvider {
encode!: Resource<(doc: Doc) => Promise<string>>
decode!: Resource<(id: string) => Promise<Ref<Doc> | undefined>>
}

@Mixin(view.mixin.ObjectPanel, core.class.Class)
export class TObjectPanel extends TClass implements ObjectPanel {
component!: AnyComponent
Expand Down Expand Up @@ -450,7 +457,8 @@ export function createModel (builder: Builder): void {
TObjectIdentifier,
TObjectTooltip,
TObjectIcon,
TAttrPresenter
TAttrPresenter,
TLinkIdProvider
)

classPresenter(
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/panelup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
47 changes: 31 additions & 16 deletions plugins/chunter-resources/src/components/chat/Chat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-->
<script lang="ts">
import { Doc, Ref, Class } from '@hcengineering/core'
import { createQuery } from '@hcengineering/presentation'
import { createQuery, getClient } from '@hcengineering/presentation'
import {
Component,
defineSeparators,
Expand All @@ -26,29 +26,32 @@
restoreLocation,
deviceOptionsStore as deviceInfo
} from '@hcengineering/ui'
import { NavigatorModel, SpecialNavModel } from '@hcengineering/workbench'
import { InboxNotificationsClientImpl } from '@hcengineering/notification-resources'
import { onMount } from 'svelte'
import { chunterId } from '@hcengineering/chunter'
import { ActivityMessage } from '@hcengineering/activity'
import view, { decodeObjectURI } from '@hcengineering/view'
import { parseLinkId, getObjectLinkId } from '@hcengineering/view-resources'
import ChatNavigator from './navigator/ChatNavigator.svelte'
import ChannelView from '../ChannelView.svelte'
import { chatSpecials, loadSavedAttachments } from './utils'
import { SelectChannelEvent } from './types'
import { decodeChannelURI, openChannel } from '../../navigation'
import { openChannel } from '../../navigation'
const notificationsClient = InboxNotificationsClientImpl.getClient()
const contextByDocStore = notificationsClient.contextByDoc
const objectQuery = createQuery()
const client = getClient()
const navigatorModel: NavigatorModel = {
spaces: [],
specials: chatSpecials
}
let selectedData: { _id: Ref<Doc>, _class: Ref<Class<Doc>> } | undefined = undefined
const linkProviders = client.getModel().findAllSync(view.mixin.LinkIdProvider, {})
let selectedData: { id: string, _class: Ref<Class<Doc>> } | undefined = undefined
let currentSpecial: SpecialNavModel | undefined
Expand All @@ -58,10 +61,18 @@
syncLocation(loc)
})
$: void loadObject(selectedData?._id, selectedData?._class)
$: void loadObject(selectedData?.id, selectedData?._class)
async function loadObject (_id?: Ref<Doc>, _class?: Ref<Class<Doc>>): Promise<void> {
if (_id == null || _class == null || _class === '') {
async function loadObject (id?: string, _class?: Ref<Class<Doc>>): Promise<void> {
if (id == null || _class == null || _class === '') {
object = undefined
objectQuery.unsubscribe()
return
}
const _id: Ref<Doc> | undefined = await parseLinkId(linkProviders, id, _class)
if (_id === undefined) {
object = undefined
objectQuery.unsubscribe()
return
Expand All @@ -84,7 +95,7 @@
const id = loc.path[3]
if (!id) {
if (id == null || id === '') {
currentSpecial = undefined
selectedData = undefined
object = undefined
Expand All @@ -98,26 +109,30 @@
selectedData = undefined
object = undefined
} else {
const [_id, _class] = decodeChannelURI(loc.path[3])
selectedData = { _id, _class }
const [id, _class] = decodeObjectURI(loc.path[3])
selectedData = { id, _class }
}
}
function handleChannelSelected (event: CustomEvent): void {
async function handleChannelSelected (event: CustomEvent): Promise<void> {
if (event.detail === null) {
selectedData = undefined
return
}
const detail = (event.detail ?? {}) as SelectChannelEvent
const _class = detail.object._class
const _id = detail.object._id
const id = await getObjectLinkId(linkProviders, _id, _class, detail.object)
selectedData = { _id: detail.object._id, _class: detail.object._class }
selectedData = { id, _class }
if (selectedData._id !== object?._id) {
if (_id !== object?._id) {
object = detail.object
}
openChannel(selectedData._id, selectedData._class)
openChannel(selectedData.id, selectedData._class)
}
defineSeparators('chat', [
Expand All @@ -134,7 +149,7 @@
{#if $deviceInfo.navigator.visible}
<div class="antiPanel-navigator {$deviceInfo.navigator.direction === 'horizontal' ? 'portrait' : 'landscape'}">
<div class="antiPanel-wrap__content hulyNavPanel-container">
<ChatNavigator objectId={selectedData?._id} {object} {currentSpecial} on:select={handleChannelSelected} />
<ChatNavigator {object} {currentSpecial} on:select={handleChannelSelected} />
</div>
<Separator name="chat" float={$deviceInfo.navigator.float ? 'navigator' : true} index={0} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import ChatNavSection from './ChatNavSection.svelte'
import chunter from '../../../plugin'
export let objectId: Ref<Doc> | undefined
export let object: Doc | undefined
export let model: ChatNavGroupModel
Expand Down Expand Up @@ -191,7 +190,7 @@
id={section.id}
objects={section.objects}
{contexts}
{objectId}
objectId={object?._id}
header={section.label}
actions={getSectionActions(section, contexts)}
sortFn={model.sortFn}
Expand Down
Loading

0 comments on commit 1e9fea3

Please sign in to comment.