mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 03:14:40 +03:00
Nevdex fixes (#3714)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
0560821f39
commit
87ee2a028f
10
.vscode/launch.json
vendored
10
.vscode/launch.json
vendored
@ -67,7 +67,7 @@
|
||||
"env": {
|
||||
"MONGO_URL": "mongodb://localhost:27017",
|
||||
"SERVER_SECRET": "secret",
|
||||
"TRANSACTOR_URL": "ws:/localhost:3333",
|
||||
"TRANSACTOR_URL": "ws://localhost:3333",
|
||||
"ACCOUNT_PORT": "3000",
|
||||
"FRONT_URL": "http://localhost:8080",
|
||||
"SES_URL": "http://localhost:8091",
|
||||
@ -97,7 +97,7 @@
|
||||
"request": "launch",
|
||||
"args": ["src/index.ts", "gen-recruit", "ws1", "20"],
|
||||
"env": {
|
||||
"TRANSACTOR_URL": "ws:/localhost:3333",
|
||||
"TRANSACTOR_URL": "ws://localhost:3333",
|
||||
"MINIO_ACCESS_KEY": "minioadmin",
|
||||
"MINIO_SECRET_KEY": "minioadmin",
|
||||
"MINIO_ENDPOINT": "localhost"
|
||||
@ -117,7 +117,7 @@
|
||||
"MINIO_SECRET_KEY": "minioadmin",
|
||||
"MINIO_ENDPOINT": "localhost",
|
||||
"MONGO_URL": "mongodb://localhost:27017",
|
||||
"TRANSACTOR_URL": "ws:/localhost:3333",
|
||||
"TRANSACTOR_URL": "ws://localhost:3333",
|
||||
"TELEGRAM_DATABASE": "telegram-service",
|
||||
"ELASTIC_URL": "http://localhost:9200"
|
||||
},
|
||||
@ -137,7 +137,7 @@
|
||||
"MINIO_SECRET_KEY": "minioadmin",
|
||||
"MINIO_ENDPOINT": "localhost",
|
||||
"MONGO_URL": "mongodb://localhost:27017",
|
||||
"TRANSACTOR_URL": "ws:/localhost:3333",
|
||||
"TRANSACTOR_URL": "ws://localhost:3333",
|
||||
"TELEGRAM_DATABASE": "telegram-service",
|
||||
"ELASTIC_URL": "http://localhost:9200",
|
||||
"REKONI_URL": "http://localhost:4004"
|
||||
@ -157,7 +157,7 @@
|
||||
"MINIO_ACCESS_KEY": "minioadmin",
|
||||
"MINIO_SECRET_KEY": "minioadmin",
|
||||
"SECRET": "secret",
|
||||
"TRANSACTOR_URL": "ws:/localhost:3333",
|
||||
"TRANSACTOR_URL": "ws://localhost:3333",
|
||||
"BUCKET_NAME":"test_backups",
|
||||
"INTERVAL":"30"
|
||||
},
|
||||
|
@ -10,7 +10,7 @@
|
||||
"lint:fix": "eslint --fix src",
|
||||
"start": "ts-node src/index.ts",
|
||||
"bundle": "esbuild src/index.ts --bundle --minify --platform=node > bundle.js",
|
||||
"run-local": "TRANSACTOR_URL=ws:/localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ts-node ./src/index.ts",
|
||||
"run-local": "TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost ts-node ./src/index.ts",
|
||||
"lint": "eslint src",
|
||||
"format": "prettier --write src && eslint --fix src"
|
||||
},
|
||||
|
@ -13,7 +13,7 @@
|
||||
"docker:build": "docker build -t hardcoreeng/tool .",
|
||||
"docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/tool staging",
|
||||
"docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/tool",
|
||||
"run-local": "cross-env SERVER_SECRET=secret MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost MONGO_URL=mongodb://localhost:27017 TRANSACTOR_URL=ws:/localhost:3333 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../models/all/lib/__showversion.js) GIT_REVISION=$(git describe --all --long) node -r ts-node/register --max-old-space-size=18000 ./src/__start.ts",
|
||||
"run-local": "cross-env SERVER_SECRET=secret MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost MONGO_URL=mongodb://localhost:27017 TRANSACTOR_URL=ws://localhost:3333 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../models/all/lib/__showversion.js) GIT_REVISION=$(git describe --all --long) node -r ts-node/register --max-old-space-size=18000 ./src/__start.ts",
|
||||
"run": "cross-env node -r ts-node/register --max-old-space-size=8000 ./src/__start.ts",
|
||||
"upgrade": "rushx run-local upgrade",
|
||||
"lint": "eslint src",
|
||||
|
@ -760,26 +760,6 @@ export function createModel (builder: Builder): void {
|
||||
},
|
||||
contact.action.KickEmployee
|
||||
)
|
||||
createAction(
|
||||
builder,
|
||||
{
|
||||
action: contact.actionImpl.KickEmployee,
|
||||
label: contact.string.DeleteEmployee,
|
||||
icon: contact.icon.KickUser,
|
||||
query: {
|
||||
active: false
|
||||
},
|
||||
category: contact.category.Contact,
|
||||
target: contact.mixin.Employee,
|
||||
input: 'focus',
|
||||
context: {
|
||||
mode: ['context'],
|
||||
group: 'remove'
|
||||
},
|
||||
secured: true
|
||||
},
|
||||
contact.action.DeleteEmployee
|
||||
)
|
||||
|
||||
createAction(
|
||||
builder,
|
||||
|
@ -13,17 +13,16 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Channel, combineName, Employee, findPerson, Person } from '@hcengineering/contact'
|
||||
import { Channel, combineName, Employee, Person, PersonAccount } from '@hcengineering/contact'
|
||||
import core, { AccountRole, AttachedData, Data, generateId, Ref } from '@hcengineering/core'
|
||||
import login from '@hcengineering/login'
|
||||
import { getResource } from '@hcengineering/platform'
|
||||
import { Card, getClient } from '@hcengineering/presentation'
|
||||
import { Card, createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { createFocusManager, EditBox, FocusHandler, IconInfo, Label } from '@hcengineering/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { ChannelsDropdown } from '..'
|
||||
import contact from '../plugin'
|
||||
import EditableAvatar from './EditableAvatar.svelte'
|
||||
import PersonPresenter from './PersonPresenter.svelte'
|
||||
|
||||
export let canSave: boolean = true
|
||||
export let onCreate: ((id: Ref<Employee>) => Promise<void>) | undefined = undefined
|
||||
@ -60,8 +59,10 @@
|
||||
active: true
|
||||
})
|
||||
|
||||
const mail = email.trim()
|
||||
|
||||
await client.createDoc(contact.class.PersonAccount, core.space.Model, {
|
||||
email: email.trim(),
|
||||
email: mail,
|
||||
person: id,
|
||||
role: AccountRole.User
|
||||
})
|
||||
@ -88,10 +89,17 @@
|
||||
}
|
||||
]
|
||||
|
||||
let matches: Person[] = []
|
||||
$: findPerson(client, combineName(firstName, lastName), channels).then((p) => {
|
||||
matches = p
|
||||
})
|
||||
let exists: PersonAccount | undefined
|
||||
const query = createQuery()
|
||||
$: query.query(
|
||||
contact.class.PersonAccount,
|
||||
{
|
||||
email: email.trim()
|
||||
},
|
||||
(p) => {
|
||||
exists = p[0]
|
||||
}
|
||||
)
|
||||
|
||||
const manager = createFocusManager()
|
||||
|
||||
@ -116,8 +124,8 @@
|
||||
okAction={createPerson}
|
||||
canSave={firstName.trim().length > 0 &&
|
||||
lastName.trim().length > 0 &&
|
||||
matches.length === 0 &&
|
||||
email.trim().length > 0 &&
|
||||
exists === undefined &&
|
||||
canSave}
|
||||
on:close={() => {
|
||||
dispatch('close')
|
||||
@ -125,13 +133,12 @@
|
||||
on:changeContent
|
||||
>
|
||||
<svelte:fragment slot="error">
|
||||
{#if matches.length > 0}
|
||||
{#if exists !== undefined}
|
||||
<div class="flex-row-center error-color">
|
||||
<IconInfo size={'small'} />
|
||||
<span class="text-sm overflow-label ml-2">
|
||||
<Label label={contact.string.PersonAlreadyExists} />
|
||||
</span>
|
||||
<div class="ml-4"><PersonPresenter value={matches[0]} /></div>
|
||||
</div>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
|
@ -218,22 +218,6 @@ async function kickEmployee (doc: Person): Promise<void> {
|
||||
|
||||
const employee = client.getHierarchy().as(doc, contact.mixin.Employee)
|
||||
const email = await client.findOne(contact.class.PersonAccount, { person: doc._id })
|
||||
if (!employee.active) {
|
||||
showPopup(
|
||||
MessageBox,
|
||||
{
|
||||
label: contact.string.DeleteEmployee,
|
||||
message: contact.string.DeleteEmployeeDescr
|
||||
},
|
||||
undefined,
|
||||
(res?: boolean) => {
|
||||
if (res === true) {
|
||||
void client.remove(doc)
|
||||
}
|
||||
}
|
||||
)
|
||||
return
|
||||
}
|
||||
if (email === undefined) {
|
||||
await client.update(employee, { active: false })
|
||||
} else {
|
||||
|
@ -13,7 +13,7 @@
|
||||
"docker:build": "docker build -t hardcoreeng/account .",
|
||||
"docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/account staging",
|
||||
"docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/account",
|
||||
"run-local": "cross-env MONGO_URL=mongodb://localhost:27017 MINIO_ACCESS_KEY=minioadmi MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost SERVER_SECRET='secret' TRANSACTOR_URL=ws:/localhost:3333 ts-node src/__start.ts",
|
||||
"run-local": "cross-env MONGO_URL=mongodb://localhost:27017 MINIO_ACCESS_KEY=minioadmi MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost SERVER_SECRET='secret' TRANSACTOR_URL=ws://localhost:3333 ts-node src/__start.ts",
|
||||
"lint": "eslint src",
|
||||
"format": "prettier --write src && eslint --fix src"
|
||||
},
|
||||
|
@ -13,7 +13,7 @@
|
||||
"docker:build": "docker build -t hardcoreeng/backup .",
|
||||
"docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/backup staging",
|
||||
"docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/backup",
|
||||
"run-local": "cross-env ACCOUNTS_URL=http://localhost:3000/ SECRET=secret MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost TRANSACTOR_URL=ws:/localhost:3333 BUCKET_NAME=backups INTERVAL=30 ts-node src/index.ts",
|
||||
"run-local": "cross-env ACCOUNTS_URL=http://localhost:3000/ SECRET=secret MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost TRANSACTOR_URL=ws://localhost:3333 BUCKET_NAME=backups INTERVAL=30 ts-node src/index.ts",
|
||||
"lint": "eslint src",
|
||||
"format": "prettier --write src && eslint --fix src"
|
||||
},
|
||||
|
@ -15,7 +15,7 @@
|
||||
"docker:tbuild": "docker build -t hardcoreeng/front . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/front",
|
||||
"lint": "eslint src",
|
||||
"format": "prettier --write src && eslint --fix src",
|
||||
"run-local": "cross-env MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost TRANSACTOR_URL=ws:/localhost:3333 SERVER_SECRET='secret' ACCOUNTS_URL=http://localhost:3000 UPLOAD_URL=/files ELASTIC_URL=http://localhost:9200 MODEL_VERSION=$(node ../../models/all/lib/__showversion.js) PUBLIC_DIR='.' ts-node ./src/__start.ts"
|
||||
"run-local": "cross-env MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost TRANSACTOR_URL=ws://localhost:3333 SERVER_SECRET='secret' ACCOUNTS_URL=http://localhost:3000 UPLOAD_URL=/files ELASTIC_URL=http://localhost:9200 MODEL_VERSION=$(node ../../models/all/lib/__showversion.js) PUBLIC_DIR='.' ts-node ./src/__start.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@hcengineering/platform-rig": "^0.6.0",
|
||||
|
@ -54,6 +54,7 @@ import type { TriggerControl } from '@hcengineering/server-core'
|
||||
import serverNotification, {
|
||||
HTMLPresenter,
|
||||
TextPresenter,
|
||||
getEmployee,
|
||||
getPersonAccount,
|
||||
getPersonAccountById
|
||||
} from '@hcengineering/server-notification'
|
||||
@ -366,7 +367,7 @@ function isTypeMatched (
|
||||
): boolean {
|
||||
const h = control.hierarchy
|
||||
const targetClass = h.getBaseClass(type.objectClass)
|
||||
if (!type.txClasses.includes(extractedTx._class)) return false
|
||||
if (!type.txClasses.includes(tx._class)) return false
|
||||
if (!control.hierarchy.isDerived(h.getBaseClass(extractedTx.objectClass), targetClass)) return false
|
||||
if (tx._class === core.class.TxCollectionCUD && type.attachedToClass !== undefined) {
|
||||
if (!control.hierarchy.isDerived(h.getBaseClass(tx.objectClass), h.getBaseClass(type.attachedToClass))) return false
|
||||
@ -508,17 +509,23 @@ async function getNotificationTxes (
|
||||
if (allowed.allowed) {
|
||||
pushNotification(control, res, target, object, originTx, docUpdates)
|
||||
}
|
||||
for (const type of allowed.emails) {
|
||||
const emailTx = await createEmailNotificationTxes(
|
||||
control,
|
||||
originTx,
|
||||
type._id,
|
||||
object,
|
||||
originTx.modifiedBy as Ref<PersonAccount>,
|
||||
target as Ref<PersonAccount>
|
||||
)
|
||||
if (emailTx !== undefined) {
|
||||
res.push(emailTx)
|
||||
if (allowed.emails.length === 0) return res
|
||||
const acc = await getPersonAccountById(target, control)
|
||||
if (acc === undefined) return res
|
||||
const emp = await getEmployee(acc.person as Ref<Employee>, control)
|
||||
if (emp?.active === true) {
|
||||
for (const type of allowed.emails) {
|
||||
const emailTx = await createEmailNotificationTxes(
|
||||
control,
|
||||
originTx,
|
||||
type._id,
|
||||
object,
|
||||
originTx.modifiedBy as Ref<PersonAccount>,
|
||||
target as Ref<PersonAccount>
|
||||
)
|
||||
if (emailTx !== undefined) {
|
||||
res.push(emailTx)
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
@ -847,7 +854,7 @@ export async function isUserEmployeeInFieldValue (
|
||||
): Promise<boolean> {
|
||||
if (type.field === undefined) return false
|
||||
const value = (doc as any)[type.field]
|
||||
if (value === undefined) return false
|
||||
if (value == null) return false
|
||||
const employee = (await control.modelDb.findAll(contact.class.PersonAccount, { _id: user as Ref<PersonAccount> }))[0]
|
||||
if (employee === undefined) return false
|
||||
if (Array.isArray(value)) {
|
||||
|
@ -267,7 +267,8 @@ export async function selectWorkspace (
|
||||
db: Db,
|
||||
productId: string,
|
||||
token: string,
|
||||
workspace: string
|
||||
workspace: string,
|
||||
allowAdmin: boolean = true
|
||||
): Promise<WorkspaceLoginInfo> {
|
||||
const { email } = decodeToken(token)
|
||||
const accountInfo = await getAccount(db, email)
|
||||
@ -275,7 +276,7 @@ export async function selectWorkspace (
|
||||
throw new PlatformError(new Status(Severity.ERROR, platform.status.AccountNotFound, { account: email }))
|
||||
}
|
||||
|
||||
if (accountInfo.admin === true) {
|
||||
if (accountInfo.admin === true && allowAdmin) {
|
||||
return {
|
||||
endpoint: getEndpoint(),
|
||||
email,
|
||||
@ -999,7 +1000,7 @@ export async function checkJoin (
|
||||
const { email } = decodeToken(token)
|
||||
const invite = await getInvite(db, inviteId)
|
||||
const workspace = await checkInvite(invite, email)
|
||||
return await selectWorkspace(db, productId, token, workspace.name)
|
||||
return await selectWorkspace(db, productId, token, workspace.name, false)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,7 @@ export MINIO_ACCESS_KEY=minioadmin
|
||||
export MINIO_SECRET_KEY=minioadmin
|
||||
export MINIO_ENDPOINT=localhost:9000
|
||||
export MONGO_URL=mongodb://localhost:27017
|
||||
export TRANSACTOR_URL=ws:/localhost:3333
|
||||
export TRANSACTOR_URL=ws://localhost:3333
|
||||
export ELASTIC_URL=http://localhost:9200
|
||||
export SERVER_SECRET=secret
|
||||
|
||||
|
@ -3,7 +3,7 @@ export MINIO_ACCESS_KEY=minioadmin
|
||||
export MINIO_SECRET_KEY=minioadmin
|
||||
export MINIO_ENDPOINT=localhost:9000
|
||||
export MONGO_URL=mongodb://localhost:27017
|
||||
export TRANSACTOR_URL=ws:/localhost:3333
|
||||
export TRANSACTOR_URL=ws://localhost:3333
|
||||
export ELASTIC_URL=http://localhost:9200
|
||||
export SERVER_SECRET=secret
|
||||
|
||||
|
@ -139,19 +139,5 @@ test.describe('contact tests', () => {
|
||||
await page.click('text=Ok')
|
||||
|
||||
await expect(page.locator(`td:has-text("${last} ${first}")`)).toHaveCount(1)
|
||||
|
||||
// We need some time to ensure that the status is proper one
|
||||
await page.waitForTimeout(1000)
|
||||
|
||||
// Delete employee
|
||||
|
||||
// Click #context-menu svg
|
||||
await page.hover(`td:has-text("${last} ${first}")`)
|
||||
await page.click(`td:has-text("${last} ${first}")`, { button: 'right' })
|
||||
await page.click('text="Delete employee"')
|
||||
// Click text=Ok
|
||||
await page.click('text=Ok')
|
||||
|
||||
await expect(page.locator(`td:has-text("${last} ${first}")`)).toHaveCount(0)
|
||||
})
|
||||
})
|
||||
|
@ -4,7 +4,7 @@ export MINIO_ACCESS_KEY=minioadmin
|
||||
export MINIO_SECRET_KEY=minioadmin
|
||||
export MINIO_ENDPOINT=localhost:9002
|
||||
export MONGO_URL=mongodb://localhost:27018
|
||||
export TRANSACTOR_URL=ws:/localhost:3334
|
||||
export TRANSACTOR_URL=ws://localhost:3334
|
||||
export ELASTIC_URL=http://localhost:9201
|
||||
export SERVER_SECRET=secret
|
||||
|
||||
|
@ -3,7 +3,7 @@ export MINIO_ACCESS_KEY=minioadmin
|
||||
export MINIO_SECRET_KEY=minioadmin
|
||||
export MINIO_ENDPOINT=localhost:9000
|
||||
export MONGO_URL=mongodb://localhost:27017
|
||||
export TRANSACTOR_URL=ws:/localhost:3333
|
||||
export TRANSACTOR_URL=ws://localhost:3333
|
||||
export ELASTIC_URL=http://localhost:9200
|
||||
export SERVER_SECRET=secret
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user