mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-20 17:55:55 +00:00
Only show rename or deleted message once
This commit is contained in:
parent
bc94ea56cb
commit
4743b460f5
5 changed files with 49 additions and 3 deletions
|
@ -58,6 +58,10 @@ module.exports = EditorController =
|
|||
|
||||
# can be done affter the connection has happened
|
||||
ConnectedUsersManager.updateUserPosition project_id, client.id, user, null, ->
|
||||
|
||||
# Only show the 'renamed or deleted' message once
|
||||
ProjectDeleter.unmarkAsDeletedByExternalSource project
|
||||
|
||||
|
||||
leaveProject: (client, user) ->
|
||||
self = @
|
||||
|
|
|
@ -7,7 +7,7 @@ FileStoreHandler = require("../FileStore/FileStoreHandler")
|
|||
|
||||
module.exports = ProjectDeleter =
|
||||
|
||||
markAsDeletedByExternalSource : (project_id, callback)->
|
||||
markAsDeletedByExternalSource : (project_id, callback = (error) ->)->
|
||||
logger.log project_id:project_id, "marking project as deleted by external data source"
|
||||
conditions = {_id:project_id}
|
||||
update = {deletedByExternalDataSource:true}
|
||||
|
@ -15,6 +15,15 @@ module.exports = ProjectDeleter =
|
|||
Project.update conditions, update, {}, (err)->
|
||||
require('../Editor/EditorController').notifyUsersProjectHasBeenDeletedOrRenamed project_id, ->
|
||||
callback()
|
||||
|
||||
unmarkAsDeletedByExternalSource: (project, callback = (error) ->) ->
|
||||
logger.log project_id: "removing flag marking project as deleted by external data source"
|
||||
if project.deletedByExternalDataSource
|
||||
conditions = {_id:project._id.toString()}
|
||||
update = {deletedByExternalDataSource: false}
|
||||
Project.update conditions, update, {}, callback
|
||||
else
|
||||
callback()
|
||||
|
||||
deleteUsersProjects: (owner_id, callback)->
|
||||
logger.log owner_id:owner_id, "deleting users projects"
|
||||
|
|
|
@ -89,6 +89,7 @@ describe "EditorController", ->
|
|||
@AuthorizationManager.setPrivilegeLevelOnClient = sinon.stub()
|
||||
@EditorRealTimeController.emitToRoom = sinon.stub()
|
||||
@ConnectedUsersManager.updateUserPosition.callsArgWith(4)
|
||||
@ProjectDeleter.unmarkAsDeletedByExternalSource = sinon.stub()
|
||||
|
||||
describe "when authorized", ->
|
||||
beforeEach ->
|
||||
|
@ -122,8 +123,12 @@ describe "EditorController", ->
|
|||
|
||||
it "should mark the user as connected with the ConnectedUsersManager", ->
|
||||
@ConnectedUsersManager.updateUserPosition.calledWith(@project_id, @client.id, @user, null).should.equal true
|
||||
|
||||
|
||||
|
||||
it "should remove the flag to send a user a message about the project being deleted", ->
|
||||
@ProjectDeleter.unmarkAsDeletedByExternalSource
|
||||
.calledWith(@project)
|
||||
.should.equal true
|
||||
|
||||
describe "when not authorized", ->
|
||||
beforeEach ->
|
||||
@AuthorizationManager.getPrivilegeLevelForProject =
|
||||
|
|
|
@ -281,6 +281,7 @@ describe "ProjectController", ->
|
|||
@UserModel.findById.callsArgWith(1, null, @user)
|
||||
@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, {})
|
||||
@SecurityManager.userCanAccessProject.callsArgWith 2, true, "owner"
|
||||
@ProjectDeleter.unmarkAsDeletedByExternalSource = sinon.stub()
|
||||
|
||||
it "should render the project/editor page", (done)->
|
||||
@res.render = (pageName, opts)=>
|
||||
|
|
|
@ -30,6 +30,7 @@ describe 'Project deleter', ->
|
|||
'../../models/Project':{Project:@Project}
|
||||
'../DocumentUpdater/DocumentUpdaterHandler': @documentUpdaterHandler
|
||||
"../Tags/TagsHandler":@TagsHandler
|
||||
"../FileStore/FileStoreHandler": @FileStoreHandler = {}
|
||||
'logger-sharelatex':
|
||||
log:->
|
||||
|
||||
|
@ -46,6 +47,32 @@ describe 'Project deleter', ->
|
|||
@deleter.markAsDeletedByExternalSource project_id, =>
|
||||
@editorController.notifyUsersProjectHasBeenDeletedOrRenamed.calledWith(project_id).should.equal true
|
||||
done()
|
||||
|
||||
describe "unmarkAsDeletedByExternalSource", ->
|
||||
beforeEach ->
|
||||
@Project.update = sinon.stub().callsArg(3)
|
||||
@callback = sinon.stub()
|
||||
@project = {
|
||||
_id: @project_id
|
||||
}
|
||||
|
||||
describe "when the project does not have the flag set", ->
|
||||
beforeEach ->
|
||||
@project.deletedByExternalDataSource = false
|
||||
@deleter.unmarkAsDeletedByExternalSource @project, @callback
|
||||
|
||||
it "should not update the project", ->
|
||||
@Project.update.called.should.equal false
|
||||
|
||||
describe "when the project does have the flag set", ->
|
||||
beforeEach ->
|
||||
@project.deletedByExternalDataSource = true
|
||||
@deleter.unmarkAsDeletedByExternalSource @project, @callback
|
||||
|
||||
it "should remove the flag from the project", ->
|
||||
@Project.update
|
||||
.calledWith({_id: @project_id}, {deletedByExternalDataSource:false})
|
||||
.should.equal true
|
||||
|
||||
describe "deleteUsersProjects", ->
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue