diff --git a/services/web/app/views/beta_program/opt_in.pug b/services/web/app/views/beta_program/opt_in.pug index f54766f30d..c740b894a6 100644 --- a/services/web/app/views/beta_program/opt_in.pug +++ b/services/web/app/views/beta_program/opt_in.pug @@ -18,11 +18,9 @@ block content | #{translate("beta_program_badge_description")} span.beta-feature-badge p.text-centered - | #{translate("beta_program_current_beta_features_description")} - ul.list-unstyled.text-center - li - i.fa.fa-fw.fa-book - |  #{translate("syntax_checking")} + strong We're currently testing track changes and commenting: + p.text-centered + img(src="/img/teasers/track-changes/track-changes-beta.png", style="max-width: 100%; border-bottom: 1px solid #ddd") .row.text-centered .col-md-12 if user.betaProgram diff --git a/services/web/app/views/project/editor/header.pug b/services/web/app/views/project/editor/header.pug index 85397fa83f..2817efa814 100644 --- a/services/web/app/views/project/editor/header.pug +++ b/services/web/app/views/project/editor/header.pug @@ -92,7 +92,9 @@ header.toolbar.toolbar-header.toolbar-with-labels( ng-click="toggleReviewPanel()" ) i.review-icon - p.toolbar-label Review + p.toolbar-label + | Review + span(style="vertical-align: 20%; margin-left: 4px; padding: 2px 4px;").beta-feature-badge a.btn.btn-full-height( href, ng-if="permissions.admin", diff --git a/services/web/app/views/project/editor/review-panel.pug b/services/web/app/views/project/editor/review-panel.pug index 227f76899f..7b1c96b5eb 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -332,6 +332,7 @@ script(type='text/ng-template', id='addCommentEntryTemplate') ng-keypress="handleCommentKeyPress($event);" placeholder="Add your comment here" focus-on="comment:new:open" + ng-blur="submitNewComment()" ) .rp-entry-actions button.rp-entry-button( diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee index ed15da2958..b75cb07dba 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/track-changes/TrackChangesManager.coffee @@ -20,8 +20,8 @@ define [ @rangesTracker = doc.ranges @connectToRangesTracker() - @$scope.$on "comment:add", (e, thread_id) => - @addCommentToSelection(thread_id) + @$scope.$on "comment:add", (e, thread_id, offset, length) => + @addCommentToSelection(thread_id, offset, length) @$scope.$on "comment:select_line", (e) => @selectLineIfNoSelection() @@ -45,7 +45,7 @@ define [ @recalculateReviewEntriesScreenPositions() changingSelection = false - onChangeSelection = (args...) => + onChangeSelection = () => # Deletes can send about 5 changeSelection events, so # just act on the last one. if !changingSelection @@ -53,7 +53,6 @@ define [ @$scope.$evalAsync () => changingSelection = false @updateFocus() - @recalculateReviewEntriesScreenPositions() onResize = () => @recalculateReviewEntriesScreenPositions() @@ -64,11 +63,13 @@ define [ bindToAce = () => @editor.on "changeSelection", onChangeSelection + @editor.on "change", onChangeSelection # Selection also moves with updates elsewhere in the document @editor.on "changeSession", onChangeSession @editor.renderer.on "resize", onResize unbindFromAce = () => @editor.off "changeSelection", onChangeSelection + @editor.off "change", onChangeSelection @editor.off "changeSession", onChangeSession @editor.renderer.off "resize", onResize @@ -174,10 +175,11 @@ define [ # @rangesTracker.applyOp op # Will apply via sharejs @$scope.sharejsDoc.submitOp op - addCommentToSelection: (thread_id) -> - range = @editor.getSelectionRange() - content = @editor.getSelectedText() - offset = @_aceRangeToShareJs(range.start) + addCommentToSelection: (thread_id, offset, length) -> + start = @_shareJsOffsetToAcePosition(offset) + end = @_shareJsOffsetToAcePosition(offset + length) + range = new Range(start.row, start.column, end.row, end.column) + content = @editor.session.getTextRange(range) @addComment(offset, content, thread_id) selectLineIfNoSelection: () -> diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 5cdf7c672c..88a3233934 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -280,6 +280,7 @@ define [ entries["add-comment"] = { type: "add-comment" offset: selection_offset_start + length: selection_offset_end - selection_offset_start } for id, entry of entries @@ -310,10 +311,15 @@ define [ $scope.$broadcast "review-panel:layout" $scope.submitNewComment = (content) -> + return if !content? or content == "" + doc_id = $scope.editor.open_doc_id + entries = getDocEntries(doc_id) + return if !entries["add-comment"]? + {offset, length} = entries["add-comment"] thread_id = RangesTracker.generateId() thread = getThread(thread_id) thread.submitting = true - $scope.$broadcast "comment:add", thread_id + $scope.$broadcast "comment:add", thread_id, offset, length $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") diff --git a/services/web/public/coffee/ide/review-panel/directives/addCommentEntry.coffee b/services/web/public/coffee/ide/review-panel/directives/addCommentEntry.coffee index 124794e7b8..c23c37b674 100644 --- a/services/web/public/coffee/ide/review-panel/directives/addCommentEntry.coffee +++ b/services/web/public/coffee/ide/review-panel/directives/addCommentEntry.coffee @@ -28,10 +28,9 @@ define [ if ev.keyCode == 13 and !ev.shiftKey and !ev.ctrlKey and !ev.metaKey ev.preventDefault() if scope.state.content.length > 0 - ev.target.blur() scope.submitNewComment() scope.submitNewComment = () -> scope.onSubmit { content: scope.state.content } scope.state.isAdding = false - scope.state.content = "" \ No newline at end of file + scope.state.content = "" diff --git a/services/web/public/img/teasers/track-changes/track-changes-beta.png b/services/web/public/img/teasers/track-changes/track-changes-beta.png new file mode 100644 index 0000000000..a9efead2cc Binary files /dev/null and b/services/web/public/img/teasers/track-changes/track-changes-beta.png differ