Add system spaces (#2724)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-03-13 13:57:10 +06:00 committed by GitHub
parent fff54ea212
commit 3cfd9f14b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 176 additions and 2 deletions

View File

@ -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],

View File

@ -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)
}
}

View File

@ -200,4 +200,5 @@ export function createModel (builder: Builder): void {
})
}
export { calendarOperation } from './migration'
export default calendar

View 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)
}
}

View File

@ -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)
}
}

View File

@ -35,3 +35,4 @@ export function createModel (builder: Builder): void {
}
export { preference as default }
export { preferenceOperation } from './migration'

View 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)
}
}

View File

@ -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)
}
}