mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-07 00:09:34 +00:00
Board: Update server-plugin for task to subscribe to updates on create & update (#1925)
Signed-off-by: Anna No <anna.no@xored.com>
This commit is contained in:
parent
e97a6cb6f5
commit
df9115b75a
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
Platform:
|
Platform:
|
||||||
|
|
||||||
|
- Fix subscribe to updates on Task create / update
|
||||||
- Fix popup window layouts
|
- Fix popup window layouts
|
||||||
- Fix table two loading spinners
|
- Fix table two loading spinners
|
||||||
- Improve full text search performance
|
- Improve full text search performance
|
||||||
|
@ -16,18 +16,11 @@
|
|||||||
|
|
||||||
import type { Doc, Ref, Tx, TxCollectionCUD, TxCreateDoc, TxRemoveDoc } from '@anticrm/core'
|
import type { Doc, Ref, Tx, TxCollectionCUD, TxCreateDoc, TxRemoveDoc } from '@anticrm/core'
|
||||||
import type { TriggerControl } from '@anticrm/server-core'
|
import type { TriggerControl } from '@anticrm/server-core'
|
||||||
|
import { extractTx } from '@anticrm/server-core'
|
||||||
import type { Attachment } from '@anticrm/attachment'
|
import type { Attachment } from '@anticrm/attachment'
|
||||||
import attachment from '@anticrm/attachment'
|
import attachment from '@anticrm/attachment'
|
||||||
import core, { TxProcessor } from '@anticrm/core'
|
import core, { TxProcessor } from '@anticrm/core'
|
||||||
|
|
||||||
const extractTx = (tx: Tx): Tx => {
|
|
||||||
if (tx._class === core.class.TxCollectionCUD) {
|
|
||||||
return (tx as TxCollectionCUD<Doc, Attachment>).tx
|
|
||||||
}
|
|
||||||
|
|
||||||
return tx
|
|
||||||
}
|
|
||||||
|
|
||||||
const findCreateTx = async (
|
const findCreateTx = async (
|
||||||
id: Ref<Attachment>,
|
id: Ref<Attachment>,
|
||||||
findAll: TriggerControl['findAll']
|
findAll: TriggerControl['findAll']
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
import contact, { Channel } from '@anticrm/contact'
|
import contact, { Channel } from '@anticrm/contact'
|
||||||
import core, {
|
import core, {
|
||||||
AttachedDoc,
|
|
||||||
Class,
|
Class,
|
||||||
Doc,
|
Doc,
|
||||||
DocumentQuery,
|
DocumentQuery,
|
||||||
@ -24,28 +23,11 @@ import core, {
|
|||||||
Hierarchy,
|
Hierarchy,
|
||||||
Ref,
|
Ref,
|
||||||
Tx,
|
Tx,
|
||||||
TxCollectionCUD,
|
|
||||||
TxCreateDoc,
|
TxCreateDoc,
|
||||||
TxProcessor
|
TxProcessor
|
||||||
} from '@anticrm/core'
|
} from '@anticrm/core'
|
||||||
import gmail, { Message } from '@anticrm/gmail'
|
import gmail, { Message } from '@anticrm/gmail'
|
||||||
import { TriggerControl } from '@anticrm/server-core'
|
import { extractTx, TriggerControl } from '@anticrm/server-core'
|
||||||
|
|
||||||
const extractTx = (tx: Tx): Tx => {
|
|
||||||
if (tx._class === core.class.TxCollectionCUD) {
|
|
||||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
|
||||||
if (ctx.tx._class === core.class.TxCreateDoc) {
|
|
||||||
const create = ctx.tx as TxCreateDoc<AttachedDoc>
|
|
||||||
create.attributes.attachedTo = ctx.objectId
|
|
||||||
create.attributes.attachedToClass = ctx.objectClass
|
|
||||||
create.attributes.collection = ctx.collection
|
|
||||||
return create
|
|
||||||
}
|
|
||||||
return ctx.tx
|
|
||||||
}
|
|
||||||
|
|
||||||
return tx
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
|
@ -13,31 +13,15 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import core, { AttachedDoc, Doc, Tx, TxCollectionCUD, TxCreateDoc, TxProcessor, TxUpdateDoc } from '@anticrm/core'
|
import core, { Doc, Tx, TxCreateDoc, TxProcessor, TxUpdateDoc } from '@anticrm/core'
|
||||||
import inventory, { Product } from '@anticrm/inventory'
|
import inventory, { Product } from '@anticrm/inventory'
|
||||||
import login from '@anticrm/login'
|
import login from '@anticrm/login'
|
||||||
import { getMetadata } from '@anticrm/platform'
|
import { getMetadata } from '@anticrm/platform'
|
||||||
import { TriggerControl } from '@anticrm/server-core'
|
import { extractTx, TriggerControl } from '@anticrm/server-core'
|
||||||
import { getUpdateLastViewTx } from '@anticrm/server-notification'
|
import { getUpdateLastViewTx } from '@anticrm/server-notification'
|
||||||
import view from '@anticrm/view'
|
import view from '@anticrm/view'
|
||||||
import workbench from '@anticrm/workbench'
|
import workbench from '@anticrm/workbench'
|
||||||
|
|
||||||
const extractTx = (tx: Tx): Tx => {
|
|
||||||
if (tx._class === core.class.TxCollectionCUD) {
|
|
||||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
|
||||||
if (ctx.tx._class === core.class.TxCreateDoc) {
|
|
||||||
const create = ctx.tx as TxCreateDoc<AttachedDoc>
|
|
||||||
create.attributes.attachedTo = ctx.objectId
|
|
||||||
create.attributes.attachedToClass = ctx.objectClass
|
|
||||||
create.attributes.collection = ctx.collection
|
|
||||||
return create
|
|
||||||
}
|
|
||||||
return ctx.tx
|
|
||||||
}
|
|
||||||
|
|
||||||
return tx
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
|
@ -35,25 +35,10 @@ import core, {
|
|||||||
import notification, { EmailNotification, Notification, NotificationStatus } from '@anticrm/notification'
|
import notification, { EmailNotification, Notification, NotificationStatus } from '@anticrm/notification'
|
||||||
import { getResource } from '@anticrm/platform'
|
import { getResource } from '@anticrm/platform'
|
||||||
import type { TriggerControl } from '@anticrm/server-core'
|
import type { TriggerControl } from '@anticrm/server-core'
|
||||||
|
import { extractTx } from '@anticrm/server-core'
|
||||||
import { getUpdateLastViewTx } from '@anticrm/server-notification'
|
import { getUpdateLastViewTx } from '@anticrm/server-notification'
|
||||||
import view, { HTMLPresenter, TextPresenter } from '@anticrm/view'
|
import view, { HTMLPresenter, TextPresenter } from '@anticrm/view'
|
||||||
|
|
||||||
const extractTx = (tx: Tx): Tx => {
|
|
||||||
if (tx._class === core.class.TxCollectionCUD) {
|
|
||||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
|
||||||
if (ctx.tx._class === core.class.TxCreateDoc) {
|
|
||||||
const create = ctx.tx as TxCreateDoc<AttachedDoc>
|
|
||||||
create.attributes.attachedTo = ctx.objectId
|
|
||||||
create.attributes.attachedToClass = ctx.objectClass
|
|
||||||
create.attributes.collection = ctx.collection
|
|
||||||
return create
|
|
||||||
}
|
|
||||||
return ctx.tx
|
|
||||||
}
|
|
||||||
|
|
||||||
return tx
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import core, {
|
import core, {
|
||||||
AttachedDoc,
|
|
||||||
Class,
|
Class,
|
||||||
Doc,
|
Doc,
|
||||||
DocumentQuery,
|
DocumentQuery,
|
||||||
@ -23,31 +22,14 @@ import core, {
|
|||||||
Hierarchy,
|
Hierarchy,
|
||||||
Ref,
|
Ref,
|
||||||
Tx,
|
Tx,
|
||||||
TxCollectionCUD,
|
|
||||||
TxCreateDoc,
|
TxCreateDoc,
|
||||||
TxCUD,
|
TxCUD,
|
||||||
TxProcessor,
|
TxProcessor,
|
||||||
TxRemoveDoc
|
TxRemoveDoc
|
||||||
} from '@anticrm/core'
|
} from '@anticrm/core'
|
||||||
import { TriggerControl } from '@anticrm/server-core'
|
import { extractTx, TriggerControl } from '@anticrm/server-core'
|
||||||
import tags, { TagElement, TagReference } from '@anticrm/tags'
|
import tags, { TagElement, TagReference } from '@anticrm/tags'
|
||||||
|
|
||||||
const extractTx = (tx: Tx): Tx => {
|
|
||||||
if (tx._class === core.class.TxCollectionCUD) {
|
|
||||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
|
||||||
if (ctx.tx._class === core.class.TxCreateDoc) {
|
|
||||||
const create = ctx.tx as TxCreateDoc<AttachedDoc>
|
|
||||||
create.attributes.attachedTo = ctx.objectId
|
|
||||||
create.attributes.attachedToClass = ctx.objectClass
|
|
||||||
create.attributes.collection = ctx.collection
|
|
||||||
return create
|
|
||||||
}
|
|
||||||
return ctx.tx
|
|
||||||
}
|
|
||||||
|
|
||||||
return tx
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
import core, { Doc, Tx, TxCreateDoc, TxProcessor, TxUpdateDoc } from '@anticrm/core'
|
import core, { Doc, Tx, TxCreateDoc, TxProcessor, TxUpdateDoc } from '@anticrm/core'
|
||||||
import login from '@anticrm/login'
|
import login from '@anticrm/login'
|
||||||
import { getMetadata } from '@anticrm/platform'
|
import { getMetadata } from '@anticrm/platform'
|
||||||
import { TriggerControl } from '@anticrm/server-core'
|
import { extractTx, TriggerControl } from '@anticrm/server-core'
|
||||||
import { getUpdateLastViewTx } from '@anticrm/server-notification'
|
import { getUpdateLastViewTx } from '@anticrm/server-notification'
|
||||||
import task, { Issue, Task } from '@anticrm/task'
|
import task, { Issue, Task } from '@anticrm/task'
|
||||||
import view from '@anticrm/view'
|
import view from '@anticrm/view'
|
||||||
@ -43,11 +43,12 @@ export function issueTextPresenter (doc: Doc): string {
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export async function OnTaskCreate (tx: Tx, control: TriggerControl): Promise<Tx[]> {
|
export async function OnTaskCreate (tx: Tx, control: TriggerControl): Promise<Tx[]> {
|
||||||
if (tx._class !== core.class.TxCreateDoc) {
|
const actualTx = extractTx(tx)
|
||||||
|
if (actualTx._class !== core.class.TxCreateDoc) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
const createTx = tx as TxCreateDoc<Task>
|
const createTx = actualTx as TxCreateDoc<Task>
|
||||||
|
|
||||||
if (!control.hierarchy.isDerived(createTx.objectClass, task.class.Task)) {
|
if (!control.hierarchy.isDerived(createTx.objectClass, task.class.Task)) {
|
||||||
return []
|
return []
|
||||||
@ -89,11 +90,12 @@ export async function OnTaskCreate (tx: Tx, control: TriggerControl): Promise<Tx
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export async function OnTaskUpdate (tx: Tx, control: TriggerControl): Promise<Tx[]> {
|
export async function OnTaskUpdate (tx: Tx, control: TriggerControl): Promise<Tx[]> {
|
||||||
if (tx._class !== core.class.TxUpdateDoc) {
|
const actualTx = extractTx(tx)
|
||||||
|
if (actualTx._class !== core.class.TxUpdateDoc) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateTx = tx as TxUpdateDoc<Task>
|
const updateTx = actualTx as TxUpdateDoc<Task>
|
||||||
|
|
||||||
if (!control.hierarchy.isDerived(updateTx.objectClass, task.class.Task)) {
|
if (!control.hierarchy.isDerived(updateTx.objectClass, task.class.Task)) {
|
||||||
return []
|
return []
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
import contact, { Channel } from '@anticrm/contact'
|
import contact, { Channel } from '@anticrm/contact'
|
||||||
import core, {
|
import core, {
|
||||||
AttachedDoc,
|
|
||||||
Class,
|
Class,
|
||||||
Doc,
|
Doc,
|
||||||
DocumentQuery,
|
DocumentQuery,
|
||||||
@ -24,29 +23,12 @@ import core, {
|
|||||||
Hierarchy,
|
Hierarchy,
|
||||||
Ref,
|
Ref,
|
||||||
Tx,
|
Tx,
|
||||||
TxCollectionCUD,
|
|
||||||
TxCreateDoc,
|
TxCreateDoc,
|
||||||
TxProcessor
|
TxProcessor
|
||||||
} from '@anticrm/core'
|
} from '@anticrm/core'
|
||||||
import { TriggerControl } from '@anticrm/server-core'
|
import { extractTx, TriggerControl } from '@anticrm/server-core'
|
||||||
import telegram, { TelegramMessage } from '@anticrm/telegram'
|
import telegram, { TelegramMessage } from '@anticrm/telegram'
|
||||||
|
|
||||||
const extractTx = (tx: Tx): Tx => {
|
|
||||||
if (tx._class === core.class.TxCollectionCUD) {
|
|
||||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
|
||||||
if (ctx.tx._class === core.class.TxCreateDoc) {
|
|
||||||
const create = ctx.tx as TxCreateDoc<AttachedDoc>
|
|
||||||
create.attributes.attachedTo = ctx.objectId
|
|
||||||
create.attributes.attachedToClass = ctx.objectClass
|
|
||||||
create.attributes.collection = ctx.collection
|
|
||||||
return create
|
|
||||||
}
|
|
||||||
return ctx.tx
|
|
||||||
}
|
|
||||||
|
|
||||||
return tx
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
|
@ -19,4 +19,5 @@ export * from './types'
|
|||||||
export * from './fulltext'
|
export * from './fulltext'
|
||||||
export * from './storage'
|
export * from './storage'
|
||||||
export * from './pipeline'
|
export * from './pipeline'
|
||||||
|
export * from './utils'
|
||||||
export { default } from './plugin'
|
export { default } from './plugin'
|
||||||
|
@ -52,6 +52,7 @@ import { FullTextIndex } from './fulltext'
|
|||||||
import serverCore from './plugin'
|
import serverCore from './plugin'
|
||||||
import { Triggers } from './triggers'
|
import { Triggers } from './triggers'
|
||||||
import type { FullTextAdapter, FullTextAdapterFactory, ObjectDDParticipant } from './types'
|
import type { FullTextAdapter, FullTextAdapterFactory, ObjectDDParticipant } from './types'
|
||||||
|
import { extractTx } from './utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
@ -230,17 +231,8 @@ class TServerStorage implements ServerStorage {
|
|||||||
return doc
|
return doc
|
||||||
}
|
}
|
||||||
|
|
||||||
extractTx (tx: Tx): Tx {
|
|
||||||
if (tx._class === core.class.TxCollectionCUD) {
|
|
||||||
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
|
||||||
return ctx.tx
|
|
||||||
}
|
|
||||||
|
|
||||||
return tx
|
|
||||||
}
|
|
||||||
|
|
||||||
async processRemove (ctx: MeasureContext, tx: Tx): Promise<Tx[]> {
|
async processRemove (ctx: MeasureContext, tx: Tx): Promise<Tx[]> {
|
||||||
const actualTx = this.extractTx(tx)
|
const actualTx = extractTx(tx)
|
||||||
if (!this.hierarchy.isDerived(actualTx._class, core.class.TxRemoveDoc)) return []
|
if (!this.hierarchy.isDerived(actualTx._class, core.class.TxRemoveDoc)) return []
|
||||||
const rtx = actualTx as TxRemoveDoc<Doc>
|
const rtx = actualTx as TxRemoveDoc<Doc>
|
||||||
const result: Tx[] = []
|
const result: Tx[] = []
|
||||||
@ -316,7 +308,7 @@ class TServerStorage implements ServerStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async processMove (ctx: MeasureContext, tx: Tx): Promise<Tx[]> {
|
async processMove (ctx: MeasureContext, tx: Tx): Promise<Tx[]> {
|
||||||
const actualTx = this.extractTx(tx)
|
const actualTx = extractTx(tx)
|
||||||
if (!this.hierarchy.isDerived(actualTx._class, core.class.TxUpdateDoc)) return []
|
if (!this.hierarchy.isDerived(actualTx._class, core.class.TxUpdateDoc)) return []
|
||||||
const rtx = actualTx as TxUpdateDoc<Doc>
|
const rtx = actualTx as TxUpdateDoc<Doc>
|
||||||
if (rtx.operations.space === undefined || rtx.operations.space === rtx.objectSpace) return []
|
if (rtx.operations.space === undefined || rtx.operations.space === rtx.objectSpace) return []
|
||||||
|
20
server/core/src/utils.ts
Normal file
20
server/core/src/utils.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import core, { AttachedDoc, Doc, Tx, TxCollectionCUD, TxCreateDoc } from '@anticrm/core'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export function extractTx (tx: Tx): Tx {
|
||||||
|
if (tx._class === core.class.TxCollectionCUD) {
|
||||||
|
const ctx = tx as TxCollectionCUD<Doc, AttachedDoc>
|
||||||
|
if (ctx.tx._class === core.class.TxCreateDoc) {
|
||||||
|
const create = ctx.tx as TxCreateDoc<AttachedDoc>
|
||||||
|
create.attributes.attachedTo = ctx.objectId
|
||||||
|
create.attributes.attachedToClass = ctx.objectClass
|
||||||
|
create.attributes.collection = ctx.collection
|
||||||
|
return create
|
||||||
|
}
|
||||||
|
return ctx.tx
|
||||||
|
}
|
||||||
|
|
||||||
|
return tx
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user