mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-11 12:57:59 +00:00
UBERF-10590: Suport disabled integrations
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
4b105dd01c
commit
806930e6e3
@ -348,7 +348,8 @@ export default function buildModel (): Builder {
|
||||
description: github.string.ConfigDescription,
|
||||
enabled: true,
|
||||
beta: false,
|
||||
icon: github.icon.Github
|
||||
icon: github.icon.Github,
|
||||
classFilter: defaultFilter
|
||||
}
|
||||
],
|
||||
[
|
||||
|
@ -838,7 +838,9 @@ export function pluginFilterTx (
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('exclude plugin', msg)
|
||||
if (typeof window !== 'undefined') {
|
||||
console.log('exclude plugin', msg)
|
||||
}
|
||||
systemTx = systemTx.filter((t) => !totalExcluded.has(t._id))
|
||||
return systemTx
|
||||
}
|
||||
|
@ -315,7 +315,9 @@ class Connection implements ClientConnection {
|
||||
this.lastHash = (resp as HelloResponse).lastHash
|
||||
|
||||
const serverVersion = helloResp.serverVersion
|
||||
console.log('Connected to server:', serverVersion)
|
||||
if (typeof window !== 'undefined') {
|
||||
console.log('Connected to server:', serverVersion)
|
||||
}
|
||||
|
||||
if (this.opt?.onHello !== undefined && !this.opt.onHello(serverVersion)) {
|
||||
this.closed = true
|
||||
|
@ -184,7 +184,6 @@ function returnClientTxes (txes: Tx[]): Tx[] {
|
||||
'text-editor:class:TextEditorAction' as Ref<Class<Doc>>,
|
||||
'templates:class:TemplateField' as Ref<Class<Doc>>,
|
||||
'activity:class:DocUpdateMessageViewlet' as Ref<Class<Doc>>,
|
||||
'core:class:PluginConfiguration' as Ref<Class<Doc>>,
|
||||
'core:class:DomainIndexConfiguration' as Ref<Class<Doc>>,
|
||||
'view:class:ViewletDescriptor' as Ref<Class<Doc>>,
|
||||
'presentation:class:ComponentPointExtension' as Ref<Class<Doc>>,
|
||||
|
@ -12,7 +12,7 @@
|
||||
import { WithLookup, getCurrentAccount } from '@hcengineering/core'
|
||||
import { GithubAuthentication, GithubIntegration } from '@hcengineering/github'
|
||||
import { getEmbeddedLabel, getMetadata, translate } from '@hcengineering/platform'
|
||||
import presentation, { Card, HTMLViewer, NavLink, createQuery } from '@hcengineering/presentation'
|
||||
import presentation, { Card, HTMLViewer, NavLink, createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { Integration } from '@hcengineering/setting'
|
||||
import tracker, { Project } from '@hcengineering/tracker'
|
||||
import ui, { Button, Label, Loading, TabItem, TabList, location, ticker } from '@hcengineering/ui'
|
||||
@ -58,6 +58,9 @@
|
||||
})
|
||||
|
||||
function save (): void {
|
||||
void getClient().diffUpdate(integration, {
|
||||
value: auth?.login ?? ''
|
||||
})
|
||||
dispatch('close', { value: auth?.login ?? '-' })
|
||||
}
|
||||
function onConnect (): void {
|
||||
|
@ -167,14 +167,17 @@ export class PlatformWorker {
|
||||
triggerCheckWorkspaces = (): void => {}
|
||||
|
||||
async doSyncWorkspaces (): Promise<void> {
|
||||
let oldErrors = ''
|
||||
let sameErrors = 1
|
||||
|
||||
while (!this.canceled) {
|
||||
let errors = false
|
||||
let errors: string[] = []
|
||||
try {
|
||||
errors = await this.checkWorkspaces()
|
||||
} catch (err: any) {
|
||||
Analytics.handleError(err)
|
||||
this.ctx.error('check workspace', err)
|
||||
errors = true
|
||||
errors.push(err.message)
|
||||
}
|
||||
await new Promise<void>((resolve) => {
|
||||
this.triggerCheckWorkspaces = () => {
|
||||
@ -182,10 +185,19 @@ export class PlatformWorker {
|
||||
this.triggerCheckWorkspaces = () => {}
|
||||
resolve()
|
||||
}
|
||||
if (errors) {
|
||||
if (errors.length > 0) {
|
||||
const timeout = 15000 * sameErrors
|
||||
const ne = errors.join(',')
|
||||
if (oldErrors === ne) {
|
||||
if (sameErrors < 25) {
|
||||
sameErrors++
|
||||
}
|
||||
} else {
|
||||
oldErrors = ne
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.triggerCheckWorkspaces()
|
||||
}, 15000)
|
||||
}, timeout)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -762,7 +774,7 @@ export class PlatformWorker {
|
||||
return { workspaceInfo, needRecheck: true }
|
||||
}
|
||||
|
||||
private async checkWorkspaces (): Promise<boolean> {
|
||||
private async checkWorkspaces (): Promise<string[]> {
|
||||
this.ctx.info('************************* Check workspaces ************************* ', {
|
||||
workspaces: this.clients.size
|
||||
})
|
||||
@ -886,7 +898,6 @@ export class PlatformWorker {
|
||||
} catch (e: any) {
|
||||
Analytics.handleError(e)
|
||||
this.ctx.info("Couldn't create WS worker", { workspace, error: e })
|
||||
console.error(e)
|
||||
rechecks.push(workspace)
|
||||
} finally {
|
||||
connecting.delete(workspaceInfo.workspace)
|
||||
@ -930,7 +941,7 @@ export class PlatformWorker {
|
||||
recheckCount: rechecks.length,
|
||||
workspacesToCheck: rechecks
|
||||
})
|
||||
return rechecks.length > 0
|
||||
return rechecks
|
||||
}
|
||||
|
||||
getWorkers (): GithubWorker[] {
|
||||
|
@ -200,6 +200,20 @@ export abstract class IssueSyncManagerBase {
|
||||
)
|
||||
await this.client.diffUpdate(doc, issueData, lastModified, account)
|
||||
this.provider.sync()
|
||||
} else if (doc === undefined) {
|
||||
await derivedClient.diffUpdate(
|
||||
syncData,
|
||||
{
|
||||
external,
|
||||
externalVersion: githubExternalSyncVersion,
|
||||
needSync: '',
|
||||
derivedVersion: '', // Check derived changes
|
||||
lastModified,
|
||||
lastGithubUser: account,
|
||||
...extraSyncUpdate
|
||||
},
|
||||
lastModified
|
||||
)
|
||||
}
|
||||
}
|
||||
if (needSync) {
|
||||
|
@ -1619,6 +1619,11 @@ export class GithubWorker implements IntegrationManager {
|
||||
reconnect(workspace.name, event)
|
||||
}))
|
||||
|
||||
const githubEnabled = (await client.findOne(core.class.PluginConfiguration, { pluginId: githubId }))?.enabled
|
||||
if (githubEnabled === false) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
await GithubWorker.checkIntegrations(client, installations)
|
||||
|
||||
const worker = new GithubWorker(
|
||||
@ -1644,12 +1649,12 @@ export class GithubWorker implements IntegrationManager {
|
||||
} catch (err: any) {
|
||||
ctx.error('timeout during to connect', { workspace, error: err })
|
||||
await client?.close()
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
static async checkIntegrations (client: Client, installations: Map<number, InstallationRecord>): Promise<void> {
|
||||
const wsIntegerations = await client.findAll(github.class.GithubIntegration, {})
|
||||
|
||||
for (const intValue of wsIntegerations) {
|
||||
if (!installations.has(intValue.installationId)) {
|
||||
const ops = new TxOperations(client, core.account.System)
|
||||
|
Loading…
Reference in New Issue
Block a user