mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 19:11:33 +03:00
Fix account presenter (#2829)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
a004c6dfbb
commit
df7bb05d0d
@ -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<Client> {
|
||||
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))
|
||||
|
@ -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
|
||||
|
@ -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<Class<Obj>>,
|
||||
@ -155,6 +160,7 @@ export default plugin(coreId, {
|
||||
Hyperlink: '' as IntlString,
|
||||
Private: '' as IntlString,
|
||||
Object: '' as IntlString,
|
||||
System: '' as IntlString,
|
||||
CreatedBy: '' as IntlString
|
||||
}
|
||||
})
|
||||
|
@ -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'
|
||||
|
@ -27,6 +27,7 @@
|
||||
"Members": "Members",
|
||||
"Hyperlink": "URL",
|
||||
"Object": "Object",
|
||||
"System": "System",
|
||||
"CreatedBy": "Reporter"
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
"Members": "Участники",
|
||||
"Hyperlink": "URL",
|
||||
"Object": "Объект",
|
||||
"System": "Система",
|
||||
"CreatedBy": "Автор"
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
"Changed": "changed",
|
||||
"To": "to",
|
||||
"Unset": "unset",
|
||||
"System": "System",
|
||||
"CollectionUpdated": "Update {collection}",
|
||||
"Added": "added",
|
||||
"Removed": "removed",
|
||||
|
@ -9,7 +9,6 @@
|
||||
"Changed": "изменил(а)",
|
||||
"To": "на",
|
||||
"Unset": "сбросил",
|
||||
"System": "Система",
|
||||
"CollectionUpdated": "Обновлена {collection}",
|
||||
"Added": "добавила(а)",
|
||||
"Removed": "удалил(а)",
|
||||
|
@ -173,7 +173,7 @@
|
||||
{#if employee}
|
||||
{getName(employee)}
|
||||
{:else}
|
||||
<Label label={activity.string.System} />
|
||||
<Label label={core.string.System} />
|
||||
{/if}
|
||||
</div>
|
||||
{#if viewlet && viewlet?.editable}
|
||||
|
@ -25,7 +25,6 @@ export default mergeIds(activityId, activity, {
|
||||
Changed: '' as IntlString,
|
||||
To: '' as IntlString,
|
||||
Unset: '' as IntlString,
|
||||
System: '' as IntlString,
|
||||
Added: '' as IntlString,
|
||||
Removed: '' as IntlString,
|
||||
From: '' as IntlString,
|
||||
|
@ -14,43 +14,38 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { EmployeeAccount, getName } from '@hcengineering/contact'
|
||||
import { Account } from '@hcengineering/core'
|
||||
import { EmployeeAccount } from '@hcengineering/contact'
|
||||
import core, { Account, systemAccountEmail } from '@hcengineering/core'
|
||||
import { getEmbeddedLabel } from '@hcengineering/platform'
|
||||
import { showPopup, tooltip } from '@hcengineering/ui'
|
||||
import { EditDoc } from '@hcengineering/view-resources'
|
||||
import DocNavLink from '@hcengineering/view-resources/src/components/DocNavLink.svelte'
|
||||
import { Label, tooltip } from '@hcengineering/ui'
|
||||
import { employeeByIdStore } from '../utils'
|
||||
import Avatar from './Avatar.svelte'
|
||||
import EmployeePresenter from './EmployeePresenter.svelte'
|
||||
|
||||
export let value: Account
|
||||
export let disabled = false
|
||||
export let inline = false
|
||||
|
||||
$: employee = $employeeByIdStore.get((value as EmployeeAccount).employee)
|
||||
|
||||
async function onClick () {
|
||||
if (employee !== undefined) {
|
||||
showPopup(EditDoc, { _id: employee._id, _class: employee._class }, 'content')
|
||||
}
|
||||
}
|
||||
const valueLabel = value.email === systemAccountEmail ? core.string.System : getEmbeddedLabel(value.email)
|
||||
</script>
|
||||
|
||||
{#if value}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<DocNavLink object={value} disableClick={disabled} noUnderline={disabled} {onClick}>
|
||||
<span class="flex-row-center" use:tooltip={{ label: getEmbeddedLabel(employee ? getName(employee) : value.email) }}>
|
||||
{#if employee}
|
||||
<Avatar size={'x-small'} avatar={employee.avatar} />
|
||||
<span class="overflow-label user">{getName(employee)}</span>
|
||||
{:else}
|
||||
<span class="overflow-label user">{value.email}</span>
|
||||
{/if}
|
||||
</span>
|
||||
</DocNavLink>
|
||||
{#if employee}
|
||||
<EmployeePresenter value={employee} disableClick={disabled} {inline} />
|
||||
{:else}
|
||||
<div class="flex-row-center">
|
||||
<Avatar size="x-small" />
|
||||
<span class="overflow-label user" use:tooltip={{ label: valueLabel }}><Label label={valueLabel} /></span>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
.user {
|
||||
color: var(--accent-color);
|
||||
margin-left: 0.5rem;
|
||||
font-weight: 500;
|
||||
text-align: left;
|
||||
|
@ -27,6 +27,7 @@ import core, {
|
||||
Data,
|
||||
getWorkspaceId,
|
||||
Ref,
|
||||
systemAccountEmail,
|
||||
Tx,
|
||||
TxOperations,
|
||||
Version,
|
||||
@ -352,7 +353,7 @@ export async function createAccount (
|
||||
const salt = randomBytes(32)
|
||||
const hash = hashWithSalt(password, salt)
|
||||
|
||||
const systemEmails = ['anticrm@hc.engineering']
|
||||
const systemEmails = [systemAccountEmail]
|
||||
if (systemEmails.includes(email)) {
|
||||
throw new PlatformError(new Status(Severity.ERROR, accountPlugin.status.AccountAlreadyExists, { account: email }))
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import core, { Account, AccountRole, ServerStorage } from '@hcengineering/core'
|
||||
import core, { Account, AccountRole, ServerStorage, systemAccountEmail } from '@hcengineering/core'
|
||||
import platform, { PlatformError, Severity, Status } from '@hcengineering/platform'
|
||||
import { SessionContext } from '@hcengineering/server-core'
|
||||
|
||||
@ -35,12 +35,12 @@ export async function getUser (storage: ServerStorage, ctx: SessionContext): Pro
|
||||
}
|
||||
const account = (await storage.modelDb.findAll(core.class.Account, { email: ctx.userEmail }))[0]
|
||||
if (account === undefined) {
|
||||
if (ctx.userEmail === 'anticrm@hc.engineering') {
|
||||
if (ctx.userEmail === systemAccountEmail) {
|
||||
return {
|
||||
_id: core.account.System,
|
||||
_class: core.class.Account,
|
||||
role: AccountRole.Owner,
|
||||
email: 'anticrm@hc.engineering',
|
||||
email: systemAccountEmail,
|
||||
space: core.space.Model,
|
||||
modifiedBy: core.account.System,
|
||||
modifiedOn: 0
|
||||
|
@ -15,7 +15,7 @@
|
||||
//
|
||||
|
||||
import client, { clientId } from '@hcengineering/client'
|
||||
import { Client, WorkspaceId } from '@hcengineering/core'
|
||||
import { Client, systemAccountEmail, WorkspaceId } from '@hcengineering/core'
|
||||
import { addLocation, getResource, setMetadata } from '@hcengineering/platform'
|
||||
import { generateToken } from '@hcengineering/server-token'
|
||||
|
||||
@ -28,7 +28,7 @@ export async function connect (
|
||||
email?: string,
|
||||
extra?: Record<string, string>
|
||||
): Promise<Client> {
|
||||
const token = generateToken(email ?? 'anticrm@hc.engineering', workspace, extra)
|
||||
const token = generateToken(email ?? systemAccountEmail, workspace, extra)
|
||||
|
||||
// We need to override default factory with 'ws' one.
|
||||
// eslint-disable-next-line
|
||||
|
Loading…
Reference in New Issue
Block a user