Browse Source

Merge branch 'master' into ja-fix-cursor-on-resize

James Allen 9 years ago
parent
commit
c1a2779d9e

+ 5 - 1
services/web/app/coffee/Features/PasswordReset/PasswordResetController.coffee

@@ -53,7 +53,11 @@ module.exports =
 					if req.body.login_after
 						UserGetter.getUser user_id, {email: 1}, (err, user) ->
 							return next(err) if err?
-							AuthenticationController.doLogin {email:user.email, password: password}, req, res, next
+							AuthenticationController.afterLoginSessionSetup req, user, (err) ->
+								if err?
+									logger.err {err, email: user.email}, "Error setting up session after setting password"
+									return next(err)
+								res.json {redir: AuthenticationController._getRedirectFromSession(req) || "/project"}
 					else
 						res.sendStatus 200
 			else

+ 6 - 5
services/web/public/coffee/directives/expandableTextArea.coffee

@@ -5,12 +5,13 @@ define [
 		restrict: "A"
 		link: (scope, el) ->
 			resetHeight = () ->
-				el.css("height", "auto")
-				el.css("height", el.prop("scrollHeight"))
+				curHeight = el.outerHeight()
+				fitHeight = el.prop("scrollHeight")
+				
+				if fitHeight > curHeight and el.val() != ""
+					scope.$emit "expandable-text-area:resize"
+					el.css("height", fitHeight) 
 
 			scope.$watch (() -> el.val()), resetHeight
 
-			resetHeight()
-
-
 	

+ 3 - 0
services/web/public/coffee/ide/editor/directives/aceEditor/cursor-position/CursorPositionManager.coffee

@@ -37,6 +37,9 @@ define [
 						@gotoOffset(offset)
 					, 10 # Hack: Must happen after @gotoStoredPosition
 
+			@$scope.$on "#{@$scope.name}:clearSelection", (e) =>
+				@editor.selection.clearSelection()
+
 		storeScrollTopPosition: (session) ->
 			if @doc_id?
 				docPosition = @localStorage("doc.position.#{@doc_id}") || {}

+ 5 - 0
services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee

@@ -33,6 +33,10 @@ define [
 		$scope.$on "layout:pdf:resize", (event, state) ->
 			$scope.reviewPanel.layoutToLeft = (state.east?.size < 220 || state.east?.initClosed)
 
+		$scope.$on "expandable-text-area:resize", (event) ->
+			$timeout () ->
+				$scope.$broadcast "review-panel:layout"
+
 		$scope.$watch "ui.pdfLayout", (layout) ->
 			$scope.reviewPanel.layoutToLeft = (layout == "flat")
 
@@ -306,6 +310,7 @@ define [
 			$http.post("/project/#{$scope.project_id}/thread/#{thread_id}/messages", {content, _csrf: window.csrfToken})
 				.error (error) ->
 					ide.showGenericMessageModal("Error submitting comment", "Sorry, there was a problem submitting your comment")
+			$scope.$broadcast "editor:clearSelection"
 			$timeout () ->
 				$scope.$broadcast "review-panel:layout"
 			event_tracking.sendMB "rp-new-comment", { size: content.length }

BIN
services/web/public/img/about/joe_green.jpg


+ 2 - 0
services/web/public/stylesheets/app/editor/review-panel.less

@@ -451,6 +451,8 @@
 		resize: vertical;
 		color: @rp-type-darkgrey;
 		margin-top: 3px;
+		overflow-x: hidden;
+		min-height: 3em;
 	}
 
 .rp-icon-delete {

+ 20 - 11
services/web/test/UnitTests/coffee/PasswordReset/PasswordResetControllerTests.coffee

@@ -145,18 +145,27 @@ describe "PasswordResetController", ->
 				done()
 			@PasswordResetController.setNewUserPassword @req, @res
 
-		it "should login user if login_after is set", (done) ->
-			@UserGetter.getUser = sinon.stub().callsArgWith(2, null, { email: "joe@example.com" })
-			@PasswordResetHandler.setNewUserPassword.callsArgWith(2, null, true, @user_id = "user-id-123")
-			@req.body.login_after = "true"
-			@AuthenticationController.doLogin = (options, req, res, next)=>
-				@UserGetter.getUser.calledWith(@user_id).should.equal true
-				expect(options).to.deep.equal {
-					email: "joe@example.com",
-					password: @password
-				}
+		describe 'when login_after is set', ->
+
+			beforeEach ->
+				@UserGetter.getUser = sinon.stub().callsArgWith(2, null, { email: "joe@example.com" })
+				@PasswordResetHandler.setNewUserPassword.callsArgWith(2, null, true, @user_id = "user-id-123")
+				@req.body.login_after = "true"
+				@res.json = sinon.stub()
+				@AuthenticationController.afterLoginSessionSetup = sinon.stub().callsArgWith(2, null)
+				@AuthenticationController._getRedirectFromSession = sinon.stub().returns('/some/path')
+
+			it "should login user if login_after is set", (done) ->
+				@PasswordResetController.setNewUserPassword @req, @res
+				@AuthenticationController.afterLoginSessionSetup.callCount.should.equal 1
+				@AuthenticationController.afterLoginSessionSetup.calledWith(
+					@req,
+					{email: 'joe@example.com'}
+				).should.equal true
+				@AuthenticationController._getRedirectFromSession.callCount.should.equal 1
+				@res.json.callCount.should.equal 1
+				@res.json.calledWith({redir: '/some/path'}).should.equal true
 				done()
-			@PasswordResetController.setNewUserPassword @req, @res
 
 	describe "renderSetPasswordForm", ->