From df7bb05d0d2e38eeb7f82718137f9198eb4759ff Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Fri, 24 Mar 2023 22:51:15 +0600 Subject: [PATCH] Fix account presenter (#2829) Signed-off-by: Denis Bykhov --- dev/generator/src/connect.ts | 4 +-- models/core/src/index.ts | 12 +++++-- packages/core/src/component.ts | 6 ++++ packages/core/src/index.ts | 2 +- packages/core/src/lang/en.json | 1 + packages/core/src/lang/ru.json | 1 + plugins/activity-assets/lang/en.json | 1 - plugins/activity-assets/lang/ru.json | 1 - .../src/components/TxView.svelte | 2 +- plugins/activity-resources/src/plugin.ts | 1 - .../EmployeeAccountPresenter.svelte | 35 ++++++++----------- server/account/src/index.ts | 3 +- server/middleware/src/utils.ts | 6 ++-- server/tool/src/connect.ts | 4 +-- 14 files changed, 44 insertions(+), 35 deletions(-) diff --git a/dev/generator/src/connect.ts b/dev/generator/src/connect.ts index a64de986e5..c5c42b6d95 100644 --- a/dev/generator/src/connect.ts +++ b/dev/generator/src/connect.ts @@ -1,6 +1,6 @@ import client from '@hcengineering/client' import clientResources from '@hcengineering/client-resources' -import { Client, WorkspaceId } from '@hcengineering/core' +import { Client, systemAccountEmail, WorkspaceId } from '@hcengineering/core' import { setMetadata } from '@hcengineering/platform' import { generateToken } from '@hcengineering/server-token' @@ -9,7 +9,7 @@ const WebSocket = require('ws') export async function connect (transactorUrl: string, workspace: WorkspaceId): Promise { console.log('connecting to transactor...') - const token = generateToken('anticrm@hc.engineering', workspace) + const token = generateToken(systemAccountEmail, workspace) // We need to override default factory with 'ws' one. setMetadata(client.metadata.ClientSocketFactory, (url) => new WebSocket(url)) diff --git a/models/core/src/index.ts b/models/core/src/index.ts index dcf4b80639..1e2f9b8a73 100644 --- a/models/core/src/index.ts +++ b/models/core/src/index.ts @@ -13,7 +13,15 @@ // limitations under the License. // -import { AccountRole, TxCollectionCUD, Doc, AttachedDoc, IndexingConfiguration, Class } from '@hcengineering/core' +import { + AccountRole, + TxCollectionCUD, + Doc, + AttachedDoc, + IndexingConfiguration, + Class, + systemAccountEmail +} from '@hcengineering/core' import { Builder } from '@hcengineering/model' import core from './component' import { @@ -113,7 +121,7 @@ export function createModel (builder: Builder): void { core.class.Account, core.space.Model, { - email: 'anticrm@hc.engineering', + email: systemAccountEmail, role: AccountRole.Owner }, core.account.System diff --git a/packages/core/src/component.ts b/packages/core/src/component.ts index 78d01a43e5..c9d7862631 100644 --- a/packages/core/src/component.ts +++ b/packages/core/src/component.ts @@ -62,6 +62,11 @@ import type { */ export const coreId = 'core' as Plugin +/** + * @public + */ +export const systemAccountEmail = 'anticrm@hc.engineering' + export default plugin(coreId, { class: { Obj: '' as Ref>, @@ -155,6 +160,7 @@ export default plugin(coreId, { Hyperlink: '' as IntlString, Private: '' as IntlString, Object: '' as IntlString, + System: '' as IntlString, CreatedBy: '' as IntlString } }) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 330e578c52..4bdbf1a828 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -18,7 +18,7 @@ import { coreId } from './component' // export * from './classes' export * from './client' -export { coreId, default } from './component' +export { coreId, systemAccountEmail, default } from './component' export * from './hierarchy' export * from './measurements' export * from './memdb' diff --git a/packages/core/src/lang/en.json b/packages/core/src/lang/en.json index c62a2e866f..9917a32f4f 100644 --- a/packages/core/src/lang/en.json +++ b/packages/core/src/lang/en.json @@ -27,6 +27,7 @@ "Members": "Members", "Hyperlink": "URL", "Object": "Object", + "System": "System", "CreatedBy": "Reporter" } } diff --git a/packages/core/src/lang/ru.json b/packages/core/src/lang/ru.json index e827677ddd..5c7f1d1bca 100644 --- a/packages/core/src/lang/ru.json +++ b/packages/core/src/lang/ru.json @@ -27,6 +27,7 @@ "Members": "Участники", "Hyperlink": "URL", "Object": "Объект", + "System": "Система", "CreatedBy": "Автор" } } diff --git a/plugins/activity-assets/lang/en.json b/plugins/activity-assets/lang/en.json index a20ae459a5..e779b74237 100644 --- a/plugins/activity-assets/lang/en.json +++ b/plugins/activity-assets/lang/en.json @@ -9,7 +9,6 @@ "Changed": "changed", "To": "to", "Unset": "unset", - "System": "System", "CollectionUpdated": "Update {collection}", "Added": "added", "Removed": "removed", diff --git a/plugins/activity-assets/lang/ru.json b/plugins/activity-assets/lang/ru.json index 413c0e49f3..c5f55838b2 100644 --- a/plugins/activity-assets/lang/ru.json +++ b/plugins/activity-assets/lang/ru.json @@ -9,7 +9,6 @@ "Changed": "изменил(а)", "To": "на", "Unset": "сбросил", - "System": "Система", "CollectionUpdated": "Обновлена {collection}", "Added": "добавила(а)", "Removed": "удалил(а)", diff --git a/plugins/activity-resources/src/components/TxView.svelte b/plugins/activity-resources/src/components/TxView.svelte index d2a0dccf1f..2d6a8698a7 100644 --- a/plugins/activity-resources/src/components/TxView.svelte +++ b/plugins/activity-resources/src/components/TxView.svelte @@ -173,7 +173,7 @@ {#if employee} {getName(employee)} {:else} -