mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-17 18:05:42 +02:00
Add support for custom exclude filters
Add support for custom exclude filters - by Andrey Sobolev - haiodo@gmail.com Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@hcengineering/client-resources",
|
||||
"comment": "Add support for custom exclude filters",
|
||||
"type": "patch"
|
||||
}
|
||||
],
|
||||
"packageName": "@hcengineering/client-resources"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@hcengineering/client",
|
||||
"comment": "Add support for custom exclude filters",
|
||||
"type": "patch"
|
||||
}
|
||||
],
|
||||
"packageName": "@hcengineering/client"
|
||||
}
|
||||
@@ -98,6 +98,7 @@ export default async () => {
|
||||
function: {
|
||||
GetClient: async (token: string, endpoint: string, opt?: ClientFactoryOptions): Promise<Client> => {
|
||||
const filterModel = getMetadata(clientPlugin.metadata.FilterModel) ?? 'none'
|
||||
const extraFilter = getMetadata(clientPlugin.metadata.ExtraFilter) ?? []
|
||||
|
||||
const handler = async (handler: TxHandler): Promise<ClientConnection> => {
|
||||
const url = concatLink(endpoint, `/${token}`)
|
||||
@@ -170,7 +171,7 @@ export default async () => {
|
||||
return returnClientTxes(txes)
|
||||
}
|
||||
if (filterModel === 'ui') {
|
||||
return returnUITxes(txes)
|
||||
return returnUITxes(txes, extraFilter)
|
||||
}
|
||||
return txes
|
||||
}
|
||||
@@ -181,13 +182,13 @@ export default async () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
function returnUITxes (txes: Tx[]): Tx[] {
|
||||
function returnUITxes (txes: Tx[], extraFilter: string[]): Tx[] {
|
||||
const configs = new Map<Ref<PluginConfiguration>, PluginConfiguration>()
|
||||
fillConfiguration(txes, configs)
|
||||
|
||||
const allowedPlugins = [...getPlugins(), ...(getMetadata(clientPlugin.metadata.ExtraPlugins) ?? [])]
|
||||
const excludedPlugins = Array.from(configs.values()).filter(
|
||||
(it) => !it.enabled || !allowedPlugins.includes(it.pluginId)
|
||||
(it) => !it.enabled || !allowedPlugins.includes(it.pluginId) || extraFilter.includes(it.pluginId)
|
||||
)
|
||||
return pluginFilterTx(excludedPlugins, configs, txes)
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ export default plugin(clientId, {
|
||||
metadata: {
|
||||
ClientSocketFactory: '' as Metadata<ClientSocketFactory>,
|
||||
FilterModel: '' as Metadata<FilterMode>,
|
||||
ExtraFilter: '' as Metadata<string[]>,
|
||||
ExtraPlugins: '' as Metadata<Plugin[]>,
|
||||
UseBinaryProtocol: '' as Metadata<boolean>,
|
||||
UseProtocolCompression: '' as Metadata<boolean>,
|
||||
|
||||
Reference in New Issue
Block a user