Move collection description rendering to JSON (#6944)
* First pass, moving collection description rendering to JSON * tsc * docs * refactor * test
This commit is contained in:
@@ -182,7 +182,7 @@ export default class WebsocketsProcessor {
|
||||
? `team-${collection.teamId}`
|
||||
: `user-${collection.createdById}`
|
||||
)
|
||||
.emit(event.name, presentCollection(collection));
|
||||
.emit(event.name, await presentCollection(undefined, collection));
|
||||
|
||||
return socketio
|
||||
.to(
|
||||
@@ -210,7 +210,7 @@ export default class WebsocketsProcessor {
|
||||
? `collection-${event.collectionId}`
|
||||
: `team-${collection.teamId}`
|
||||
)
|
||||
.emit(event.name, presentCollection(collection));
|
||||
.emit(event.name, await presentCollection(undefined, collection));
|
||||
}
|
||||
|
||||
case "collections.delete": {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import JSZip from "jszip";
|
||||
import omit from "lodash/omit";
|
||||
import { NavigationNode } from "@shared/types";
|
||||
import { parser } from "@server/editor";
|
||||
import env from "@server/env";
|
||||
import Logger from "@server/logging/Logger";
|
||||
import {
|
||||
@@ -63,10 +62,10 @@ export default class ExportJSONTask extends ExportTask {
|
||||
) {
|
||||
const output: CollectionJSONExport = {
|
||||
collection: {
|
||||
...omit(presentCollection(collection), ["url"]),
|
||||
description: collection.description
|
||||
? parser.parse(collection.description)
|
||||
: null,
|
||||
...omit(await presentCollection(undefined, collection), [
|
||||
"url",
|
||||
"description",
|
||||
]),
|
||||
documentStructure: collection.documentStructure,
|
||||
},
|
||||
documents: {},
|
||||
|
||||
@@ -129,15 +129,14 @@ export default class ImportJSONTask extends ImportTask {
|
||||
}
|
||||
|
||||
const collectionId = uuidv4();
|
||||
const data = item.collection.description ?? item.collection.data;
|
||||
|
||||
output.collections.push({
|
||||
...item.collection,
|
||||
description:
|
||||
item.collection.description &&
|
||||
typeof item.collection.description === "object"
|
||||
? serializer.serialize(
|
||||
Node.fromJSON(schema, item.collection.description)
|
||||
)
|
||||
: item.collection.description,
|
||||
data && typeof data === "object"
|
||||
? serializer.serialize(Node.fromJSON(schema, data))
|
||||
: data,
|
||||
id: collectionId,
|
||||
externalId: item.collection.id,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user