Skip to content

Commit

Permalink
Merge branch 'main' into fix-570
Browse files Browse the repository at this point in the history
  • Loading branch information
SasLord committed Feb 7, 2023
2 parents fdd19e1 + 857e879 commit 4f1b6c0
Show file tree
Hide file tree
Showing 108 changed files with 1,960 additions and 795 deletions.
3 changes: 2 additions & 1 deletion dev/client-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default async () => {
if (client === undefined) {
client = await createClient(connect)
for (const op of migrateOperations) {
await op.upgrade(client)
console.log('Migrate', op[0])
await op[1].upgrade(client)
}
}
// Check if we had dev hook for client.
Expand Down
14 changes: 12 additions & 2 deletions dev/storage/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,18 @@ class InMemoryTxAdapter extends DummyDbAdapter implements TxAdapter {
return await this.txdb.findAll(_class, query, options)
}

tx (tx: Tx): Promise<TxResult> {
return this.txdb.tx(tx)
async tx (...tx: Tx[]): Promise<TxResult> {
const r: TxResult[] = []
for (const t of tx) {
r.push(await this.txdb.tx(t))
}
if (r.length === 1) {
return r[0]
}
if (r.length === 0) {
return {}
}
return r
}

async init (model: Tx[]): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion dev/tool/src/__start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function prepareTools (): {
minio: MinioService
txes: Tx[]
version: Data<Version>
migrateOperations: MigrateOperation[]
migrateOperations: [string, MigrateOperation][]
} {
return { ...prepareToolsRaw(builder.getTxes()), version, migrateOperations }
}
Expand Down
2 changes: 1 addition & 1 deletion dev/tool/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function devTool (
minio: MinioService
txes: Tx[]
version: Data<Version>
migrateOperations: MigrateOperation[]
migrateOperations: [string, MigrateOperation][]
},
productId: string
): void {
Expand Down
2 changes: 1 addition & 1 deletion dev/tool/src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export async function restoreWorkspace (
elasticUrl: string,
transactorUrl: string,
rawTxes: Tx[],
migrateOperations: MigrateOperation[]
migrateOperations: [string, MigrateOperation][]
): Promise<void> {
console.log('Restoring workspace', mongoUrl, workspaceId, fileName)
const client = new MongoClient(mongoUrl)
Expand Down
46 changes: 23 additions & 23 deletions models/all/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ import { hrOperation } from '@hcengineering/model-hr'
import { documentOperation } from '@hcengineering/model-document'
import { bitrixOperation } from '@hcengineering/model-bitrix'

export const migrateOperations: MigrateOperation[] = [
coreOperation,
chunterOperation,
demoOperation,
gmailOperation,
templatesOperation,
telegramOperation,
taskOperation,
attachmentOperation,
automationOperation,
leadOperation,
recruitOperation,
viewOperation,
contactOperation,
tagsOperation,
notificationOperation,
settingOperation,
trackerOperation,
boardOperation,
hrOperation,
documentOperation,
bitrixOperation,
inventoryOperation
export const migrateOperations: [string, MigrateOperation][] = [
['core', coreOperation],
['chunter', chunterOperation],
['demo', demoOperation],
['gmail', gmailOperation],
['templates', templatesOperation],
['telegram', telegramOperation],
['task', taskOperation],
['attachment', attachmentOperation],
['', automationOperation],
['lead', leadOperation],
['recruit', recruitOperation],
['view', viewOperation],
['contact', contactOperation],
['tags', tagsOperation],
['notification', notificationOperation],
['setting', settingOperation],
['tracker', trackerOperation],
['board', boardOperation],
['hr', hrOperation],
['document', documentOperation],
['bitrix', bitrixOperation],
['inventiry', inventoryOperation]
]
4 changes: 3 additions & 1 deletion models/board/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ export function createModel (builder: Builder): void {
input: 'any',
category: board.category.Card,
target: board.class.Card,
context: { mode: 'context', application: board.app.Board, group: 'create' }
keyBinding: ['Enter'],
context: { mode: 'context', application: board.app.Board, group: 'create' },
override: [view.action.Open]
},
board.action.Open
)
Expand Down
13 changes: 2 additions & 11 deletions models/contact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
Persons,
Status
} from '@hcengineering/contact'
import { Class, DateRangeMode, Domain, Ref, Timestamp, DOMAIN_MODEL, IndexKind } from '@hcengineering/core'
import { Class, DateRangeMode, Domain, DOMAIN_MODEL, IndexKind, Ref, Timestamp } from '@hcengineering/core'
import {
Builder,
Collection,
Expand All @@ -48,7 +48,7 @@ import attachment from '@hcengineering/model-attachment'
import chunter from '@hcengineering/model-chunter'
import core, { TAccount, TAttachedDoc, TDoc, TSpace } from '@hcengineering/model-core'
import presentation from '@hcengineering/model-presentation'
import view, { actionTemplates, createAction, ViewAction, Viewlet } from '@hcengineering/model-view'
import view, { createAction, ViewAction, Viewlet } from '@hcengineering/model-view'
import workbench from '@hcengineering/model-workbench'
import type { Asset, IntlString, Resource } from '@hcengineering/platform'
import setting from '@hcengineering/setting'
Expand Down Expand Up @@ -498,15 +498,6 @@ export function createModel (builder: Builder): void {
contact.completion.OrganizationCategory
)

createAction(builder, {
...actionTemplates.open,
target: contact.class.Contact,
context: {
mode: ['browser', 'context'],
group: 'create'
}
})

createAction(
builder,
{
Expand Down
69 changes: 40 additions & 29 deletions models/contact/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,47 @@ async function createSpace (tx: TxOperations): Promise<void> {
}

async function setCreate (client: MigrationClient): Promise<void> {
const docs = await client.find<Contact>(DOMAIN_CONTACT, {
_class: { $in: [contact.class.Contact, contact.class.Organization, contact.class.Person, contact.class.Employee] },
createOn: { $exists: false }
})
for (const doc of docs) {
const tx = (
await client.find<TxCreateDoc<Contact>>(DOMAIN_TX, {
objectId: doc._id,
_class: core.class.TxCreateDoc
})
)[0]
if (tx !== undefined) {
await client.update(
DOMAIN_CONTACT,
{
_id: doc._id
},
{
createOn: tx.modifiedOn
}
)
await client.update(
DOMAIN_TX,
{
_id: tx._id
while (true) {
const docs = await client.find<Contact>(
DOMAIN_CONTACT,
{
_class: {
$in: [contact.class.Contact, contact.class.Organization, contact.class.Person, contact.class.Employee]
},
{
'attributes.createOn': tx.modifiedOn
}
)
createOn: { $exists: false }
},
{ limit: 500 }
)
if (docs.length === 0) {
break
}
console.log('processing createOn migration', docs.length)
const creates = await client.find<TxCreateDoc<Contact>>(DOMAIN_TX, {
objectId: { $in: docs.map((it) => it._id) },
_class: core.class.TxCreateDoc
})
for (const doc of docs) {
const tx = creates.find((it) => it.objectId === doc._id)
if (tx !== undefined) {
await client.update(
DOMAIN_CONTACT,
{
_id: doc._id
},
{
createOn: tx.modifiedOn
}
)
await client.update(
DOMAIN_TX,
{
_id: tx._id
},
{
'attributes.createOn': tx.modifiedOn
}
)
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion models/document/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,15 @@ export function createModel (builder: Builder): void {

createAction(builder, {
...actionTemplates.open,
actionProps: {
component: document.component.EditDoc
},
target: document.class.Document,
context: {
mode: ['browser', 'context'],
group: 'create'
}
},
override: [view.action.Open]
})
builder.mixin(document.class.DocumentVersion, core.class.Class, view.mixin.CollectionEditor, {
editor: document.component.DocumentVersions
Expand Down
2 changes: 1 addition & 1 deletion models/gmail/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function createModel (builder: Builder): void {
label: gmail.string.WrtieEmail,
icon: contact.icon.Email,
keyBinding: [],
input: 'none',
input: 'any',
category: contact.category.Contact,
target: contact.class.Contact,
context: {
Expand Down
22 changes: 20 additions & 2 deletions models/recruit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ export function createModel (builder: Builder): void {
},
label: recruit.string.CreateTalent,
icon: recruit.icon.Create,
keyBinding: ['c'],
keyBinding: ['keyC'],
input: 'none',
category: recruit.category.Recruit,
target: core.class.Doc,
Expand Down Expand Up @@ -720,7 +720,7 @@ export function createModel (builder: Builder): void {
},
input: 'focus',
category: recruit.category.Recruit,
keyBinding: ['e'],
keyBinding: ['keyE'],
target: recruit.class.Vacancy,
context: {
mode: ['context', 'browser'],
Expand Down Expand Up @@ -1014,6 +1014,24 @@ export function createModel (builder: Builder): void {
label: recruit.string.RelatedIssues
}
})

createAction(
builder,
{
label: view.string.Move,
action: recruit.actionImpl.MoveApplicant,
icon: view.icon.Move,
input: 'any',
category: view.category.General,
target: recruit.class.Applicant,
context: {
mode: ['context', 'browser'],
group: 'tools'
},
override: [task.action.Move]
},
recruit.action.MoveApplicant
)
}

export { recruitOperation } from './migration'
Expand Down
72 changes: 39 additions & 33 deletions models/recruit/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
// limitations under the License.
//

import { getCategories } from '@anticrm/skillset'
import { Organization } from '@hcengineering/contact'
import core, { Doc, DOMAIN_TX, Ref, Space, TxCreateDoc, TxOperations } from '@hcengineering/core'
import core, { Doc, DOMAIN_TX, Ref, Space, TxCollectionCUD, TxOperations } from '@hcengineering/core'
import { createOrUpdate, MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
import { DOMAIN_CALENDAR } from '@hcengineering/model-calendar'
import contact, { DOMAIN_CONTACT } from '@hcengineering/model-contact'
import { DOMAIN_SPACE } from '@hcengineering/model-core'
import tags, { TagCategory } from '@hcengineering/model-tags'
import { createKanbanTemplate, createSequence, DOMAIN_TASK } from '@hcengineering/model-task'
import { Applicant, Vacancy } from '@hcengineering/recruit'
import { getCategories } from '@anticrm/skillset'
import { Applicant, Candidate, Vacancy } from '@hcengineering/recruit'
import { KanbanTemplate } from '@hcengineering/task'
import recruit from './plugin'

Expand All @@ -39,36 +39,42 @@ async function fixImportedTitle (client: MigrationClient): Promise<void> {
}

async function setCreate (client: MigrationClient): Promise<void> {
const docs = await client.find<Applicant>(DOMAIN_TASK, {
_class: recruit.class.Applicant,
createOn: { $exists: false }
})
for (const doc of docs) {
const tx = (
await client.find<TxCreateDoc<Applicant>>(DOMAIN_TX, {
objectId: doc._id,
_class: core.class.TxCreateDoc
})
)[0]
if (tx !== undefined) {
await client.update(
DOMAIN_CONTACT,
{
_id: doc._id
},
{
createOn: tx.modifiedOn
}
)
await client.update(
DOMAIN_TX,
{
_id: tx._id
},
{
'attributes.createOn': tx.modifiedOn
}
)
while (true) {
const docs = await client.find<Applicant>(
DOMAIN_TASK,
{
_class: recruit.class.Applicant,
createOn: { $exists: false }
},
{ limit: 500 }
)
if (docs.length === 0) break
const txex = await client.find<TxCollectionCUD<Candidate, Applicant>>(DOMAIN_TX, {
'tx.objectId': { $in: docs.map((it) => it._id) },
'tx._class': core.class.TxCreateDoc
})
for (const doc of docs) {
const tx = txex.find((it) => it.tx.objectId === doc._id)
if (tx !== undefined) {
await client.update(
DOMAIN_TASK,
{
_id: doc._id
},
{
createOn: tx.modifiedOn
}
)
await client.update(
DOMAIN_TX,
{
_id: tx._id
},
{
'tx.attributes.createOn': tx.modifiedOn
}
)
}
}
}
}
Expand Down
Loading

0 comments on commit 4f1b6c0

Please sign in to comment.