mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-26 04:54:40 +03:00
Disabled integrations (#1145)
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
36ddf8477a
commit
4ac8a4d80e
@ -69,6 +69,7 @@ specifiers:
|
||||
'@rush-temp/model-server-lead': file:./projects/model-server-lead.tgz
|
||||
'@rush-temp/model-server-notification': file:./projects/model-server-notification.tgz
|
||||
'@rush-temp/model-server-recruit': file:./projects/model-server-recruit.tgz
|
||||
'@rush-temp/model-server-setting': file:./projects/model-server-setting.tgz
|
||||
'@rush-temp/model-server-task': file:./projects/model-server-task.tgz
|
||||
'@rush-temp/model-setting': file:./projects/model-setting.tgz
|
||||
'@rush-temp/model-tags': file:./projects/model-tags.tgz
|
||||
@ -109,6 +110,8 @@ specifiers:
|
||||
'@rush-temp/server-notification-resources': file:./projects/server-notification-resources.tgz
|
||||
'@rush-temp/server-recruit': file:./projects/server-recruit.tgz
|
||||
'@rush-temp/server-recruit-resources': file:./projects/server-recruit-resources.tgz
|
||||
'@rush-temp/server-setting': file:./projects/server-setting.tgz
|
||||
'@rush-temp/server-setting-resources': file:./projects/server-setting-resources.tgz
|
||||
'@rush-temp/server-task': file:./projects/server-task.tgz
|
||||
'@rush-temp/server-task-resources': file:./projects/server-task-resources.tgz
|
||||
'@rush-temp/server-token': file:./projects/server-token.tgz
|
||||
@ -192,6 +195,7 @@ specifiers:
|
||||
fast-equals: ^2.0.3
|
||||
file-loader: ^6.2.0
|
||||
filesize: ^8.0.3
|
||||
html-webpack-plugin: ~5.5.0
|
||||
intl-messageformat: ^9.7.1
|
||||
jpeg-js: ~0.4.3
|
||||
just-clone: ^3.2.1
|
||||
@ -297,6 +301,7 @@ dependencies:
|
||||
'@rush-temp/model-server-lead': file:projects/model-server-lead.tgz_typescript@4.5.4
|
||||
'@rush-temp/model-server-notification': file:projects/model-server-notification.tgz_typescript@4.5.4
|
||||
'@rush-temp/model-server-recruit': file:projects/model-server-recruit.tgz_typescript@4.5.4
|
||||
'@rush-temp/model-server-setting': file:projects/model-server-setting.tgz_typescript@4.5.4
|
||||
'@rush-temp/model-server-task': file:projects/model-server-task.tgz_typescript@4.5.4
|
||||
'@rush-temp/model-setting': file:projects/model-setting.tgz_typescript@4.5.4
|
||||
'@rush-temp/model-tags': file:projects/model-tags.tgz_typescript@4.5.4
|
||||
@ -337,6 +342,8 @@ dependencies:
|
||||
'@rush-temp/server-notification-resources': file:projects/server-notification-resources.tgz
|
||||
'@rush-temp/server-recruit': file:projects/server-recruit.tgz
|
||||
'@rush-temp/server-recruit-resources': file:projects/server-recruit-resources.tgz
|
||||
'@rush-temp/server-setting': file:projects/server-setting.tgz
|
||||
'@rush-temp/server-setting-resources': file:projects/server-setting-resources.tgz
|
||||
'@rush-temp/server-task': file:projects/server-task.tgz
|
||||
'@rush-temp/server-task-resources': file:projects/server-task-resources.tgz
|
||||
'@rush-temp/server-token': file:projects/server-token.tgz
|
||||
@ -420,6 +427,7 @@ dependencies:
|
||||
fast-equals: 2.0.4
|
||||
file-loader: 6.2.0_webpack@5.65.0
|
||||
filesize: 8.0.6
|
||||
html-webpack-plugin: 5.5.0_webpack@5.65.0
|
||||
intl-messageformat: 9.10.0
|
||||
jpeg-js: 0.4.3
|
||||
just-clone: 3.2.1
|
||||
@ -12890,6 +12898,27 @@ packages:
|
||||
- typescript
|
||||
dev: false
|
||||
|
||||
file:projects/model-server-setting.tgz_typescript@4.5.4:
|
||||
resolution: {integrity: sha512-sSatGVzTXWASCQIHUz7og+pZXUuv1qUk/6ZeznxaNTVTv3iq4R/mhNSga3xdKh4WFVygaVTkTSnVCMvjBBkVSQ==, tarball: file:projects/model-server-setting.tgz}
|
||||
id: file:projects/model-server-setting.tgz
|
||||
name: '@rush-temp/model-server-setting'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
'@rushstack/heft': 0.41.8
|
||||
'@types/heft-jest': 1.0.2
|
||||
'@typescript-eslint/eslint-plugin': 5.7.0_c25e8c1f4f4f7aaed27aa6f9ce042237
|
||||
'@typescript-eslint/parser': 5.7.0_eslint@7.32.0+typescript@4.5.4
|
||||
eslint: 7.32.0
|
||||
eslint-config-standard-with-typescript: 21.0.1_ce2fa0c4dfa1c256100cababd749a13a
|
||||
eslint-plugin-import: 2.25.3_eslint@7.32.0
|
||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||
eslint-plugin-promise: 5.2.0_eslint@7.32.0
|
||||
prettier: 2.5.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
- typescript
|
||||
dev: false
|
||||
|
||||
file:projects/model-server-task.tgz_typescript@4.5.4:
|
||||
resolution: {integrity: sha512-UGeEby4x4ZUjOO3ECPvg3wVKQUAXjNMw8zQFiQmCemiMQk+6NNvGhwkHgV674dt5rGDCNBjKJfFaShTj7jcDlw==, tarball: file:projects/model-server-task.tgz}
|
||||
id: file:projects/model-server-task.tgz
|
||||
@ -13844,6 +13873,47 @@ packages:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
file:projects/server-setting-resources.tgz:
|
||||
resolution: {integrity: sha512-Jf0YabfPXMgfmjSd1jNibkwSR4FoVIxxCfeU+g6CGrCJ6NE1XgCrWgZXrRiIkGEHx14C+zQhE6IIFYKhB0LTXA==, tarball: file:projects/server-setting-resources.tgz}
|
||||
name: '@rush-temp/server-setting-resources'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
'@rushstack/heft': 0.41.8
|
||||
'@types/heft-jest': 1.0.2
|
||||
'@typescript-eslint/eslint-plugin': 5.7.0_c25e8c1f4f4f7aaed27aa6f9ce042237
|
||||
'@typescript-eslint/parser': 5.7.0_eslint@7.32.0+typescript@4.5.4
|
||||
eslint: 7.32.0
|
||||
eslint-config-standard-with-typescript: 21.0.1_ce2fa0c4dfa1c256100cababd749a13a
|
||||
eslint-plugin-import: 2.25.3_eslint@7.32.0
|
||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||
eslint-plugin-promise: 5.2.0_eslint@7.32.0
|
||||
prettier: 2.5.1
|
||||
typescript: 4.5.4
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
file:projects/server-setting.tgz:
|
||||
resolution: {integrity: sha512-J5y5nrM9SJ9USgO3kHR0T0AwN3QP/1mtFFTPPwpykXzgy5y2UqauOhavQsboVs4I4iqkiqW388pzAAjiY3Uugg==, tarball: file:projects/server-setting.tgz}
|
||||
name: '@rush-temp/server-setting'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
'@rushstack/heft': 0.41.8
|
||||
'@types/heft-jest': 1.0.2
|
||||
'@types/node': 16.11.14
|
||||
'@typescript-eslint/eslint-plugin': 5.7.0_c25e8c1f4f4f7aaed27aa6f9ce042237
|
||||
'@typescript-eslint/parser': 5.7.0_eslint@7.32.0+typescript@4.5.4
|
||||
eslint: 7.32.0
|
||||
eslint-config-standard-with-typescript: 21.0.1_ce2fa0c4dfa1c256100cababd749a13a
|
||||
eslint-plugin-import: 2.25.3_eslint@7.32.0
|
||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||
eslint-plugin-promise: 5.2.0_eslint@7.32.0
|
||||
prettier: 2.5.1
|
||||
typescript: 4.5.4
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
file:projects/server-task-resources.tgz:
|
||||
resolution: {integrity: sha512-jowQNnlvRD38vrWZMQO8WU00IGaRWcWmfIKnecgu24O53KxMqTmJ1uWA7MNsO3N2b86jF+hJ4PsDqcjTUyxzeQ==, tarball: file:projects/server-task-resources.tgz}
|
||||
name: '@rush-temp/server-task-resources'
|
||||
|
@ -97,6 +97,8 @@
|
||||
"@anticrm/server-contact-resources": "~0.6.0",
|
||||
"@anticrm/server-notification": "~0.6.0",
|
||||
"@anticrm/server-notification-resources": "~0.6.0",
|
||||
"@anticrm/server-setting": "~0.6.0",
|
||||
"@anticrm/server-setting-resources": "~0.6.0",
|
||||
"@anticrm/templates": "~0.6.0",
|
||||
"@anticrm/templates-assets": "~0.6.0",
|
||||
"@anticrm/templates-resources": "~0.6.0",
|
||||
|
@ -20,6 +20,7 @@ import { clientId } from '@anticrm/client'
|
||||
import { serverAttachmentId } from '@anticrm/server-attachment'
|
||||
import { serverContactId } from '@anticrm/server-contact'
|
||||
import { serverNotificationId } from '@anticrm/server-notification'
|
||||
import { serverSettingId } from '@anticrm/server-setting'
|
||||
import { serverChunterId } from '@anticrm/server-chunter'
|
||||
import { serverInventoryId } from '@anticrm/server-inventory'
|
||||
import { serverLeadId } from '@anticrm/server-lead'
|
||||
@ -40,6 +41,7 @@ export function configurePlatformDev() {
|
||||
addLocation(serverAttachmentId, () => import(/* webpackChunkName: "server-attachment" */ '@anticrm/server-attachment-resources'))
|
||||
addLocation(serverContactId, () => import(/* webpackChunkName: "server-contact" */ '@anticrm/server-contact-resources'))
|
||||
addLocation(serverNotificationId, () => import(/* webpackChunkName: "server-notification" */ '@anticrm/server-notification-resources'))
|
||||
addLocation(serverSettingId, () => import(/* webpackChunkName: "server-setting" */ '@anticrm/server-setting-resources'))
|
||||
addLocation(serverChunterId, () => import(/* webpackChunkName: "server-chunter" */ '@anticrm/server-chunter-resources'))
|
||||
addLocation(serverInventoryId, () => import(/* webpackChunkName: "server-inventory" */ '@anticrm/server-inventory-resources'))
|
||||
addLocation(serverLeadId, () => import(/* webpackChunkName: "server-lead" */ '@anticrm/server-lead-resources'))
|
||||
|
@ -77,6 +77,8 @@
|
||||
"@anticrm/server-contact-resources": "~0.6.0",
|
||||
"@anticrm/server-notification": "~0.6.0",
|
||||
"@anticrm/server-notification-resources": "~0.6.0",
|
||||
"@anticrm/server-setting": "~0.6.0",
|
||||
"@anticrm/server-setting-resources": "~0.6.0",
|
||||
"@anticrm/server-tool": "~0.6.0",
|
||||
"@anticrm/server-chunter": "~0.6.0",
|
||||
"@anticrm/server-chunter-resources": "~0.6.0",
|
||||
|
@ -50,6 +50,7 @@ import {
|
||||
import { serverAttachmentId } from '@anticrm/server-attachment'
|
||||
import { serverContactId } from '@anticrm/server-contact'
|
||||
import { serverNotificationId } from '@anticrm/server-notification'
|
||||
import { serverSettingId } from '@anticrm/server-setting'
|
||||
import { serverChunterId } from '@anticrm/server-chunter'
|
||||
import { serverInventoryId } from '@anticrm/server-inventory'
|
||||
import { serverLeadId } from '@anticrm/server-lead'
|
||||
@ -115,6 +116,7 @@ export class ElasticTool {
|
||||
addLocation(serverInventoryId, () => import(/* webpackChunkName: "server-inventory" */ '@anticrm/server-inventory-resources'))
|
||||
addLocation(serverLeadId, () => import(/* webpackChunkName: "server-lead" */ '@anticrm/server-lead-resources'))
|
||||
addLocation(serverRecruitId, () => import(/* webpackChunkName: "server-recruit" */ '@anticrm/server-recruit-resources'))
|
||||
addLocation(serverSettingId, () => import(/* webpackChunkName: "server-recruit" */ '@anticrm/server-setting-resources'))
|
||||
addLocation(serverTaskId, () => import/* webpackChunkName: "server-task" */ ('@anticrm/server-task-resources'))
|
||||
this.mongoClient = new MongoClient(mongoUrl)
|
||||
}
|
||||
|
@ -46,6 +46,7 @@
|
||||
"@anticrm/model-server-attachment": "~0.6.0",
|
||||
"@anticrm/model-server-contact": "~0.6.0",
|
||||
"@anticrm/model-server-notification": "~0.6.0",
|
||||
"@anticrm/model-server-setting": "~0.6.0",
|
||||
"@anticrm/model-server-chunter": "~0.6.0",
|
||||
"@anticrm/model-server-task": "~0.6.0",
|
||||
"@anticrm/model-server-recruit": "~0.6.0",
|
||||
|
@ -35,6 +35,7 @@ import { createModel as serverChunterModel } from '@anticrm/model-server-chunter
|
||||
import { createModel as serverInventoryModel } from '@anticrm/model-server-inventory'
|
||||
import { createModel as serverLeadModel } from '@anticrm/model-server-lead'
|
||||
import { createModel as serverTaskModel } from '@anticrm/model-server-task'
|
||||
import { createModel as serveSettingModel } from '@anticrm/model-server-setting'
|
||||
import { createModel as serverRecruitModel } from '@anticrm/model-server-recruit'
|
||||
import { createModel as serverCoreModel } from '@anticrm/model-server-core'
|
||||
import { createModel as settingModel } from '@anticrm/model-setting'
|
||||
@ -74,6 +75,7 @@ const builders = [
|
||||
serverAttachmentModel,
|
||||
serverContactModel,
|
||||
serverNotificationModel,
|
||||
serveSettingModel,
|
||||
tagsModel,
|
||||
serverChunterModel,
|
||||
serverInventoryModel,
|
||||
|
@ -21,6 +21,7 @@ import { taskOperation } from '@anticrm/model-task'
|
||||
import { attachmentOperation } from '@anticrm/model-attachment'
|
||||
import { leadOperation } from '@anticrm/model-lead'
|
||||
import { notificationOperation } from '@anticrm/model-notification'
|
||||
import { settingOperation } from '@anticrm/model-setting'
|
||||
import { recruitOperation } from '@anticrm/model-recruit'
|
||||
import { viewOperation } from '@anticrm/model-view'
|
||||
import { contactOperation } from '@anticrm/model-contact'
|
||||
@ -35,5 +36,6 @@ export const migrateOperations: MigrateOperation[] = [
|
||||
viewOperation,
|
||||
contactOperation,
|
||||
tagsOperation,
|
||||
notificationOperation
|
||||
notificationOperation,
|
||||
settingOperation
|
||||
]
|
||||
|
7
models/server-setting/.eslintrc.js
Normal file
7
models/server-setting/.eslintrc.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
extends: ['./node_modules/@anticrm/model-rig/profiles/default/config/eslint.config.json'],
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: './tsconfig.json'
|
||||
}
|
||||
}
|
4
models/server-setting/.npmignore
Normal file
4
models/server-setting/.npmignore
Normal file
@ -0,0 +1,4 @@
|
||||
*
|
||||
!/lib/**
|
||||
!CHANGELOG.md
|
||||
/lib/**/__tests__/
|
18
models/server-setting/config/rig.json
Normal file
18
models/server-setting/config/rig.json
Normal file
@ -0,0 +1,18 @@
|
||||
// The "rig.json" file directs tools to look for their config files in an external package.
|
||||
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
||||
|
||||
/**
|
||||
* (Required) The name of the rig package to inherit from.
|
||||
* It should be an NPM package name with the "-rig" suffix.
|
||||
*/
|
||||
"rigPackageName": "@anticrm/model-rig"
|
||||
|
||||
/**
|
||||
* (Optional) Selects a config profile from the rig package. The name must consist of
|
||||
* lowercase alphanumeric words separated by hyphens, for example "sample-profile".
|
||||
* If omitted, then the "default" profile will be used."
|
||||
*/
|
||||
// "rigProfile": "your-profile-name"
|
||||
}
|
34
models/server-setting/package.json
Normal file
34
models/server-setting/package.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "@anticrm/model-server-setting",
|
||||
"version": "0.6.0",
|
||||
"main": "lib/index.js",
|
||||
"author": "Anticrm Platform Contributors",
|
||||
"license": "EPL-2.0",
|
||||
"scripts": {
|
||||
"build": "heft build",
|
||||
"build:watch": "tsc",
|
||||
"lint:fix": "eslint --fix src",
|
||||
"lint": "eslint src",
|
||||
"format": "prettier --write src && eslint --fix src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@anticrm/model-rig": "~0.6.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
||||
"eslint-plugin-import": "^2.25.3",
|
||||
"eslint-plugin-promise": "^5.1.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint": "^7.32.0",
|
||||
"@types/heft-jest": "^1.0.2",
|
||||
"@typescript-eslint/parser": "^5.4.0",
|
||||
"eslint-config-standard-with-typescript": "^21.0.1",
|
||||
"prettier": "^2.4.1",
|
||||
"@rushstack/heft": "^0.41.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anticrm/core": "~0.6.11",
|
||||
"@anticrm/model": "~0.6.0",
|
||||
"@anticrm/platform": "~0.6.5",
|
||||
"@anticrm/server-setting": "~0.6.0",
|
||||
"@anticrm/server-core": "~0.6.0"
|
||||
}
|
||||
}
|
27
models/server-setting/src/index.ts
Normal file
27
models/server-setting/src/index.ts
Normal file
@ -0,0 +1,27 @@
|
||||
//
|
||||
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
||||
// Copyright © 2021, 2022 Hardcore Engineering Inc.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { Builder } from '@anticrm/model'
|
||||
|
||||
import serverCore from '@anticrm/server-core'
|
||||
import core from '@anticrm/core'
|
||||
import serverSetting from '@anticrm/server-setting'
|
||||
|
||||
export function createModel (builder: Builder): void {
|
||||
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
|
||||
trigger: serverSetting.trigger.OnIntegrationDisable
|
||||
})
|
||||
}
|
8
models/server-setting/tsconfig.json
Normal file
8
models/server-setting/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "./node_modules/@anticrm/model-rig/profiles/default/tsconfig.json",
|
||||
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib",
|
||||
}
|
||||
}
|
@ -30,10 +30,12 @@
|
||||
"@anticrm/ui": "~0.6.0",
|
||||
"@anticrm/view": "~0.6.0",
|
||||
"@anticrm/setting": "~0.6.0",
|
||||
"@anticrm/setting-resources": "~0.6.0",
|
||||
"@anticrm/platform": "~0.6.5",
|
||||
"@anticrm/model-core": "~0.6.0",
|
||||
"@anticrm/model-view": "~0.6.0",
|
||||
"@anticrm/model-workbench": "~0.6.1",
|
||||
"@anticrm/task": "~0.6.0"
|
||||
"@anticrm/task": "~0.6.0",
|
||||
"@anticrm/activity": "~0.6.0"
|
||||
}
|
||||
}
|
||||
|
@ -16,10 +16,11 @@
|
||||
import { Builder, Model } from '@anticrm/model'
|
||||
import { Ref, Domain, DOMAIN_MODEL } from '@anticrm/core'
|
||||
import core, { TDoc } from '@anticrm/model-core'
|
||||
import setting from '@anticrm/setting'
|
||||
import setting from './plugin'
|
||||
import type { Integration, IntegrationType, Handler, SettingsCategory } from '@anticrm/setting'
|
||||
import type { Asset, IntlString } from '@anticrm/platform'
|
||||
import task from '@anticrm/task'
|
||||
import activity from '@anticrm/activity'
|
||||
|
||||
import workbench from '@anticrm/model-workbench'
|
||||
import { AnyComponent } from '@anticrm/ui'
|
||||
@ -29,6 +30,7 @@ export const DOMAIN_SETTING = 'setting' as Domain
|
||||
@Model(setting.class.Integration, core.class.Doc, DOMAIN_SETTING)
|
||||
export class TIntegration extends TDoc implements Integration {
|
||||
type!: Ref<IntegrationType>
|
||||
disabled!: boolean
|
||||
value!: string
|
||||
}
|
||||
@Model(setting.class.SettingsCategory, core.class.Doc, DOMAIN_MODEL)
|
||||
@ -45,6 +47,7 @@ export class TIntegrationType extends TDoc implements IntegrationType {
|
||||
description!: IntlString
|
||||
icon!: AnyComponent
|
||||
createComponent!: AnyComponent
|
||||
reconnectComponent?: AnyComponent
|
||||
onDisconnect!: Handler
|
||||
}
|
||||
|
||||
@ -120,4 +123,18 @@ export function createModel (builder: Builder): void {
|
||||
},
|
||||
setting.ids.SettingApp
|
||||
)
|
||||
|
||||
builder.createDoc(activity.class.TxViewlet, core.space.Model, {
|
||||
objectClass: setting.class.Integration,
|
||||
icon: setting.icon.Integrations,
|
||||
txClass: core.class.TxUpdateDoc,
|
||||
label: setting.string.IntegrationWith,
|
||||
labelComponent: setting.activity.TxIntegrationDisable,
|
||||
component: setting.activity.TxIntegrationDisableReconnect,
|
||||
display: 'emphasized',
|
||||
editable: false,
|
||||
hideOnRemove: true
|
||||
}, setting.ids.TxIntegrationDisable)
|
||||
}
|
||||
|
||||
export { settingOperation } from './migration'
|
||||
|
31
models/setting/src/migration.ts
Normal file
31
models/setting/src/migration.ts
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright © 2022 Hardcore Engineering Inc.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@anticrm/model'
|
||||
import setting from '@anticrm/setting'
|
||||
import { DOMAIN_SETTING } from '.'
|
||||
|
||||
export const settingOperation: MigrateOperation = {
|
||||
async migrate (client: MigrationClient): Promise<void> {
|
||||
await client.update(DOMAIN_SETTING, {
|
||||
_class: setting.class.Integration,
|
||||
disabled: { $exists: false }
|
||||
}, {
|
||||
disabled: false
|
||||
})
|
||||
},
|
||||
async upgrade (client: MigrationUpgradeClient): Promise<void> {
|
||||
}
|
||||
}
|
31
models/setting/src/plugin.ts
Normal file
31
models/setting/src/plugin.ts
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright © 2022 Hardcore Engineering Inc.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { Ref } from '@anticrm/core'
|
||||
import { mergeIds } from '@anticrm/platform'
|
||||
import { settingId } from '@anticrm/setting'
|
||||
import setting from '@anticrm/setting-resources/src/plugin'
|
||||
import type { TxViewlet } from '@anticrm/activity'
|
||||
import { AnyComponent } from '@anticrm/ui'
|
||||
|
||||
export default mergeIds(settingId, setting, {
|
||||
activity: {
|
||||
TxIntegrationDisable: '' as AnyComponent,
|
||||
TxIntegrationDisableReconnect: '' as AnyComponent
|
||||
},
|
||||
ids: {
|
||||
TxIntegrationDisable: '' as Ref<TxViewlet>
|
||||
}
|
||||
})
|
@ -91,6 +91,7 @@ export function createModel (builder: Builder): void {
|
||||
description: telegram.string.TelegramIntegrationDesc,
|
||||
icon: telegram.component.IconTelegram,
|
||||
createComponent: telegram.component.Connect,
|
||||
reconnectComponent: telegram.component.Reconnect,
|
||||
onDisconnect: telegram.handler.DisconnectHandler
|
||||
},
|
||||
telegram.integrationType.Telegram
|
||||
|
@ -38,7 +38,7 @@
|
||||
const accountId = getCurrentAccount()._id
|
||||
let integrations: Set<Ref<IntegrationType>> = new Set<Ref<IntegrationType>>()
|
||||
const settingsQuery = createQuery()
|
||||
$: settingsQuery.query(setting.class.Integration, { space: accountId as string as Ref<Space> }, (res) => {
|
||||
$: settingsQuery.query(setting.class.Integration, { space: accountId as string as Ref<Space>, disabled: false }, (res) => {
|
||||
integrations = new Set(res.map((p) => p.type))
|
||||
})
|
||||
|
||||
|
@ -58,7 +58,7 @@
|
||||
const accountId = getCurrentAccount()._id
|
||||
let integrations: Set<Ref<IntegrationType>> = new Set<Ref<IntegrationType>>()
|
||||
const settingsQuery = createQuery()
|
||||
$: settingsQuery.query(setting.class.Integration, { space: accountId as string as Ref<Space> }, (res) => {
|
||||
$: settingsQuery.query(setting.class.Integration, { space: accountId as string as Ref<Space>, disabled: false }, (res) => {
|
||||
integrations = new Set(res.map((p) => p.type))
|
||||
})
|
||||
|
||||
|
@ -85,7 +85,8 @@ export default plugin(gmailId, {
|
||||
Gmail: '' as Ref<IntegrationType>
|
||||
},
|
||||
handler: {
|
||||
DisconnectHandler: '' as Handler
|
||||
DisconnectHandler: '' as Handler,
|
||||
ReconnectHandler: '' as Handler
|
||||
},
|
||||
class: {
|
||||
Message: '' as Ref<Class<Message>>,
|
||||
|
@ -33,7 +33,6 @@
|
||||
"@anticrm/platform": "~0.6.5",
|
||||
"svelte": "^3.37.0",
|
||||
"@anticrm/login": "~0.6.1",
|
||||
"@anticrm/account": "~0.6.0",
|
||||
"@anticrm/ui": "~0.6.0",
|
||||
"@anticrm/workbench": "~0.6.1"
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
import { Status, OK, unknownError, getMetadata, serialize, unknownStatus } from '@anticrm/platform'
|
||||
import type { Request, Response } from '@anticrm/platform'
|
||||
import type { Workspace } from '@anticrm/account'
|
||||
|
||||
import login from '@anticrm/login'
|
||||
import { fetchMetadataLocalStorage, getCurrentLocation, navigate } from '@anticrm/ui'
|
||||
@ -26,6 +25,10 @@ export interface LoginInfo {
|
||||
email: string
|
||||
}
|
||||
|
||||
export interface Workspace {
|
||||
workspace: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a login operation to required workspace with user credentials.
|
||||
*/
|
||||
@ -165,10 +168,7 @@ export async function getWorkspaces (): Promise<Workspace[]> {
|
||||
if (endpoint !== undefined) {
|
||||
return [
|
||||
{
|
||||
_id: '' as any,
|
||||
workspace: 'DEV WORKSPACE',
|
||||
organisation: '',
|
||||
accounts: []
|
||||
workspace: 'DEV WORKSPACE'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -25,6 +25,9 @@
|
||||
"Settings": "Settings",
|
||||
"SelectWorkspace": "Select workspace",
|
||||
"DeleteStatus": "Delete status",
|
||||
"DeleteStatusConfirm": "Do you want to delete this status?"
|
||||
"DeleteStatusConfirm": "Do you want to delete this status?",
|
||||
"Reconnect": "Reconnect",
|
||||
"IntegrationDisabled": " has been disabled",
|
||||
"IntegrationWith": "Integration with "
|
||||
}
|
||||
}
|
@ -25,6 +25,9 @@
|
||||
"Settings": "Настройки",
|
||||
"SelectWorkspace": "Выбрать пространство",
|
||||
"DeleteStatus": "Удаление статуса",
|
||||
"DeleteStatusConfirm": "Вы действительно хотите удалить этот статус?"
|
||||
"DeleteStatusConfirm": "Вы действительно хотите удалить этот статус?",
|
||||
"Reconnect": "Переподключить",
|
||||
"IntegrationDisabled": " была отключена",
|
||||
"IntegrationWith": "Интеграция с "
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@
|
||||
import { getResource } from '@anticrm/platform'
|
||||
import { showPopup } from '@anticrm/ui'
|
||||
import type { Integration, IntegrationType } from '@anticrm/setting'
|
||||
import setting from '@anticrm/setting'
|
||||
import setting from '../plugin'
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
import { getCurrentAccount, Ref, Space } from '@anticrm/core'
|
||||
|
||||
@ -27,12 +27,27 @@
|
||||
const accountId = getCurrentAccount()._id
|
||||
const client = getClient()
|
||||
const onDisconnectP = getResource(integrationType.onDisconnect)
|
||||
const space = accountId as string as Ref<Space>
|
||||
|
||||
async function close(res: any): Promise<void> {
|
||||
if (res?.value) {
|
||||
await client.createDoc(setting.class.Integration, accountId as string as Ref<Space>, {
|
||||
await client.createDoc(setting.class.Integration, space, {
|
||||
type: integrationType._id,
|
||||
value: res.value
|
||||
value: res.value,
|
||||
disabled: false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function reconnect (res: any): Promise<void> {
|
||||
if (res?.value) {
|
||||
const current = await client.findOne(setting.class.Integration, {
|
||||
space,
|
||||
type: integrationType._id
|
||||
})
|
||||
if (current === undefined) return
|
||||
await client.update(current, {
|
||||
disabled: false
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -57,7 +72,19 @@
|
||||
<div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod temp</div>
|
||||
<div class="footer">
|
||||
{#if integration}
|
||||
<Button label={setting.string.Disconnect} on:click={disconnect} />
|
||||
{#if integration.disabled && integrationType.reconnectComponent}
|
||||
<Button
|
||||
label={setting.string.Reconnect}
|
||||
primary
|
||||
on:click={(e) => {
|
||||
if (integrationType.reconnectComponent) {
|
||||
showPopup(integrationType.reconnectComponent, {}, e.target, reconnect)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{:else}
|
||||
<Button label={setting.string.Disconnect} on:click={disconnect} />
|
||||
{/if}
|
||||
{:else}
|
||||
<Button
|
||||
label={setting.string.Add}
|
||||
|
@ -0,0 +1,42 @@
|
||||
<!--
|
||||
// Copyright © 2022 Hardcore Engineering Inc.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { TxUpdateDoc } from '@anticrm/core'
|
||||
import { IntlString } from '@anticrm/platform'
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
import { Integration } from '@anticrm/setting'
|
||||
import { Label } from '@anticrm/ui'
|
||||
import setting from '../../plugin'
|
||||
|
||||
export let tx: TxUpdateDoc<Integration>
|
||||
export let doc: Integration
|
||||
|
||||
const client = getClient()
|
||||
|
||||
async function getTypeLabel (tx: TxUpdateDoc<Integration>): Promise<IntlString | undefined> {
|
||||
const doc = await client.findOne(setting.class.Integration, { _id: tx.objectId })
|
||||
if (doc === undefined) return
|
||||
const type = await client.findOne(setting.class.IntegrationType, { _id: doc.type })
|
||||
return type?.label
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
{#await getTypeLabel(tx) then typeLabel}
|
||||
{#if typeLabel}
|
||||
<Label label={typeLabel}/>
|
||||
{/if}
|
||||
{/await}
|
||||
<Label label={setting.string.IntegrationDisabled} />
|
@ -0,0 +1,57 @@
|
||||
<!--
|
||||
// Copyright © 2022 Hardcore Engineering Inc.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { TxUpdateDoc } from '@anticrm/core'
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
import { Integration,IntegrationType } from '@anticrm/setting'
|
||||
import { Button,showPopup } from '@anticrm/ui'
|
||||
import setting from '../../plugin'
|
||||
|
||||
export let tx: TxUpdateDoc<Integration>
|
||||
let doc: Integration | undefined
|
||||
|
||||
const client = getClient()
|
||||
|
||||
let type: IntegrationType | undefined
|
||||
|
||||
$: getType(tx)
|
||||
|
||||
async function getType (tx: TxUpdateDoc<Integration>): Promise<IntegrationType | undefined> {
|
||||
doc = await client.findOne(setting.class.Integration, { _id: tx.objectId })
|
||||
if (doc === undefined) return
|
||||
type = await client.findOne(setting.class.IntegrationType, { _id: doc.type })
|
||||
}
|
||||
|
||||
async function reconnect (res: any): Promise<void> {
|
||||
if (res?.value) {
|
||||
if (doc === undefined) return
|
||||
await client.update(doc, {
|
||||
disabled: false
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class='flex-center'>
|
||||
<Button
|
||||
label={setting.string.Reconnect}
|
||||
primary
|
||||
on:click={(e) => {
|
||||
if (type?.reconnectComponent) {
|
||||
showPopup(type.reconnectComponent, {}, e.target, reconnect)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
@ -23,8 +23,14 @@ import Support from './components/Support.svelte'
|
||||
import Privacy from './components/Privacy.svelte'
|
||||
import Terms from './components/Terms.svelte'
|
||||
import Settings from './components/Settings.svelte'
|
||||
import TxIntegrationDisable from './components/activity/TxIntegrationDisable.svelte'
|
||||
import TxIntegrationDisableReconnect from './components/activity/TxIntegrationDisableReconnect.svelte'
|
||||
|
||||
export default async (): Promise<Resources> => ({
|
||||
activity: {
|
||||
TxIntegrationDisable,
|
||||
TxIntegrationDisableReconnect
|
||||
},
|
||||
component: {
|
||||
Settings,
|
||||
Profile,
|
||||
|
@ -19,6 +19,8 @@ import setting, { settingId } from '@anticrm/setting'
|
||||
|
||||
export default mergeIds(settingId, setting, {
|
||||
string: {
|
||||
IntegrationDisabled: '' as IntlString,
|
||||
IntegrationWith: '' as IntlString,
|
||||
DeleteStatus: '' as IntlString,
|
||||
DeleteStatusConfirm: '' as IntlString
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ export interface IntegrationType extends Doc {
|
||||
icon: AnyComponent
|
||||
createComponent: AnyComponent
|
||||
onDisconnect: Handler
|
||||
reconnectComponent?: AnyComponent
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,6 +40,7 @@ export interface IntegrationType extends Doc {
|
||||
*/
|
||||
export interface Integration extends Doc {
|
||||
type: Ref<IntegrationType>
|
||||
disabled: boolean
|
||||
value: string
|
||||
}
|
||||
|
||||
@ -112,7 +114,8 @@ export default plugin(settingId, {
|
||||
EnterNewPassword: '' as IntlString,
|
||||
RepeatNewPassword: '' as IntlString,
|
||||
Signout: '' as IntlString,
|
||||
SelectWorkspace: '' as IntlString
|
||||
SelectWorkspace: '' as IntlString,
|
||||
Reconnect: '' as IntlString
|
||||
},
|
||||
icon: {
|
||||
EditProfile: '' as Asset,
|
||||
|
@ -20,13 +20,14 @@
|
||||
import { generateId, getCurrentAccount, Ref, SortingOrder, Space } from '@anticrm/core'
|
||||
import { NotificationClientImpl } from '@anticrm/notification-resources'
|
||||
import { createQuery, getClient } from '@anticrm/presentation'
|
||||
import setting from '@anticrm/setting'
|
||||
import setting, { Integration } from '@anticrm/setting'
|
||||
import type { NewTelegramMessage, SharedTelegramMessage, TelegramMessage } from '@anticrm/telegram'
|
||||
import { ActionIcon, Button, IconShare, ScrollBox, showPopup } from '@anticrm/ui'
|
||||
import telegram from '../plugin'
|
||||
import Connect from './Connect.svelte'
|
||||
import TelegramIcon from './icons/Telegram.svelte'
|
||||
import Messages from './Messages.svelte'
|
||||
import Reconnect from './Reconnect.svelte';
|
||||
|
||||
export let object: Contact
|
||||
let channel: Channel | undefined = undefined
|
||||
@ -46,7 +47,7 @@
|
||||
|
||||
let messages: TelegramMessage[] = []
|
||||
let accounts: EmployeeAccount[] = []
|
||||
let enabled: boolean
|
||||
let integration: Integration | undefined
|
||||
let selected: Set<Ref<SharedTelegramMessage>> = new Set<Ref<SharedTelegramMessage>>()
|
||||
let selectable = false
|
||||
|
||||
@ -89,7 +90,7 @@
|
||||
setting.class.Integration,
|
||||
{ type: telegram.integrationType.Telegram, space: accountId as string as Ref<Space> },
|
||||
(res) => {
|
||||
enabled = res.length > 0
|
||||
integration = res[0]
|
||||
}
|
||||
)
|
||||
|
||||
@ -155,7 +156,16 @@
|
||||
if (res?.value) {
|
||||
await client.createDoc(setting.class.Integration, accountId as string as Ref<Space>, {
|
||||
type: telegram.integrationType.Telegram,
|
||||
value: res.value
|
||||
value: res.value,
|
||||
disabled: false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function onReconnect (res: any): Promise<void> {
|
||||
if (res?.value && integration !== undefined) {
|
||||
await client.update(integration, {
|
||||
disabled: false
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -206,14 +216,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{:else if enabled}
|
||||
<AttachmentRefInput
|
||||
space={telegram.space.Telegram}
|
||||
_class={telegram.class.NewMessage}
|
||||
{objectId}
|
||||
on:message={onMessage}
|
||||
/>
|
||||
{:else}
|
||||
{:else if integration === undefined}
|
||||
<div class="flex-center">
|
||||
<Button
|
||||
label={telegram.string.Connect}
|
||||
@ -223,6 +226,23 @@
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{:else if integration.disabled}
|
||||
<div class="flex-center">
|
||||
<Button
|
||||
label={setting.string.Reconnect}
|
||||
primary
|
||||
on:click={(e) => {
|
||||
showPopup(Reconnect, {}, e.target, onReconnect)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
<AttachmentRefInput
|
||||
space={telegram.space.Telegram}
|
||||
_class={telegram.class.NewMessage}
|
||||
{objectId}
|
||||
on:message={onMessage}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
225
plugins/telegram-resources/src/components/Reconnect.svelte
Normal file
225
plugins/telegram-resources/src/components/Reconnect.svelte
Normal file
@ -0,0 +1,225 @@
|
||||
<!--
|
||||
// Copyright © 2022 Hardcore Engineering Inc.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { getMetadata, serialize } from '@anticrm/platform'
|
||||
import { Button, EditBox, IconClose, Label } from '@anticrm/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import login from '@anticrm/login'
|
||||
import PinPad from './PinPad.svelte'
|
||||
import telegram from '../plugin'
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
import setting from '@anticrm/setting'
|
||||
import { getCurrentAccount, Ref, Space } from '@anticrm/core'
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
let requested = false
|
||||
let secondFactor = false
|
||||
let connecting = false
|
||||
let phone: string = ''
|
||||
let code: string = ''
|
||||
let password: string = ''
|
||||
let error: string | undefined = undefined
|
||||
const url = getMetadata(login.metadata.TelegramUrl) ?? ''
|
||||
|
||||
async function requestCode (): Promise<void> {
|
||||
const res = await sendRequest('/signin', { phone })
|
||||
if (res.next === 'code') {
|
||||
requested = true
|
||||
}
|
||||
|
||||
if (res.next === 'end') {
|
||||
dispatch('close', { value: phone })
|
||||
}
|
||||
}
|
||||
|
||||
async function sendPassword (): Promise<void> {
|
||||
const res = await sendRequest('/signin/pass', { phone, pass: password })
|
||||
if (res.next === 'end') {
|
||||
dispatch('close', { value: phone })
|
||||
}
|
||||
}
|
||||
|
||||
async function sendCode (): Promise<void> {
|
||||
const res = await sendRequest('/signin/code', { phone, code: code })
|
||||
if (res.next === 'pass') {
|
||||
secondFactor = true
|
||||
} else if (res.next === 'end') {
|
||||
dispatch('close', { value: phone })
|
||||
}
|
||||
}
|
||||
|
||||
async function sendRequest (path: string, data: any): Promise<any> {
|
||||
connecting = true
|
||||
const response = await fetch(url + path, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + getMetadata(login.metadata.LoginToken),
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: serialize(data)
|
||||
})
|
||||
const res = await response.json()
|
||||
connecting = false
|
||||
|
||||
if (Math.trunc(response.status / 100) !== 2) {
|
||||
if (res.code === 'PHONE_CODE_INVALID') {
|
||||
error = 'Invalid code'
|
||||
}
|
||||
|
||||
throw new Error(res.message)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
function back () {
|
||||
password = ''
|
||||
code = ''
|
||||
phone = ''
|
||||
requested = false
|
||||
secondFactor = false
|
||||
}
|
||||
|
||||
$: label = connecting ? telegram.string.Connecting : requested || secondFactor ? telegram.string.Connect : telegram.string.Next
|
||||
|
||||
$: disabled = checkDisabled(connecting, secondFactor, password, requested, error, code, phone)
|
||||
|
||||
function checkDisabled (
|
||||
connecting: boolean,
|
||||
secondFactor: boolean,
|
||||
password: string,
|
||||
requested: boolean,
|
||||
error: string | undefined,
|
||||
code: string,
|
||||
phone: string
|
||||
): boolean {
|
||||
if (connecting) return true
|
||||
if (secondFactor) return password.length === 0
|
||||
if (requested) {
|
||||
if (error !== undefined) return true
|
||||
return !code.match(/^\d{5}$/)
|
||||
}
|
||||
return !phone.match(/^\+\d{9,15}$/)
|
||||
}
|
||||
|
||||
function click () {
|
||||
if (secondFactor) return sendPassword()
|
||||
if (requested) return sendCode()
|
||||
return requestCode()
|
||||
}
|
||||
|
||||
const client = getClient()
|
||||
const space = getCurrentAccount()._id as string as Ref<Space>
|
||||
|
||||
async function getCurrent () {
|
||||
const cuurent = await client.findOne(setting.class.Integration, { type: telegram.integrationType.Telegram, space })
|
||||
if (cuurent !== undefined) {
|
||||
phone = cuurent.value
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="card">
|
||||
<div class="flex-between header">
|
||||
<div class="overflow-label fs-title"><Label label={telegram.string.ConnectFull} /></div>
|
||||
<div
|
||||
class="tool"
|
||||
on:click={() => {
|
||||
dispatch('close')
|
||||
}}
|
||||
>
|
||||
<IconClose size={'small'} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
{#if secondFactor}
|
||||
<p><Label label={telegram.string.PasswordDescr} /></p>
|
||||
<EditBox label={telegram.string.Password} maxWidth="10rem" format='password' placeholder={telegram.string.Password} bind:value={password} />
|
||||
{:else if requested}
|
||||
<p><Label label={telegram.string.CodeDescr} /></p>
|
||||
<PinPad length={5} bind:value={code} bind:error />
|
||||
{:else}
|
||||
<p><Label label={telegram.string.PhoneDescr} /></p>
|
||||
{#await getCurrent() then value}
|
||||
<EditBox label={telegram.string.Phone} maxWidth="10rem" placeholder={telegram.string.PhonePlaceholder} bind:value={phone} />
|
||||
{/await}
|
||||
{/if}
|
||||
<div class="footer">
|
||||
<Button {label} primary {disabled} on:click={click} />
|
||||
{#if requested || secondFactor}
|
||||
<div class="link over-underline" on:click={back}><Label label={telegram.string.Back} /></div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 20rem;
|
||||
min-width: 20rem;
|
||||
max-width: 20rem;
|
||||
background-color: var(--theme-tooltip-color);
|
||||
border: 1px solid var(--theme-bg-accent-color);
|
||||
border-radius: .75rem;
|
||||
box-shadow: 0px 10px 20px rgba(0, 0, 0, .2);
|
||||
|
||||
.header {
|
||||
flex-shrink: 0;
|
||||
margin: 1.75rem 1.75rem 1.25rem;
|
||||
|
||||
.tool {
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
color: var(--theme-caption-color);
|
||||
}
|
||||
&:active {
|
||||
color: var(--theme-content-accent-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
flex-shrink: 0;
|
||||
flex-grow: 1;
|
||||
height: fit-content;
|
||||
margin: 0 1.75rem 0.5rem;
|
||||
p {
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
|
||||
.footer {
|
||||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 1rem 0rem;
|
||||
|
||||
.link {
|
||||
color: var(--theme-content-dark-color);
|
||||
&:hover {
|
||||
color: var(--theme-caption-color);
|
||||
}
|
||||
&:active {
|
||||
color: var(--theme-content-accent-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
@ -18,6 +18,7 @@ import { getMetadata, Resources } from '@anticrm/platform'
|
||||
import login from '@anticrm/login'
|
||||
import Chat from './components/Chat.svelte'
|
||||
import Connect from './components/Connect.svelte'
|
||||
import Reconnect from './components/Reconnect.svelte'
|
||||
import IconTelegram from './components/icons/TelegramColor.svelte'
|
||||
import TxSharedCreate from './components/activity/TxSharedCreate.svelte'
|
||||
|
||||
@ -25,6 +26,7 @@ export default async (): Promise<Resources> => ({
|
||||
component: {
|
||||
Chat,
|
||||
Connect,
|
||||
Reconnect,
|
||||
IconTelegram
|
||||
},
|
||||
activity: {
|
||||
|
@ -65,6 +65,7 @@ export default plugin(telegramId, {
|
||||
component: {
|
||||
Chat: '' as AnyComponent,
|
||||
Connect: '' as AnyComponent,
|
||||
Reconnect: '' as AnyComponent,
|
||||
IconTelegram: '' as AnyComponent
|
||||
},
|
||||
integrationType: {
|
||||
|
15
rush.json
15
rush.json
@ -1116,5 +1116,20 @@
|
||||
"projectFolder": "server-plugins/task-resources",
|
||||
"shouldPublish": true
|
||||
},
|
||||
{
|
||||
"packageName": "@anticrm/server-setting",
|
||||
"projectFolder": "server-plugins/setting",
|
||||
"shouldPublish": true
|
||||
},
|
||||
{
|
||||
"packageName": "@anticrm/model-server-setting",
|
||||
"projectFolder": "models/server-setting",
|
||||
"shouldPublish": true
|
||||
},
|
||||
{
|
||||
"packageName": "@anticrm/server-setting-resources",
|
||||
"projectFolder": "server-plugins/setting-resources",
|
||||
"shouldPublish": true
|
||||
},
|
||||
]
|
||||
}
|
||||
|
7
server-plugins/setting-resources/.eslintrc.js
Normal file
7
server-plugins/setting-resources/.eslintrc.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
extends: ['./node_modules/@anticrm/platform-rig/profiles/default/config/eslint.config.json'],
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: './tsconfig.json'
|
||||
}
|
||||
}
|
4
server-plugins/setting-resources/.npmignore
Normal file
4
server-plugins/setting-resources/.npmignore
Normal file
@ -0,0 +1,4 @@
|
||||
*
|
||||
!/lib/**
|
||||
!CHANGELOG.md
|
||||
/lib/**/__tests__/
|
18
server-plugins/setting-resources/config/rig.json
Normal file
18
server-plugins/setting-resources/config/rig.json
Normal file
@ -0,0 +1,18 @@
|
||||
// The "rig.json" file directs tools to look for their config files in an external package.
|
||||
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
||||
|
||||
/**
|
||||
* (Required) The name of the rig package to inherit from.
|
||||
* It should be an NPM package name with the "-rig" suffix.
|
||||
*/
|
||||
"rigPackageName": "@anticrm/platform-rig"
|
||||
|
||||
/**
|
||||
* (Optional) Selects a config profile from the rig package. The name must consist of
|
||||
* lowercase alphanumeric words separated by hyphens, for example "sample-profile".
|
||||
* If omitted, then the "default" profile will be used."
|
||||
*/
|
||||
// "rigProfile": "your-profile-name"
|
||||
}
|
36
server-plugins/setting-resources/package.json
Normal file
36
server-plugins/setting-resources/package.json
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "@anticrm/server-setting-resources",
|
||||
"version": "0.6.0",
|
||||
"main": "lib/index.js",
|
||||
"author": "Anticrm Platform Contributors",
|
||||
"license": "EPL-2.0",
|
||||
"scripts": {
|
||||
"build": "heft build",
|
||||
"build:watch": "tsc",
|
||||
"lint:fix": "eslint --fix src",
|
||||
"lint": "eslint src",
|
||||
"format": "prettier --write src && eslint --fix src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@anticrm/platform-rig": "~0.6.0",
|
||||
"@types/heft-jest": "^1.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
||||
"eslint-plugin-import": "^2.25.3",
|
||||
"eslint-plugin-promise": "^5.1.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint": "^7.32.0",
|
||||
"@typescript-eslint/parser": "^5.4.0",
|
||||
"eslint-config-standard-with-typescript": "^21.0.1",
|
||||
"prettier": "^2.4.1",
|
||||
"@rushstack/heft": "^0.41.1",
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anticrm/core": "~0.6.11",
|
||||
"@anticrm/platform": "~0.6.5",
|
||||
"@anticrm/server-core": "~0.6.0",
|
||||
"@anticrm/contact": "~0.6.5",
|
||||
"@anticrm/notification": "~0.6.0",
|
||||
"@anticrm/setting": "~0.6.0"
|
||||
}
|
||||
}
|
72
server-plugins/setting-resources/src/index.ts
Normal file
72
server-plugins/setting-resources/src/index.ts
Normal file
@ -0,0 +1,72 @@
|
||||
//
|
||||
// Copyright © 2022 Hardcore Engineering Inc.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import core, { Account, Data, Doc, generateId, Ref, Tx, TxCollectionCUD, TxCreateDoc, TxUpdateDoc } from '@anticrm/core'
|
||||
import type { TriggerControl } from '@anticrm/server-core'
|
||||
import setting, { Integration } from '@anticrm/setting'
|
||||
import contact, { EmployeeAccount } from '@anticrm/contact'
|
||||
import notification, { Notification, NotificationStatus } from '@anticrm/notification'
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function OnIntegrationDisable (tx: Tx, control: TriggerControl): Promise<Tx[]> {
|
||||
if (!control.hierarchy.isDerived(tx._class, core.class.TxUpdateDoc)) return []
|
||||
const ctx = tx as TxUpdateDoc<Integration>
|
||||
if (!control.hierarchy.isDerived(ctx.objectClass, setting.class.Integration)) return []
|
||||
if (ctx.operations.disabled === true) {
|
||||
const account = (await control.modelDb.findAll(core.class.Account, { _id: ctx.objectSpace as string as Ref<Account> }))[0]
|
||||
if (account === undefined) return []
|
||||
const employeeRef = (account as EmployeeAccount).employee
|
||||
if (employeeRef === undefined) return []
|
||||
|
||||
const createTx: TxCreateDoc<Notification> = {
|
||||
objectClass: notification.class.Notification,
|
||||
objectSpace: notification.space.Notifications,
|
||||
objectId: generateId(),
|
||||
modifiedOn: ctx.modifiedOn,
|
||||
modifiedBy: ctx.modifiedBy,
|
||||
space: ctx.space,
|
||||
_id: generateId(),
|
||||
_class: core.class.TxCreateDoc,
|
||||
attributes: {
|
||||
tx: ctx._id,
|
||||
status: NotificationStatus.New
|
||||
} as unknown as Data<Notification>
|
||||
}
|
||||
|
||||
const createNotificationTx: TxCollectionCUD<Doc, Notification> = {
|
||||
objectId: employeeRef,
|
||||
objectClass: contact.class.Employee,
|
||||
objectSpace: contact.space.Employee,
|
||||
modifiedOn: ctx.modifiedOn,
|
||||
space: core.space.Tx,
|
||||
_class: core.class.TxCollectionCUD,
|
||||
modifiedBy: ctx.modifiedBy,
|
||||
_id: generateId(),
|
||||
collection: 'notifications',
|
||||
tx: createTx
|
||||
}
|
||||
return [createNotificationTx]
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export default async () => ({
|
||||
trigger: {
|
||||
OnIntegrationDisable
|
||||
}
|
||||
})
|
8
server-plugins/setting-resources/tsconfig.json
Normal file
8
server-plugins/setting-resources/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "./node_modules/@anticrm/platform-rig/profiles/default/tsconfig.json",
|
||||
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib"
|
||||
}
|
||||
}
|
7
server-plugins/setting/.eslintrc.js
Normal file
7
server-plugins/setting/.eslintrc.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
extends: ['./node_modules/@anticrm/platform-rig/profiles/default/config/eslint.config.json'],
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: './tsconfig.json'
|
||||
}
|
||||
}
|
4
server-plugins/setting/.npmignore
Normal file
4
server-plugins/setting/.npmignore
Normal file
@ -0,0 +1,4 @@
|
||||
*
|
||||
!/lib/**
|
||||
!CHANGELOG.md
|
||||
/lib/**/__tests__/
|
18
server-plugins/setting/config/rig.json
Normal file
18
server-plugins/setting/config/rig.json
Normal file
@ -0,0 +1,18 @@
|
||||
// The "rig.json" file directs tools to look for their config files in an external package.
|
||||
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
||||
|
||||
/**
|
||||
* (Required) The name of the rig package to inherit from.
|
||||
* It should be an NPM package name with the "-rig" suffix.
|
||||
*/
|
||||
"rigPackageName": "@anticrm/platform-rig"
|
||||
|
||||
/**
|
||||
* (Optional) Selects a config profile from the rig package. The name must consist of
|
||||
* lowercase alphanumeric words separated by hyphens, for example "sample-profile".
|
||||
* If omitted, then the "default" profile will be used."
|
||||
*/
|
||||
// "rigProfile": "your-profile-name"
|
||||
}
|
34
server-plugins/setting/package.json
Normal file
34
server-plugins/setting/package.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "@anticrm/server-setting",
|
||||
"version": "0.6.0",
|
||||
"main": "lib/index.js",
|
||||
"author": "Anticrm Platform Contributors",
|
||||
"license": "EPL-2.0",
|
||||
"scripts": {
|
||||
"build": "heft build",
|
||||
"build:watch": "tsc",
|
||||
"lint:fix": "eslint --fix src",
|
||||
"lint": "eslint src",
|
||||
"format": "prettier --write src && eslint --fix src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@anticrm/platform-rig": "~0.6.0",
|
||||
"@types/heft-jest": "^1.0.2",
|
||||
"@types/node": "^16.4.10",
|
||||
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
||||
"eslint-plugin-import": "^2.25.3",
|
||||
"eslint-plugin-promise": "^5.1.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint": "^7.32.0",
|
||||
"@typescript-eslint/parser": "^5.4.0",
|
||||
"eslint-config-standard-with-typescript": "^21.0.1",
|
||||
"prettier": "^2.4.1",
|
||||
"@rushstack/heft": "^0.41.1",
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anticrm/core": "~0.6.11",
|
||||
"@anticrm/platform": "~0.6.5",
|
||||
"@anticrm/server-core": "~0.6.0"
|
||||
}
|
||||
}
|
32
server-plugins/setting/src/index.ts
Normal file
32
server-plugins/setting/src/index.ts
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// Copyright © 2022 Hardcore Engineering Inc.
|
||||
//
|
||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License. You may
|
||||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import type { Plugin, Resource } from '@anticrm/platform'
|
||||
import { plugin } from '@anticrm/platform'
|
||||
import type { TriggerFunc } from '@anticrm/server-core'
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const serverSettingId = 'server-setting' as Plugin
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export default plugin(serverSettingId, {
|
||||
trigger: {
|
||||
OnIntegrationDisable: '' as Resource<TriggerFunc>
|
||||
}
|
||||
})
|
9
server-plugins/setting/tsconfig.json
Normal file
9
server-plugins/setting/tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "./node_modules/@anticrm/platform-rig/profiles/default/tsconfig.json",
|
||||
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
@ -30,7 +30,6 @@
|
||||
"dependencies": {
|
||||
"mongodb": "^4.1.1",
|
||||
"@anticrm/platform": "~0.6.5",
|
||||
"@anticrm/model-all": "~0.6.0",
|
||||
"minio": "^7.0.19",
|
||||
"@anticrm/core": "~0.6.14",
|
||||
"@anticrm/contact": "~0.6.2",
|
||||
|
@ -51,6 +51,8 @@
|
||||
"@anticrm/server-contact-resources": "~0.6.0",
|
||||
"@anticrm/server-notification": "~0.6.0",
|
||||
"@anticrm/server-notification-resources": "~0.6.0",
|
||||
"@anticrm/server-setting": "~0.6.0",
|
||||
"@anticrm/server-setting-resources": "~0.6.0",
|
||||
"@anticrm/server-chunter": "~0.6.0",
|
||||
"@anticrm/server-chunter-resources": "~0.6.0",
|
||||
"@anticrm/server-inventory": "~0.6.0",
|
||||
|
@ -26,6 +26,7 @@ import { addLocation } from '@anticrm/platform'
|
||||
import { serverAttachmentId } from '@anticrm/server-attachment'
|
||||
import { serverContactId } from '@anticrm/server-contact'
|
||||
import { serverNotificationId } from '@anticrm/server-notification'
|
||||
import { serverSettingId } from '@anticrm/server-setting'
|
||||
import { serverChunterId } from '@anticrm/server-chunter'
|
||||
import { serverInventoryId } from '@anticrm/server-inventory'
|
||||
import { serverLeadId } from '@anticrm/server-lead'
|
||||
@ -61,6 +62,7 @@ export function start (dbUrl: string, fullTextUrl: string, minioConf: MinioConfi
|
||||
addLocation(serverAttachmentId, () => import('@anticrm/server-attachment-resources'))
|
||||
addLocation(serverContactId, () => import('@anticrm/server-contact-resources'))
|
||||
addLocation(serverNotificationId, () => import('@anticrm/server-notification-resources'))
|
||||
addLocation(serverSettingId, () => import('@anticrm/server-setting-resources'))
|
||||
addLocation(serverChunterId, () => import('@anticrm/server-chunter-resources'))
|
||||
addLocation(serverInventoryId, () => import('@anticrm/server-inventory-resources'))
|
||||
addLocation(serverLeadId, () => import('@anticrm/server-lead-resources'))
|
||||
|
Loading…
Reference in New Issue
Block a user