mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 03:22:19 +03:00
Add system spaces (#2724)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
fff54ea212
commit
3cfd9f14b1
@ -22,6 +22,7 @@ import { contactOperation } from '@hcengineering/model-contact'
|
||||
import { coreOperation } from '@hcengineering/model-core'
|
||||
import { gmailOperation } from '@hcengineering/model-gmail'
|
||||
import { leadOperation } from '@hcengineering/model-lead'
|
||||
import { preferenceOperation } from '@hcengineering/model-preference'
|
||||
import { notificationOperation } from '@hcengineering/model-notification'
|
||||
import { settingOperation } from '@hcengineering/model-setting'
|
||||
import { recruitOperation } from '@hcengineering/model-recruit'
|
||||
@ -37,10 +38,12 @@ import { demoOperation } from '@hcengineering/model-demo'
|
||||
import { hrOperation } from '@hcengineering/model-hr'
|
||||
import { documentOperation } from '@hcengineering/model-document'
|
||||
import { bitrixOperation } from '@hcengineering/model-bitrix'
|
||||
import { calendarOperation } from '@hcengineering/model-calendar'
|
||||
|
||||
export const migrateOperations: [string, MigrateOperation][] = [
|
||||
['core', coreOperation],
|
||||
['chunter', chunterOperation],
|
||||
['calendar', calendarOperation],
|
||||
['demo', demoOperation],
|
||||
['gmail', gmailOperation],
|
||||
['templates', templatesOperation],
|
||||
@ -49,6 +52,7 @@ export const migrateOperations: [string, MigrateOperation][] = [
|
||||
['attachment', attachmentOperation],
|
||||
['automation', automationOperation],
|
||||
['lead', leadOperation],
|
||||
['preference', preferenceOperation],
|
||||
['recruit', recruitOperation],
|
||||
['view', viewOperation],
|
||||
['contact', contactOperation],
|
||||
|
@ -13,9 +13,34 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import core, { TxOperations } from '@hcengineering/core'
|
||||
import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
|
||||
import bitrix from './plugin'
|
||||
|
||||
async function createSpace (tx: TxOperations): Promise<void> {
|
||||
const current = await tx.findOne(core.class.Space, {
|
||||
_id: bitrix.space.Mappings
|
||||
})
|
||||
if (current === undefined) {
|
||||
await tx.createDoc(
|
||||
core.class.Space,
|
||||
core.space.Space,
|
||||
{
|
||||
name: 'Bitrix mappings',
|
||||
description: 'Bitrix mappings',
|
||||
private: false,
|
||||
archived: false,
|
||||
members: []
|
||||
},
|
||||
bitrix.space.Mappings
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export const bitrixOperation: MigrateOperation = {
|
||||
async migrate (client: MigrationClient): Promise<void> {},
|
||||
async upgrade (client: MigrationUpgradeClient): Promise<void> {}
|
||||
async upgrade (client: MigrationUpgradeClient): Promise<void> {
|
||||
const tx = new TxOperations(client, core.account.System)
|
||||
await createSpace(tx)
|
||||
}
|
||||
}
|
||||
|
@ -200,4 +200,5 @@ export function createModel (builder: Builder): void {
|
||||
})
|
||||
}
|
||||
|
||||
export { calendarOperation } from './migration'
|
||||
export default calendar
|
||||
|
46
models/calendar/src/migration.ts
Normal file
46
models/calendar/src/migration.ts
Normal file
@ -0,0 +1,46 @@
|
||||
//
|
||||
// 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, { TxOperations } from '@hcengineering/core'
|
||||
import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
|
||||
import calendar from './plugin'
|
||||
|
||||
async function createSpace (tx: TxOperations): Promise<void> {
|
||||
const current = await tx.findOne(core.class.Space, {
|
||||
_id: calendar.space.PersonalEvents
|
||||
})
|
||||
if (current === undefined) {
|
||||
await tx.createDoc(
|
||||
core.class.Space,
|
||||
core.space.Space,
|
||||
{
|
||||
name: 'Personal Events',
|
||||
description: 'Personal Events',
|
||||
private: false,
|
||||
archived: false,
|
||||
members: []
|
||||
},
|
||||
calendar.space.PersonalEvents
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export const calendarOperation: MigrateOperation = {
|
||||
async migrate (client: MigrationClient): Promise<void> {},
|
||||
async upgrade (client: MigrationUpgradeClient): Promise<void> {
|
||||
const tx = new TxOperations(client, core.account.System)
|
||||
await createSpace(tx)
|
||||
}
|
||||
}
|
@ -62,6 +62,26 @@ export async function createRandom (tx: TxOperations): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function createBacklink (tx: TxOperations): Promise<void> {
|
||||
const current = await tx.findOne(core.class.Space, {
|
||||
_id: chunter.space.Backlinks
|
||||
})
|
||||
if (current === undefined) {
|
||||
await tx.createDoc(
|
||||
core.class.Space,
|
||||
core.space.Space,
|
||||
{
|
||||
name: 'Backlinks',
|
||||
description: 'Backlinks',
|
||||
private: false,
|
||||
archived: false,
|
||||
members: []
|
||||
},
|
||||
chunter.space.Backlinks
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export async function setCreate (client: TxOperations): Promise<void> {
|
||||
const messages = (await client.findAll(chunter.class.Message, {}))
|
||||
.filter((m) => m.createBy === undefined)
|
||||
@ -201,6 +221,7 @@ export const chunterOperation: MigrateOperation = {
|
||||
const tx = new TxOperations(client, core.account.System)
|
||||
await createGeneral(tx)
|
||||
await createRandom(tx)
|
||||
await createBacklink(tx)
|
||||
await setCreate(tx)
|
||||
}
|
||||
}
|
||||
|
@ -35,3 +35,4 @@ export function createModel (builder: Builder): void {
|
||||
}
|
||||
|
||||
export { preference as default }
|
||||
export { preferenceOperation } from './migration'
|
||||
|
51
models/preference/src/migration.ts
Normal file
51
models/preference/src/migration.ts
Normal file
@ -0,0 +1,51 @@
|
||||
//
|
||||
// Copyright © 2023 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 { TxOperations } from '@hcengineering/core'
|
||||
import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
|
||||
import core from '@hcengineering/model-core'
|
||||
import preference from '@hcengineering/preference'
|
||||
|
||||
async function createSpace (tx: TxOperations): Promise<void> {
|
||||
const current = await tx.findOne(core.class.Space, {
|
||||
_id: preference.space.Preference
|
||||
})
|
||||
if (current === undefined) {
|
||||
await tx.createDoc(
|
||||
core.class.Space,
|
||||
core.space.Space,
|
||||
{
|
||||
name: 'Preference',
|
||||
description: 'Preference space',
|
||||
private: false,
|
||||
archived: false,
|
||||
members: []
|
||||
},
|
||||
preference.space.Preference
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
async function createDefaults (tx: TxOperations): Promise<void> {
|
||||
await createSpace(tx)
|
||||
}
|
||||
|
||||
export const preferenceOperation: MigrateOperation = {
|
||||
async migrate (client: MigrationClient): Promise<void> {},
|
||||
async upgrade (client: MigrationUpgradeClient): Promise<void> {
|
||||
const ops = new TxOperations(client, core.account.System)
|
||||
await createDefaults(ops)
|
||||
}
|
||||
}
|
@ -13,9 +13,34 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import core, { TxOperations } from '@hcengineering/core'
|
||||
import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
|
||||
import setting from './plugin'
|
||||
|
||||
async function createSpace (tx: TxOperations): Promise<void> {
|
||||
const current = await tx.findOne(core.class.Space, {
|
||||
_id: setting.space.Setting
|
||||
})
|
||||
if (current === undefined) {
|
||||
await tx.createDoc(
|
||||
core.class.Space,
|
||||
core.space.Space,
|
||||
{
|
||||
name: 'Setting',
|
||||
description: 'Setting space',
|
||||
private: false,
|
||||
archived: false,
|
||||
members: []
|
||||
},
|
||||
setting.space.Setting
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export const settingOperation: MigrateOperation = {
|
||||
async migrate (client: MigrationClient): Promise<void> {},
|
||||
async upgrade (client: MigrationUpgradeClient): Promise<void> {}
|
||||
async upgrade (client: MigrationUpgradeClient): Promise<void> {
|
||||
const tx = new TxOperations(client, core.account.System)
|
||||
await createSpace(tx)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user