feat: Import improvements (#3064)
* feat: Split and simplify import/export pages in prep for more options * minor fixes * File operations for imports * test * icons
This commit is contained in:
@@ -5,9 +5,9 @@ import File from "formidable/lib/file";
|
||||
import invariant from "invariant";
|
||||
import { values, keys } from "lodash";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { parseOutlineExport } from "@shared/utils/zip";
|
||||
import Logger from "@server/logging/logger";
|
||||
import { Attachment, Event, Document, Collection, User } from "@server/models";
|
||||
import { parseOutlineExport, Item } from "@server/utils/zip";
|
||||
import { FileImportError } from "../errors";
|
||||
import attachmentCreator from "./attachmentCreator";
|
||||
import documentCreator from "./documentCreator";
|
||||
@@ -30,10 +30,10 @@ export default async function collectionImporter({
|
||||
}) {
|
||||
// load the zip structure into memory
|
||||
const zipData = await fs.promises.readFile(file.path);
|
||||
let items;
|
||||
let items: Item[];
|
||||
|
||||
try {
|
||||
items = await await parseOutlineExport(zipData);
|
||||
items = await parseOutlineExport(zipData);
|
||||
} catch (err) {
|
||||
throw FileImportError(err.message);
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ import { sequelize } from "@server/database/sequelize";
|
||||
import { FileOperation, Event, User } from "@server/models";
|
||||
|
||||
export default async function fileOperationDeleter(
|
||||
fileOp: FileOperation,
|
||||
fileOperation: FileOperation,
|
||||
user: User,
|
||||
ip: string
|
||||
) {
|
||||
const transaction = await sequelize.transaction();
|
||||
|
||||
try {
|
||||
await fileOp.destroy({
|
||||
await fileOperation.destroy({
|
||||
transaction,
|
||||
});
|
||||
await Event.create(
|
||||
@@ -17,8 +17,7 @@ export default async function fileOperationDeleter(
|
||||
name: "fileOperations.delete",
|
||||
teamId: user.teamId,
|
||||
actorId: user.id,
|
||||
// @ts-expect-error dataValues does exist
|
||||
data: fileOp.dataValues,
|
||||
modelId: fileOperation.id,
|
||||
ip,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user