Răsfoiți Sursa

Merge branch 'ja-include-track-changes-feature' into pr-track-changes-upgrade-prompt

James Allen 9 ani în urmă
părinte
comite
47a66eed50

+ 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

+ 1 - 1
services/web/app/views/translations/translation_message.pug

@@ -2,7 +2,7 @@
 	span(ng-controller="TranslationsPopupController", ng-cloak)
 		.translations-message(ng-hide="hidei18nNotification")
 			a(href=recomendSubdomain.url+currentUrl) !{translate("click_here_to_view_sl_in_lng", {lngName:"<strong>" + translate(recomendSubdomain.lngCode) + "</strong>"})} 
-				img(src=buildImgPath("flags/24/#{recomendSubdomain.lngCode}.png"))
+				img(src=buildImgPath("flags/24/" + recomendSubdomain.lngCode + ".png"))
 			button(ng-click="dismiss()").close.pull-right
 				span(aria-hidden="true") &times;
 				span.sr-only #{translate("close")}

+ 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()
-
-
 	

+ 12 - 0
services/web/public/coffee/ide/editor/directives/aceEditor.coffee

@@ -167,10 +167,22 @@ define [
 					if arg == "/"
 						ace.require("ace/ext/searchbox").Search(editor, true)
 
+				getCursorScreenPosition = () ->
+					session = editor.getSession()
+					cursorPosition = session.selection.getCursor()
+					sessionPos = session.documentToScreenPosition(cursorPosition.row, cursorPosition.column)
+					screenPos = editor.renderer.textToScreenCoordinates(sessionPos.row, sessionPos.column)
+					return sessionPos.row * editor.renderer.lineHeight - session.getScrollTop()
+
 				if attrs.resizeOn?
 					for event in attrs.resizeOn.split(",")
 						scope.$on event, () ->
+							previousScreenPosition = getCursorScreenPosition()
 							editor.resize()
+							# Put cursor back to same vertical position on screen
+							newScreenPosition = getCursorScreenPosition()
+							session = editor.getSession()
+							session.setScrollTop(session.getScrollTop() + newScreenPosition - previousScreenPosition)
 
 				scope.$watch "theme", (value) ->
 					editor.setTheme("ace/theme/#{value}")

+ 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}") || {}

+ 4 - 1
services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/HighlightedWordManager.coffee

@@ -12,6 +12,9 @@ define [
 
 	class HighlightedWordManager
 		constructor: (@editor) ->
+			@reset()
+		
+		reset: () ->
 			@highlights = rows: []
 
 		addHighlight: (highlight) ->
@@ -21,7 +24,7 @@ define [
 				highlight.row, highlight.column,
 				highlight.row, highlight.column + highlight.word.length
 			)
-			highlight.markerId = @editor.getSession().addMarker range, "spelling-highlight", null, true
+			highlight.markerId = @editor.getSession().addMarker range, "spelling-highlight", 'text', false
 			@highlights.rows[highlight.row] ||= []
 			@highlights.rows[highlight.row].push highlight
 

+ 7 - 2
services/web/public/coffee/ide/editor/directives/aceEditor/spell-check/SpellCheckManager.coffee

@@ -22,6 +22,10 @@ define [
 				@closeContextMenu()
 
 			@editor.on "changeSession", (e) =>
+				@highlightedWordManager.reset()
+				if @inProgressRequest?
+					@inProgressRequest.abort()
+
 				if @$scope.spellCheckEnabled and @$scope.spellCheckLanguage and @$scope.spellCheckLanguage != ""
 					@runSpellCheckSoon(200)
 
@@ -183,7 +187,8 @@ define [
 			if not words.length
 				displayResult highlights
 			else
-				@apiRequest "/check", {language: language, words: words}, (error, result) =>
+				@inProgressRequest = @apiRequest "/check", {language: language, words: words}, (error, result) =>
+					delete @inProgressRequest
 					if error? or !result? or !result.misspellings?
 						return null
 					mispelled = []
@@ -240,4 +245,4 @@ define [
 					callback null, data
 				error: (xhr, status, error) ->
 					callback error
-			$.ajax options
+			return $.ajax options

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

@@ -29,9 +29,15 @@ define [
 
 		$scope.$on "layout:pdf:linked", (event, state) ->
 			$scope.reviewPanel.layoutToLeft = (state.east?.size < 220 || state.east?.initClosed)
+			$scope.$broadcast "review-panel:layout"
 
 		$scope.$on "layout:pdf:resize", (event, state) ->
 			$scope.reviewPanel.layoutToLeft = (state.east?.size < 220 || state.east?.initClosed)
+			$scope.$broadcast "review-panel:layout"
+
+		$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 +312,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", ->