Просмотр исходного кода

Merge pull request #2378 from overleaf/bg-return-history-display-type-to-docupdater

return history display type to docupdater

GitOrigin-RevId: bc90317677937c4f0698c2045958b79820ec3b3f
Brian Gough 6 лет назад
Родитель
Сommit
fb0f8ec65f

+ 9 - 7
services/web/app/src/Features/Documents/DocumentController.js

@@ -17,6 +17,7 @@ const ProjectLocator = require('../Project/ProjectLocator')
 const ProjectEntityHandler = require('../Project/ProjectEntityHandler')
 const ProjectEntityHandler = require('../Project/ProjectEntityHandler')
 const ProjectEntityUpdateHandler = require('../Project/ProjectEntityUpdateHandler')
 const ProjectEntityUpdateHandler = require('../Project/ProjectEntityUpdateHandler')
 const logger = require('logger-sharelatex')
 const logger = require('logger-sharelatex')
+const _ = require('lodash')
 
 
 module.exports = {
 module.exports = {
   getDocument(req, res, next) {
   getDocument(req, res, next) {
@@ -69,19 +70,20 @@ module.exports = {
                 res.type('text/plain')
                 res.type('text/plain')
                 return res.send(lines.join('\n'))
                 return res.send(lines.join('\n'))
               } else {
               } else {
-                const projectHistoryId = __guard__(
-                  __guard__(
-                    project != null ? project.overleaf : undefined,
-                    x2 => x2.history
-                  ),
-                  x1 => x1.id
+                const projectHistoryId = _.get(project, 'overleaf.history.id')
+                const projectHistoryType = _.get(
+                  project,
+                  'overleaf.history.display'
                 )
                 )
+                  ? 'project-history'
+                  : undefined // for backwards compatibility, don't send anything if the project is still on track-changes
                 return res.json({
                 return res.json({
                   lines,
                   lines,
                   version,
                   version,
                   ranges,
                   ranges,
                   pathname: path.fileSystem,
                   pathname: path.fileSystem,
-                  projectHistoryId
+                  projectHistoryId,
+                  projectHistoryType
                 })
                 })
               }
               }
             })
             })

+ 11 - 3
services/web/test/unit/src/Documents/DocumentControllerTests.js

@@ -153,9 +153,16 @@ describe('DocumentController', function() {
       beforeEach(function() {
       beforeEach(function() {
         this.doc = { _id: this.doc_id }
         this.doc = { _id: this.doc_id }
         this.projectHistoryId = 1234
         this.projectHistoryId = 1234
+        this.projectHistoryDisplay = true
+        this.projectHistoryType = 'project-history'
         this.project = {
         this.project = {
           _id: this.project_id,
           _id: this.project_id,
-          overleaf: { history: { id: this.projectHistoryId } }
+          overleaf: {
+            history: {
+              id: this.projectHistoryId,
+              display: this.projectHistoryDisplay
+            }
+          }
         }
         }
         this.ProjectGetter.getProject = sinon
         this.ProjectGetter.getProject = sinon
           .stub()
           .stub()
@@ -180,7 +187,7 @@ describe('DocumentController', function() {
         )
         )
       })
       })
 
 
-      it('should return the history id to the client as JSON', function() {
+      it('should return the history id and display setting to the client as JSON', function() {
         this.res.type.should.equal('application/json')
         this.res.type.should.equal('application/json')
         return this.res.body.should.equal(
         return this.res.body.should.equal(
           JSON.stringify({
           JSON.stringify({
@@ -188,7 +195,8 @@ describe('DocumentController', function() {
             version: this.version,
             version: this.version,
             ranges: this.ranges,
             ranges: this.ranges,
             pathname: this.pathname,
             pathname: this.pathname,
-            projectHistoryId: this.projectHistoryId
+            projectHistoryId: this.projectHistoryId,
+            projectHistoryType: this.projectHistoryType
           })
           })
         )
         )
       })
       })