mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-08 02:37:44 +02:00
UBERF-8557 Save collaborative content as JSON (#7039)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
@@ -14,7 +14,6 @@ import core, {
|
||||
Account,
|
||||
AttachedDoc,
|
||||
Class,
|
||||
CollaborativeDoc,
|
||||
Doc,
|
||||
DocumentUpdate,
|
||||
Markup,
|
||||
@@ -22,7 +21,8 @@ import core, {
|
||||
Ref,
|
||||
Space,
|
||||
Status,
|
||||
TxOperations
|
||||
TxOperations,
|
||||
makeDocCollabId
|
||||
} from '@hcengineering/core'
|
||||
import github, {
|
||||
DocSyncInfo,
|
||||
@@ -74,8 +74,8 @@ import {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type WithMarkup<T> = {
|
||||
[P in keyof T]: T[P] extends CollaborativeDoc ? Markup : T[P]
|
||||
export type WithMarkup<T extends Issue> = Omit<T, 'description'> & {
|
||||
description: Markup
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,7 +259,7 @@ export abstract class IssueSyncManagerBase {
|
||||
}
|
||||
|
||||
let needProjectRefresh = false
|
||||
const update: DocumentUpdate<Issue> & Record<string, any> = {}
|
||||
const update: DocumentUpdate<WithMarkup<Issue>> & Record<string, any> = {}
|
||||
|
||||
let structure = integration.projectStructure.get(target.target._id)
|
||||
|
||||
@@ -372,7 +372,8 @@ export abstract class IssueSyncManagerBase {
|
||||
!areEqualMarkups(update.description, syncData.current?.description ?? '')
|
||||
) {
|
||||
try {
|
||||
await this.collaborator.updateContent(doc.description, { description: update.description })
|
||||
const collabId = makeDocCollabId(doc, 'description')
|
||||
await this.collaborator.updateMarkup(collabId, update.description)
|
||||
} catch (err: any) {
|
||||
Analytics.handleError(err)
|
||||
this.ctx.error(err)
|
||||
@@ -772,7 +773,7 @@ export abstract class IssueSyncManagerBase {
|
||||
}
|
||||
|
||||
if (update.description !== undefined) {
|
||||
if (areEqualMarkups(update.description, existingIssue.description)) {
|
||||
if (update.description === existingIssue.description) {
|
||||
delete update.description
|
||||
}
|
||||
}
|
||||
@@ -924,8 +925,10 @@ export abstract class IssueSyncManagerBase {
|
||||
workspace: this.provider.getWorkspaceId().name
|
||||
})
|
||||
try {
|
||||
issueData.description = update.description
|
||||
await this.collaborator.updateContent(existingIssue.description, { description: update.description })
|
||||
const description = update.description as Markup
|
||||
issueData.description = description
|
||||
const collabId = makeDocCollabId(existingIssue, 'description')
|
||||
await this.collaborator.updateMarkup(collabId, description)
|
||||
} catch (err: any) {
|
||||
Analytics.handleError(err)
|
||||
this.ctx.error('error during description update', err)
|
||||
|
||||
@@ -19,7 +19,9 @@ import core, {
|
||||
TxOperations,
|
||||
cutObjectArray,
|
||||
generateId,
|
||||
makeCollaborativeDoc
|
||||
makeDocCollabId,
|
||||
makeCollabJsonId,
|
||||
makeCollabId
|
||||
} from '@hcengineering/core'
|
||||
import github, {
|
||||
DocSyncInfo,
|
||||
@@ -239,7 +241,7 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
case 'assigned':
|
||||
case 'unassigned': {
|
||||
const assignees = await this.getAssigneesI(event.issue)
|
||||
const update: DocumentUpdate<Issue> = {
|
||||
const update: IssueUpdate = {
|
||||
assignee: assignees?.[0]?.person ?? null
|
||||
}
|
||||
await this.handleUpdate(externalData as IssueExternalData, derivedClient, update, account, prj, false)
|
||||
@@ -255,7 +257,7 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
}
|
||||
const type = await this.provider.getTaskTypeOf(prj.type, tracker.class.Issue)
|
||||
const statuses = await this.provider.getStatuses(type?._id)
|
||||
const update: DocumentUpdate<Issue> = {
|
||||
const update: IssueUpdate = {
|
||||
status: (
|
||||
await guessStatus(
|
||||
{
|
||||
@@ -380,8 +382,8 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
}
|
||||
|
||||
const description = await this.ctx.withLog('query collaborative description', {}, async () => {
|
||||
const content = await this.collaborator.getContent((existing as Issue).description)
|
||||
return content.description ?? ''
|
||||
const collabId = makeDocCollabId(existing, 'description')
|
||||
return await this.collaborator.getMarkup(collabId, (existing as Issue).description)
|
||||
})
|
||||
|
||||
this.ctx.info('create github issue', {
|
||||
@@ -624,8 +626,8 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
'query collaborative description',
|
||||
{},
|
||||
async () => {
|
||||
const content = await this.collaborator.getContent((existing as Issue).description)
|
||||
return content.description ?? ''
|
||||
const collabId = makeDocCollabId(existing, 'description')
|
||||
return await this.collaborator.getMarkup(collabId, (existing as Issue).description)
|
||||
},
|
||||
{ url: issueExternal.url }
|
||||
)
|
||||
@@ -908,9 +910,12 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
|
||||
const { description, ...update } = issueData
|
||||
|
||||
const collabId = makeCollabId(tracker.class.Issue, issueId, 'description')
|
||||
const contentId = makeCollabJsonId(collabId)
|
||||
|
||||
const value: AttachedData<Issue> = {
|
||||
...update,
|
||||
description: makeCollaborativeDoc(issueId, 'description'),
|
||||
description: contentId,
|
||||
kind: taskType,
|
||||
component: null,
|
||||
milestone: null,
|
||||
@@ -930,7 +935,7 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
identifier: `${prj.identifier}-${number}`
|
||||
}
|
||||
|
||||
await this.collaborator.updateContent(value.description, { description })
|
||||
await this.collaborator.updateMarkup(collabId, description)
|
||||
|
||||
await this.client.addCollection(
|
||||
tracker.class.Issue,
|
||||
|
||||
@@ -15,7 +15,8 @@ import core, {
|
||||
WithLookup,
|
||||
cutObjectArray,
|
||||
generateId,
|
||||
makeCollaborativeDoc
|
||||
makeCollabId,
|
||||
makeDocCollabId
|
||||
} from '@hcengineering/core'
|
||||
import github, {
|
||||
DocSyncInfo,
|
||||
@@ -217,12 +218,12 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
break
|
||||
}
|
||||
case 'review_requested': {
|
||||
const update: DocumentUpdate<GithubPullRequest> = {}
|
||||
const update: GithubPullRequestUpdate = {}
|
||||
await this.handleUpdate(externalData, derivedClient, update, account, prj, true)
|
||||
break
|
||||
}
|
||||
case 'review_request_removed': {
|
||||
const update: DocumentUpdate<GithubPullRequest> = {}
|
||||
const update: GithubPullRequestUpdate = {}
|
||||
await this.handleUpdate(externalData, derivedClient, update, account, prj, true)
|
||||
break
|
||||
}
|
||||
@@ -234,7 +235,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
case 'assigned':
|
||||
case 'unassigned': {
|
||||
const assignees = await this.getAssignees(externalData)
|
||||
const update: DocumentUpdate<GithubPullRequest> = {
|
||||
const update: GithubPullRequestUpdate = {
|
||||
assignee: assignees?.[0]?.person ?? null
|
||||
}
|
||||
await this.handleUpdate(externalData, derivedClient, update, account, prj, true)
|
||||
@@ -247,7 +248,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
|
||||
const isMerged = event.pull_request?.merged_at !== null
|
||||
|
||||
const update: DocumentUpdate<GithubPullRequest> = {
|
||||
const update: GithubPullRequestUpdate = {
|
||||
draft: externalData.isDraft,
|
||||
head: externalData.headRef,
|
||||
base: externalData.baseRef,
|
||||
@@ -594,8 +595,8 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
'query collaborative pull request description',
|
||||
{},
|
||||
async () => {
|
||||
const content = await this.collaborator.getContent((existing as any).description)
|
||||
return content.description
|
||||
const collabId = makeDocCollabId(existing, 'description')
|
||||
return await this.collaborator.getMarkup(collabId, (existing as GithubPullRequest).description)
|
||||
},
|
||||
{ url: pullRequestExternal.url }
|
||||
)
|
||||
@@ -998,7 +999,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
|
||||
async performIssueFieldsUpdate (
|
||||
info: DocSyncInfo,
|
||||
existing: Issue,
|
||||
existing: WithMarkup<Issue>,
|
||||
platformUpdate: DocumentUpdate<Issue>,
|
||||
issueData: Pick<WithMarkup<Issue>, 'title' | 'description' | 'assignee' | 'status' | 'remainingTime' | 'component'>,
|
||||
container: ContainerFocus,
|
||||
@@ -1180,7 +1181,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
const number = project.sequence
|
||||
const value: AttachedData<GithubPullRequest> = {
|
||||
...data,
|
||||
description: makeCollaborativeDoc(prId, 'description'),
|
||||
description: null,
|
||||
kind: taskType,
|
||||
component: null,
|
||||
milestone: null,
|
||||
@@ -1203,7 +1204,8 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
reviews: 0
|
||||
}
|
||||
|
||||
await this.collaborator.updateContent(value.description, { description })
|
||||
const collabId = makeCollabId(github.class.GithubPullRequest, prId, 'description')
|
||||
await this.collaborator.updateMarkup(collabId, description)
|
||||
|
||||
await client.addCollection(
|
||||
github.class.GithubPullRequest,
|
||||
|
||||
Reference in New Issue
Block a user