mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 03:22:19 +03:00
UBER-708: Github related fixes (#4704)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
b49762fe03
commit
f70bdbb469
@ -130,11 +130,14 @@ export interface DisplayDocUpdateMessage extends DocUpdateMessage {
|
|||||||
* Designed to control and filter some of changes from being to be propagated into activity.
|
* Designed to control and filter some of changes from being to be propagated into activity.
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export interface ActivityMessageControl extends Doc {
|
export interface ActivityMessageControl<T extends Doc = Doc> extends Doc {
|
||||||
objectClass: Ref<Class<Doc>>
|
objectClass: Ref<Class<Doc>>
|
||||||
|
|
||||||
// A set of rules to be skipped from generate doc update activity messages
|
// A set of rules to be skipped from generate doc update activity messages
|
||||||
skip: DocumentQuery<Tx>[]
|
skip: DocumentQuery<Tx>[]
|
||||||
|
|
||||||
|
// Skip field activity operations.
|
||||||
|
skipFields?: (keyof T)[]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -148,6 +151,9 @@ export interface ActivityInfoMessage extends ActivityMessage {
|
|||||||
props?: Record<string, any>
|
props?: Record<string, any>
|
||||||
icon?: Asset
|
icon?: Asset
|
||||||
iconProps?: Record<string, any>
|
iconProps?: Record<string, any>
|
||||||
|
|
||||||
|
// A possible set of links to some platform resources.
|
||||||
|
links?: { _class: Ref<Class<Doc>>, _id: Ref<Doc> }[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ActivityMessageExtensionKind = 'action' | 'footer'
|
export type ActivityMessageExtensionKind = 'action' | 'footer'
|
||||||
|
@ -110,10 +110,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$: subIssueValue = sortedSubIssues.map((iss) => {
|
$: subIssueValue = sortedSubIssues.map((iss) => {
|
||||||
const project = iss.$lookup?.space
|
const status = iss.$lookup?.status as WithLookup<IssueStatus> | undefined
|
||||||
const status = iss.$lookup?.status as WithLookup<IssueStatus>
|
const icon = status?.$lookup?.category?.icon
|
||||||
const icon = status.$lookup?.category?.icon
|
const color = status?.color ?? status?.$lookup?.category?.color
|
||||||
const color = status.color ?? status.$lookup?.category?.color
|
|
||||||
|
|
||||||
const c = $statusStore.byId.get(iss.status)?.category
|
const c = $statusStore.byId.get(iss.status)?.category
|
||||||
const category = c !== undefined ? categories.get(c) : undefined
|
const category = c !== undefined ? categories.get(c) : undefined
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import activity, { ActivityMessage, DocUpdateMessage, Reaction } from '@hcengineering/activity'
|
import activity, { ActivityMessage, ActivityMessageControl, DocUpdateMessage, Reaction } from '@hcengineering/activity'
|
||||||
import core, {
|
import core, {
|
||||||
Account,
|
Account,
|
||||||
AttachedDoc,
|
AttachedDoc,
|
||||||
@ -150,7 +150,8 @@ async function pushDocUpdateMessages (
|
|||||||
object: Doc | undefined,
|
object: Doc | undefined,
|
||||||
originTx: TxCUD<Doc>,
|
originTx: TxCUD<Doc>,
|
||||||
modifiedBy?: Ref<Account>,
|
modifiedBy?: Ref<Account>,
|
||||||
objectCache?: DocObjectCache
|
objectCache?: DocObjectCache,
|
||||||
|
controlRules?: ActivityMessageControl[]
|
||||||
): Promise<TxCollectionCUD<Doc, DocUpdateMessage>[]> {
|
): Promise<TxCollectionCUD<Doc, DocUpdateMessage>[]> {
|
||||||
if (object === undefined) {
|
if (object === undefined) {
|
||||||
return res
|
return res
|
||||||
@ -178,7 +179,7 @@ async function pushDocUpdateMessages (
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const attributesUpdates = await getTxAttributesUpdates(control, originTx, tx, object, objectCache)
|
const attributesUpdates = await getTxAttributesUpdates(control, originTx, tx, object, objectCache, controlRules)
|
||||||
|
|
||||||
for (const attributeUpdates of attributesUpdates) {
|
for (const attributeUpdates of attributesUpdates) {
|
||||||
res.push(
|
res.push(
|
||||||
@ -233,7 +234,7 @@ export async function generateDocUpdateMessages (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if we have override control over transaction => activity mappings
|
// Check if we have override control over transaction => activity mappings
|
||||||
const controlRules = control.modelDb.findAllSync(activity.class.ActivityMessageControl, {
|
const controlRules = control.modelDb.findAllSync<ActivityMessageControl>(activity.class.ActivityMessageControl, {
|
||||||
objectClass: { $in: hierarchy.getAncestors(tx.objectClass) }
|
objectClass: { $in: hierarchy.getAncestors(tx.objectClass) }
|
||||||
})
|
})
|
||||||
if (controlRules.length > 0) {
|
if (controlRules.length > 0) {
|
||||||
@ -254,7 +255,8 @@ export async function generateDocUpdateMessages (
|
|||||||
return await ctx.with(
|
return await ctx.with(
|
||||||
'pushDocUpdateMessages',
|
'pushDocUpdateMessages',
|
||||||
{},
|
{},
|
||||||
async (ctx) => await pushDocUpdateMessages(ctx, control, res, doc, originTx ?? tx, undefined, objectCache)
|
async (ctx) =>
|
||||||
|
await pushDocUpdateMessages(ctx, control, res, doc, originTx ?? tx, undefined, objectCache, controlRules)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
case core.class.TxMixin:
|
case core.class.TxMixin:
|
||||||
@ -267,7 +269,16 @@ export async function generateDocUpdateMessages (
|
|||||||
'pushDocUpdateMessages',
|
'pushDocUpdateMessages',
|
||||||
{},
|
{},
|
||||||
async (ctx) =>
|
async (ctx) =>
|
||||||
await pushDocUpdateMessages(ctx, control, res, doc ?? undefined, originTx ?? tx, undefined, objectCache)
|
await pushDocUpdateMessages(
|
||||||
|
ctx,
|
||||||
|
control,
|
||||||
|
res,
|
||||||
|
doc ?? undefined,
|
||||||
|
originTx ?? tx,
|
||||||
|
undefined,
|
||||||
|
objectCache,
|
||||||
|
controlRules
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
case core.class.TxCollectionCUD: {
|
case core.class.TxCollectionCUD: {
|
||||||
@ -283,7 +294,16 @@ export async function generateDocUpdateMessages (
|
|||||||
'pushDocUpdateMessages',
|
'pushDocUpdateMessages',
|
||||||
{},
|
{},
|
||||||
async (ctx) =>
|
async (ctx) =>
|
||||||
await pushDocUpdateMessages(ctx, control, res, doc ?? undefined, originTx ?? tx, undefined, objectCache)
|
await pushDocUpdateMessages(
|
||||||
|
ctx,
|
||||||
|
control,
|
||||||
|
res,
|
||||||
|
doc ?? undefined,
|
||||||
|
originTx ?? tx,
|
||||||
|
undefined,
|
||||||
|
objectCache,
|
||||||
|
controlRules
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import {
|
|||||||
TxUpdateDoc
|
TxUpdateDoc
|
||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
import core from '@hcengineering/core/lib/component'
|
import core from '@hcengineering/core/lib/component'
|
||||||
import { DocAttributeUpdates, DocUpdateAction } from '@hcengineering/activity'
|
import { ActivityMessageControl, DocAttributeUpdates, DocUpdateAction } from '@hcengineering/activity'
|
||||||
import { ActivityControl, DocObjectCache, getAllObjectTransactions } from '@hcengineering/server-activity'
|
import { ActivityControl, DocObjectCache, getAllObjectTransactions } from '@hcengineering/server-activity'
|
||||||
import { getDocCollaborators } from '@hcengineering/server-notification-resources'
|
import { getDocCollaborators } from '@hcengineering/server-notification-resources'
|
||||||
import notification from '@hcengineering/notification'
|
import notification from '@hcengineering/notification'
|
||||||
@ -224,7 +224,8 @@ export async function getTxAttributesUpdates (
|
|||||||
originTx: TxCUD<Doc>,
|
originTx: TxCUD<Doc>,
|
||||||
tx: TxCUD<Doc>,
|
tx: TxCUD<Doc>,
|
||||||
object: Doc,
|
object: Doc,
|
||||||
objectCache?: DocObjectCache
|
objectCache?: DocObjectCache,
|
||||||
|
controlRules?: ActivityMessageControl[]
|
||||||
): Promise<DocAttributeUpdates[]> {
|
): Promise<DocAttributeUpdates[]> {
|
||||||
if (![core.class.TxMixin, core.class.TxUpdateDoc].includes(tx._class)) {
|
if (![core.class.TxMixin, core.class.TxUpdateDoc].includes(tx._class)) {
|
||||||
return []
|
return []
|
||||||
@ -242,7 +243,15 @@ export async function getTxAttributesUpdates (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const hierarchy = control.hierarchy
|
const hierarchy = control.hierarchy
|
||||||
const keys = getAvailableAttributesKeys(tx, hierarchy)
|
|
||||||
|
const filterSet = new Set<string>()
|
||||||
|
for (const c of controlRules ?? []) {
|
||||||
|
for (const f of c.skipFields ?? []) {
|
||||||
|
filterSet.add(f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const keys = getAvailableAttributesKeys(tx, hierarchy).filter((it) => !filterSet.has(it))
|
||||||
|
|
||||||
if (keys.length === 0) {
|
if (keys.length === 0) {
|
||||||
return []
|
return []
|
||||||
|
Loading…
Reference in New Issue
Block a user