From b4cdfc43cfc05b9f1e20038daf507bf5924b0714 Mon Sep 17 00:00:00 2001 From: Ersun Warncke Date: Tue, 11 Feb 2020 09:19:47 -0400 Subject: [PATCH] Revert "Revert "Revert "format fix""" This reverts commit abb3f94c50b94cd87012d9e55c40afd9cbfe97e0. GitOrigin-RevId: 090e01b96222024341e3c988ec3ba4c9fa1eef11 --- .../src/Features/Compile/CompileController.js | 48 ++++++++---------- .../ProjectEntityMongoUpdateHandler.js | 13 +---- .../acceptance/src/ProjectStructureTests.js | 49 ++++++++----------- 3 files changed, 44 insertions(+), 66 deletions(-) diff --git a/services/web/app/src/Features/Compile/CompileController.js b/services/web/app/src/Features/Compile/CompileController.js index ea48c74413..8dd873521a 100644 --- a/services/web/app/src/Features/Compile/CompileController.js +++ b/services/web/app/src/Features/Compile/CompileController.js @@ -44,10 +44,7 @@ module.exports = CompileController = { if (req.body.rootDoc_id) { options.rootDoc_id = req.body.rootDoc_id - } else if ( - req.body.settingsOverride && - req.body.settingsOverride.rootDoc_id - ) { + } else if (req.body.settingsOverride && req.body.settingsOverride.rootDoc_id) { // Can be removed after deploy options.rootDoc_id = req.body.settingsOverride.rootDoc_id } @@ -57,38 +54,35 @@ module.exports = CompileController = { if (req.body.draft) { options.draft = req.body.draft } - if (['validate', 'error', 'silent'].includes(req.body.check)) { + if ( + ['validate', 'error', 'silent'].includes(req.body.check) + ) { options.check = req.body.check } if (req.body.incrementalCompilesEnabled) { options.incrementalCompilesEnabled = true } - CompileManager.compile( - project_id, - user_id, - options, - ( - error, + CompileManager.compile(project_id, user_id, options, ( + error, + status, + outputFiles, + clsiServerId, + limits, + validationProblems + ) => { + if (error) { + return next(error) + } + res.json({ status, outputFiles, + compileGroup: limits != null ? limits.compileGroup : undefined, clsiServerId, - limits, - validationProblems - ) => { - if (error) { - return next(error) - } - res.json({ - status, - outputFiles, - compileGroup: limits != null ? limits.compileGroup : undefined, - clsiServerId, - validationProblems, - pdfDownloadDomain: Settings.pdfDownloadDomain - }) - } - ) + validationProblems, + pdfDownloadDomain: Settings.pdfDownloadDomain + }) + }) }, stopCompile(req, res, next) { diff --git a/services/web/app/src/Features/Project/ProjectEntityMongoUpdateHandler.js b/services/web/app/src/Features/Project/ProjectEntityMongoUpdateHandler.js index 43629574ae..221b4bc0e3 100644 --- a/services/web/app/src/Features/Project/ProjectEntityMongoUpdateHandler.js +++ b/services/web/app/src/Features/Project/ProjectEntityMongoUpdateHandler.js @@ -316,10 +316,7 @@ async function deleteEntity(projectId, entityId, entityType, callback) { projectId, { name: true, rootFolder: true, overleaf: true, rootDoc_id: true } ) - const deleteRootDoc = - project.rootDoc_id && - entityId && - project.rootDoc_id.toString() === entityId.toString() + const deleteRootDoc = project.rootDoc_id && entityId && project.rootDoc_id.toString() === entityId.toString() const { element: entity, path } = await ProjectLocator.promises.findElement({ project, element_id: entityId, @@ -419,13 +416,7 @@ async function _insertDeletedFileReference(projectId, fileRef) { ).exec() } -async function _removeElementFromMongoArray( - model, - modelId, - path, - elementId, - deleteRootDoc = false -) { +async function _removeElementFromMongoArray(model, modelId, path, elementId, deleteRootDoc=false) { const nonArrayPath = path.slice(0, path.lastIndexOf('.')) const options = { new: true } const query = { _id: modelId } diff --git a/services/web/test/acceptance/src/ProjectStructureTests.js b/services/web/test/acceptance/src/ProjectStructureTests.js index 8a392d36f2..69eea73d23 100644 --- a/services/web/test/acceptance/src/ProjectStructureTests.js +++ b/services/web/test/acceptance/src/ProjectStructureTests.js @@ -1113,55 +1113,48 @@ describe('ProjectStructureChanges', function() { } this.project0 = project done() - } - ) + }) }) }) }) }) - describe('when rootDoc_id matches doc being deleted', function() { + describe('when rootDoc_id matches doc being deleted', () => { beforeEach(function(done) { - Project.update( - { _id: this.exampleProjectId }, - { $set: { rootDoc_id: this.exampleDocId } }, - done - ) + Project.update({_id: this.exampleProjectId}, {$set: {rootDoc_id: this.exampleDocId}}, done) }) it('should clear rootDoc_id', function(done) { deleteItem(this, 'doc', this.exampleDocId, () => { - ProjectGetter.getProject(this.exampleProjectId, (error, project) => { - if (error) { - throw error - } - expect(project.rootDoc_id).to.be.undefined - done() + ProjectGetter.getProject( + this.exampleProjectId, + (error, project) => { + if (error) { + throw error + } + expect(project.rootDoc_id).to.be.undefined + done() }) }) }) }) - describe('when rootDoc_id does not match doc being deleted', function() { + describe('when rootDoc_id does not match doc being deleted', () => { beforeEach(function(done) { this.exampleRootDocId = new ObjectId() - Project.update( - { _id: this.exampleProjectId }, - { $set: { rootDoc_id: this.exampleRootDocId } }, - done - ) + Project.update({_id: this.exampleProjectId}, {$set: {rootDoc_id: this.exampleRootDocId}}, done) }) it('should not clear rootDoc_id', function(done) { deleteItem(this, 'doc', this.exampleDocId, () => { - ProjectGetter.getProject(this.exampleProjectId, (error, project) => { - if (error) { - throw error - } - expect(project.rootDoc_id.toString()).to.equal( - this.exampleRootDocId.toString() - ) - done() + ProjectGetter.getProject( + this.exampleProjectId, + (error, project) => { + if (error) { + throw error + } + expect(project.rootDoc_id.toString()).to.equal(this.exampleRootDocId.toString()) + done() }) }) })