mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05: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
|
@ -59,6 +59,10 @@ module.exports = EditorController =
|
||||||
# can be done affter the connection has happened
|
# can be done affter the connection has happened
|
||||||
ConnectedUsersManager.updateUserPosition project_id, client.id, user, null, ->
|
ConnectedUsersManager.updateUserPosition project_id, client.id, user, null, ->
|
||||||
|
|
||||||
|
# Only show the 'renamed or deleted' message once
|
||||||
|
ProjectDeleter.unmarkAsDeletedByExternalSource project
|
||||||
|
|
||||||
|
|
||||||
leaveProject: (client, user) ->
|
leaveProject: (client, user) ->
|
||||||
self = @
|
self = @
|
||||||
client.get "project_id", (error, project_id) ->
|
client.get "project_id", (error, project_id) ->
|
||||||
|
|
|
@ -7,7 +7,7 @@ FileStoreHandler = require("../FileStore/FileStoreHandler")
|
||||||
|
|
||||||
module.exports = ProjectDeleter =
|
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"
|
logger.log project_id:project_id, "marking project as deleted by external data source"
|
||||||
conditions = {_id:project_id}
|
conditions = {_id:project_id}
|
||||||
update = {deletedByExternalDataSource:true}
|
update = {deletedByExternalDataSource:true}
|
||||||
|
@ -16,6 +16,15 @@ module.exports = ProjectDeleter =
|
||||||
require('../Editor/EditorController').notifyUsersProjectHasBeenDeletedOrRenamed project_id, ->
|
require('../Editor/EditorController').notifyUsersProjectHasBeenDeletedOrRenamed project_id, ->
|
||||||
callback()
|
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)->
|
deleteUsersProjects: (owner_id, callback)->
|
||||||
logger.log owner_id:owner_id, "deleting users projects"
|
logger.log owner_id:owner_id, "deleting users projects"
|
||||||
Project.remove owner_ref:owner_id, callback
|
Project.remove owner_ref:owner_id, callback
|
||||||
|
|
|
@ -89,6 +89,7 @@ describe "EditorController", ->
|
||||||
@AuthorizationManager.setPrivilegeLevelOnClient = sinon.stub()
|
@AuthorizationManager.setPrivilegeLevelOnClient = sinon.stub()
|
||||||
@EditorRealTimeController.emitToRoom = sinon.stub()
|
@EditorRealTimeController.emitToRoom = sinon.stub()
|
||||||
@ConnectedUsersManager.updateUserPosition.callsArgWith(4)
|
@ConnectedUsersManager.updateUserPosition.callsArgWith(4)
|
||||||
|
@ProjectDeleter.unmarkAsDeletedByExternalSource = sinon.stub()
|
||||||
|
|
||||||
describe "when authorized", ->
|
describe "when authorized", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
@ -123,6 +124,10 @@ describe "EditorController", ->
|
||||||
it "should mark the user as connected with the ConnectedUsersManager", ->
|
it "should mark the user as connected with the ConnectedUsersManager", ->
|
||||||
@ConnectedUsersManager.updateUserPosition.calledWith(@project_id, @client.id, @user, null).should.equal true
|
@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", ->
|
describe "when not authorized", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
|
|
@ -281,6 +281,7 @@ describe "ProjectController", ->
|
||||||
@UserModel.findById.callsArgWith(1, null, @user)
|
@UserModel.findById.callsArgWith(1, null, @user)
|
||||||
@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, {})
|
@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, {})
|
||||||
@SecurityManager.userCanAccessProject.callsArgWith 2, true, "owner"
|
@SecurityManager.userCanAccessProject.callsArgWith 2, true, "owner"
|
||||||
|
@ProjectDeleter.unmarkAsDeletedByExternalSource = sinon.stub()
|
||||||
|
|
||||||
it "should render the project/editor page", (done)->
|
it "should render the project/editor page", (done)->
|
||||||
@res.render = (pageName, opts)=>
|
@res.render = (pageName, opts)=>
|
||||||
|
|
|
@ -30,6 +30,7 @@ describe 'Project deleter', ->
|
||||||
'../../models/Project':{Project:@Project}
|
'../../models/Project':{Project:@Project}
|
||||||
'../DocumentUpdater/DocumentUpdaterHandler': @documentUpdaterHandler
|
'../DocumentUpdater/DocumentUpdaterHandler': @documentUpdaterHandler
|
||||||
"../Tags/TagsHandler":@TagsHandler
|
"../Tags/TagsHandler":@TagsHandler
|
||||||
|
"../FileStore/FileStoreHandler": @FileStoreHandler = {}
|
||||||
'logger-sharelatex':
|
'logger-sharelatex':
|
||||||
log:->
|
log:->
|
||||||
|
|
||||||
|
@ -47,6 +48,32 @@ describe 'Project deleter', ->
|
||||||
@editorController.notifyUsersProjectHasBeenDeletedOrRenamed.calledWith(project_id).should.equal true
|
@editorController.notifyUsersProjectHasBeenDeletedOrRenamed.calledWith(project_id).should.equal true
|
||||||
done()
|
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", ->
|
describe "deleteUsersProjects", ->
|
||||||
|
|
||||||
it "should remove all the projects owned by the user_id", (done)->
|
it "should remove all the projects owned by the user_id", (done)->
|
||||||
|
|
Loading…
Reference in a new issue