mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-05 07:10:55 +00:00
moved moveEntity from collab manager to editor controller
This commit is contained in:
parent
88e47bbe12
commit
d684f04d4f
4 changed files with 27 additions and 8 deletions
|
@ -251,7 +251,11 @@ module.exports = EditorController =
|
|||
EditorRealTimeController.emitToRoom project_id, 'reciveEntityRename', entity_id, newName
|
||||
callback?()
|
||||
|
||||
|
||||
moveEntity: (project_id, entity_id, folder_id, entityType, callback)->
|
||||
Metrics.inc "editor.move-entity"
|
||||
ProjectEntityHandler.moveEntity project_id, entity_id, folder_id, entityType, =>
|
||||
EditorRealTimeController.emitToRoom project_id, 'reciveEntityMove', entity_id, folder_id
|
||||
callback?()
|
||||
|
||||
p:
|
||||
notifyProjectUsersOfNewFolder: (project_id, folder_id, folder, callback = (error)->)->
|
||||
|
|
|
@ -15,12 +15,6 @@ EditorRealTimeController = require('../Features/Editor/EditorRealTimeController'
|
|||
module.exports = class CollaberationManager
|
||||
constructor: (@io)->
|
||||
|
||||
moveEntity: (project_id, entity_id, folder_id, entityType, callback)->
|
||||
metrics.inc "editor.move-entity"
|
||||
projectEntityHandler.moveEntity project_id, entity_id, folder_id, entityType, =>
|
||||
EditorRealTimeController.emitToRoom project_id, 'reciveEntityMove', entity_id, folder_id
|
||||
callback?()
|
||||
|
||||
renameProject: (project_id, window_id, newName, callback)->
|
||||
newName = sanitize.escape(newName)
|
||||
projectHandler.renameProject project_id, window_id, newName, =>
|
||||
|
|
|
@ -295,7 +295,7 @@ module.exports = class Router
|
|||
|
||||
client.on 'moveEntity', (entity_id, folder_id, entityType, callback)->
|
||||
AuthorizationManager.ensureClientCanEditProject client, (error, project_id) =>
|
||||
collaberationManager.moveEntity(project_id, entity_id, folder_id, entityType, callback)
|
||||
EditorController.moveEntity(project_id, entity_id, folder_id, entityType, callback)
|
||||
|
||||
client.on 'setProjectName', (window_id, newName, callback)->
|
||||
AuthorizationManager.ensureClientCanEditProject client, (error, project_id) =>
|
||||
|
|
|
@ -643,3 +643,24 @@ describe "EditorController", ->
|
|||
@EditorRealTimeController.emitToRoom.calledWith(@project_id, 'reciveEntityRename', @entity_id, @newName).should.equal true
|
||||
done()
|
||||
|
||||
|
||||
describe "moveEntity", ->
|
||||
|
||||
beforeEach ->
|
||||
@err = "errro"
|
||||
@entity_id = "entity_id_here"
|
||||
@entityType = "doc"
|
||||
@folder_id = "313dasd21dasdsa"
|
||||
@ProjectEntityHandler.moveEntity = sinon.stub().callsArgWith(4, @err)
|
||||
@EditorRealTimeController.emitToRoom = sinon.stub()
|
||||
|
||||
it "should call the ProjectEntityHandler", (done)->
|
||||
@EditorController.moveEntity @project_id, @entity_id, @folder_id, @entityType, =>
|
||||
@ProjectEntityHandler.moveEntity.calledWith(@project_id, @entity_id, @folder_id, @entityType).should.equal true
|
||||
done()
|
||||
|
||||
|
||||
it "should emit the update to the room", (done)->
|
||||
@EditorController.moveEntity @project_id, @entity_id, @folder_id, @entityType, =>
|
||||
@EditorRealTimeController.emitToRoom.calledWith(@project_id, 'reciveEntityMove', @entity_id, @folder_id).should.equal true
|
||||
done()
|
||||
|
|
Loading…
Reference in a new issue