mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-01 04:35:46 +00:00
Merge branch 'develop' into staging-new
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
commit
71e69c28de
@ -13,8 +13,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { type Doc, type Ref, type Space } from '@hcengineering/core'
|
||||
import { type Builder, Model, Prop, TypeRef } from '@hcengineering/model'
|
||||
import { type Ref, type Space } from '@hcengineering/core'
|
||||
import { type Builder, Model, Prop, TypeRef, TypeString } from '@hcengineering/model'
|
||||
import core, { TDoc } from '@hcengineering/model-core'
|
||||
import preference, { DOMAIN_PREFERENCE, type Preference, type SpacePreference } from '@hcengineering/preference'
|
||||
|
||||
@ -24,8 +24,8 @@ export { preference as default }
|
||||
|
||||
@Model(preference.class.Preference, core.class.Doc, DOMAIN_PREFERENCE)
|
||||
export class TPreference extends TDoc implements Preference {
|
||||
@Prop(TypeRef(core.class.Doc), core.string.AttachedTo)
|
||||
attachedTo!: Ref<Doc>
|
||||
@Prop(TypeString(), core.string.AttachedTo)
|
||||
attachedTo!: string
|
||||
}
|
||||
|
||||
@Model(preference.class.SpacePreference, preference.class.Preference)
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { type Class, DOMAIN_MODEL, type Ref, type Space, type AccountRole } from '@hcengineering/core'
|
||||
import { type Class, DOMAIN_MODEL, type Ref, type Space, type AccountRole, type PersonId } from '@hcengineering/core'
|
||||
import { type Builder, Mixin, Model, Prop, TypeRef, UX } from '@hcengineering/model'
|
||||
import preference, { TPreference } from '@hcengineering/model-preference'
|
||||
import { createAction } from '@hcengineering/model-view'
|
||||
@ -106,6 +106,7 @@ export class TTxSidebarEvent extends TTx implements TxSidebarEvent {
|
||||
@Model(workbench.class.WorkbenchTab, preference.class.Preference)
|
||||
@UX(workbench.string.Tab)
|
||||
export class TWorkbenchTab extends TPreference implements WorkbenchTab {
|
||||
declare attachedTo: PersonId
|
||||
location!: string
|
||||
name?: string
|
||||
isPinned!: boolean
|
||||
|
@ -19,8 +19,9 @@ import {
|
||||
tryMigrate
|
||||
} from '@hcengineering/model'
|
||||
import { DOMAIN_PREFERENCE } from '@hcengineering/preference'
|
||||
import workbench from '@hcengineering/workbench'
|
||||
import core, { DOMAIN_TX } from '@hcengineering/core'
|
||||
import workbench, { type WorkbenchTab } from '@hcengineering/workbench'
|
||||
import core, { DOMAIN_TX, MeasureMetricsContext } from '@hcengineering/core'
|
||||
import { getSocialIdByOldAccount } from '@hcengineering/model-core'
|
||||
|
||||
import { workbenchId } from '.'
|
||||
|
||||
@ -28,6 +29,20 @@ async function removeTabs (client: MigrationClient): Promise<void> {
|
||||
await client.deleteMany(DOMAIN_PREFERENCE, { _class: workbench.class.WorkbenchTab })
|
||||
}
|
||||
|
||||
async function migrateTabsToSocialIds (client: MigrationClient): Promise<void> {
|
||||
const ctx = new MeasureMetricsContext('workbench migrateTabsToSocialIds', {})
|
||||
ctx.info('migrating workbench tabs to social ids...')
|
||||
const socialIdByAccount = await getSocialIdByOldAccount(client)
|
||||
const tabs = await client.find<WorkbenchTab>(DOMAIN_PREFERENCE, { _class: workbench.class.WorkbenchTab })
|
||||
for (const tab of tabs) {
|
||||
const newAttachedTo = socialIdByAccount[tab.attachedTo]
|
||||
if (newAttachedTo != null && newAttachedTo !== tab.attachedTo) {
|
||||
await client.update(DOMAIN_PREFERENCE, { _id: tab._id }, { attachedTo: newAttachedTo })
|
||||
}
|
||||
}
|
||||
ctx.info('migrating workbench tabs to social ids completed...')
|
||||
}
|
||||
|
||||
export const workbenchOperation: MigrateOperation = {
|
||||
async migrate (client: MigrationClient): Promise<void> {
|
||||
await tryMigrate(client, workbenchId, [
|
||||
@ -43,6 +58,10 @@ export const workbenchOperation: MigrateOperation = {
|
||||
_class: core.class.TxUpdateDoc
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
state: 'tabs-accounts-to-social-ids',
|
||||
func: migrateTabsToSocialIds
|
||||
}
|
||||
])
|
||||
},
|
||||
|
@ -21,7 +21,7 @@ import { plugin } from '@hcengineering/platform'
|
||||
* @public
|
||||
*/
|
||||
export interface Preference extends Doc {
|
||||
attachedTo: Ref<Doc>
|
||||
attachedTo: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,7 +190,7 @@
|
||||
const query = createQuery()
|
||||
$: query.query(
|
||||
workbench.class.WorkbenchTab,
|
||||
{ attachedTo: me },
|
||||
{ attachedTo: { $in: account.socialIds } },
|
||||
(res) => {
|
||||
tabs = res
|
||||
tabsStore.set(tabs)
|
||||
@ -240,7 +240,7 @@
|
||||
} else {
|
||||
console.log('Creating new tab on init')
|
||||
const _id = await client.createDoc(workbench.class.WorkbenchTab, core.space.Workspace, {
|
||||
attachedTo: me,
|
||||
attachedTo: account.primarySocialId,
|
||||
location: url,
|
||||
isPinned: false
|
||||
})
|
||||
|
@ -42,7 +42,6 @@ import notification, { notificationId } from '@hcengineering/notification'
|
||||
|
||||
import { locationWorkspaceStore } from './utils'
|
||||
import workbench from './plugin'
|
||||
import { getCurrentEmployee } from '@hcengineering/contact'
|
||||
|
||||
export const tabIdStore = writable<Ref<WorkbenchTab> | undefined>()
|
||||
export const prevTabIdStore = writable<Ref<WorkbenchTab> | undefined>()
|
||||
@ -98,14 +97,13 @@ const syncTabLoc = reduceCalls(async (): Promise<void> => {
|
||||
}
|
||||
|
||||
const me = getCurrentAccount()
|
||||
const currentEmployee = getCurrentEmployee()
|
||||
const newTab: WorkbenchTab = {
|
||||
_id: generateId(),
|
||||
_class: workbench.class.WorkbenchTab,
|
||||
space: core.space.Workspace,
|
||||
location: url,
|
||||
name,
|
||||
attachedTo: currentEmployee,
|
||||
attachedTo: me.primarySocialId,
|
||||
isPinned: false,
|
||||
modifiedOn: Date.now(),
|
||||
modifiedBy: me.primarySocialId
|
||||
@ -198,7 +196,6 @@ export async function closeTab (tab: WorkbenchTab): Promise<void> {
|
||||
export async function createTab (): Promise<void> {
|
||||
const loc = getCurrentLocation()
|
||||
const client = getClient()
|
||||
const me = getCurrentEmployee()
|
||||
let defaultUrl = `${workbenchId}/${loc.path[1]}/${notificationId}`
|
||||
|
||||
try {
|
||||
@ -213,7 +210,7 @@ export async function createTab (): Promise<void> {
|
||||
|
||||
const name = await translate(notification.string.Inbox, {}, get(languageStore))
|
||||
const tab = await client.createDoc(workbench.class.WorkbenchTab, core.space.Workspace, {
|
||||
attachedTo: me,
|
||||
attachedTo: getCurrentAccount().primarySocialId,
|
||||
location: defaultUrl,
|
||||
isPinned: false,
|
||||
name
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import type { AccountRole, Class, Doc, Mixin, Obj, Ref, Space, Tx } from '@hcengineering/core'
|
||||
import type { AccountRole, Class, Doc, Mixin, Obj, PersonId, Ref, Space, Tx } from '@hcengineering/core'
|
||||
import { DocNotifyContext, InboxNotification } from '@hcengineering/notification'
|
||||
import type { Asset, IntlString, Metadata, Plugin, Resource } from '@hcengineering/platform'
|
||||
import { plugin } from '@hcengineering/platform'
|
||||
@ -116,6 +116,7 @@ export interface TxSidebarEvent<T extends Record<string, any> = Record<string, a
|
||||
}
|
||||
|
||||
export interface WorkbenchTab extends Preference {
|
||||
attachedTo: PersonId
|
||||
location: string
|
||||
isPinned: boolean
|
||||
name?: string
|
||||
|
Loading…
Reference in New Issue
Block a user