##// END OF EJS Templates
repositories: allow updating repository settings for users without store-in-root permissions...
repositories: allow updating repository settings for users without store-in-root permissions in case repository name didn't change. - when an user owns repository in root location, and isn't allow to create repositories in root before we failed to allow this user to update such repository settings due to this validation. We'll now check if name didn't change and in this case allow to update since this doesn't store any new data in root location.

File last commit:

r4408:1349565d default
r4415:fc1f6c1b default
Show More
comments.js
1263 lines | 44.7 KiB | application/javascript | JavascriptLexer
code: update copyrights to 2020
r4306 // # Copyright (C) 2010-2020 RhodeCode GmbH
project: added all source files and assets
r1 // #
// # This program is free software: you can redistribute it and/or modify
// # it under the terms of the GNU Affero General Public License, version 3
// # (only), as published by the Free Software Foundation.
// #
// # This program is distributed in the hope that it will be useful,
// # but WITHOUT ANY WARRANTY; without even the implied warranty of
// # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// # GNU General Public License for more details.
// #
// # You should have received a copy of the GNU Affero General Public License
// # along with this program. If not, see <http://www.gnu.org/licenses/>.
// #
// # This program is dual-licensed. If you wish to learn more about the
// # RhodeCode Enterprise Edition, including its added features, Support services,
// # and proprietary license terms, please see https://rhodecode.com/licenses/
var firefoxAnchorFix = function() {
// hack to make anchor links behave properly on firefox, in our inline
// comments generation when comments are injected firefox is misbehaving
// when jumping to anchor links
if (location.href.indexOf('#') > -1) {
location.href += '';
}
};
var linkifyComments = function(comments) {
js: cleanup linkifyComments function
r1329 var firstCommentId = null;
if (comments) {
firstCommentId = $(comments[0]).data('comment-id');
project: added all source files and assets
r1 }
js: cleanup linkifyComments function
r1329 if (firstCommentId){
$('#inline-comments-counter').attr('href', '#comment-' + firstCommentId);
}
project: added all source files and assets
r1 };
dan
diffs: add comments to changeset diffs
r1143
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 var bindToggleButtons = function() {
$('.comment-toggle').on('click', function() {
$(this).parent().nextUntil('tr.line').toggle('inline-comments');
});
};
project: added all source files and assets
r1
pull-requests: allow markup rendered description.
r2816
var _submitAjaxPOST = function(url, postData, successHandler, failHandler) {
failHandler = failHandler || function() {};
postData = toQueryString(postData);
var request = $.ajax({
url: url,
type: 'POST',
data: postData,
headers: {'X-PARTIAL-XHR': true}
})
.done(function (data) {
successHandler(data);
})
.fail(function (data, textStatus, errorThrown) {
failHandler(data, textStatus, errorThrown)
});
return request;
};
project: added all source files and assets
r1 /* Comment form for main and inline comments */
comments: fixed compare view comments.
r1331 (function(mod) {
comments: allow submitting id of comment which submitted comment resolved....
r1325
comments: fixed compare view comments.
r1331 if (typeof exports == "object" && typeof module == "object") {
// CommonJS
module.exports = mod();
}
else {
// Plain browser env
(this || window).CommentForm = mod();
}
comments: allow submitting id of comment which submitted comment resolved....
r1325
})(function() {
project: added all source files and assets
r1 "use strict";
comments: edit functionality added
r4401 function CommentForm(formElement, commitId, pullRequestId, lineNo, initAutocompleteActions, resolvesCommentId, edit, comment_id) {
comments: allow submitting id of comment which submitted comment resolved....
r1325 if (!(this instanceof CommentForm)) {
comments: edit functionality added
r4401 return new CommentForm(formElement, commitId, pullRequestId, lineNo, initAutocompleteActions, resolvesCommentId, edit, comment_id);
comments: allow submitting id of comment which submitted comment resolved....
r1325 }
// bind the element instance to our Form
$(formElement).get(0).CommentForm = this;
project: added all source files and assets
r1
this.withLineNo = function(selector) {
var lineNo = this.lineNo;
if (lineNo === undefined) {
return selector
} else {
return selector + '_' + lineNo;
}
};
this.commitId = commitId;
this.pullRequestId = pullRequestId;
this.lineNo = lineNo;
this.initAutocompleteActions = initAutocompleteActions;
this.previewButton = this.withLineNo('#preview-btn');
this.previewContainer = this.withLineNo('#preview-container');
this.previewBoxSelector = this.withLineNo('#preview-box');
this.editButton = this.withLineNo('#edit-btn');
this.editContainer = this.withLineNo('#edit-container');
comments: add comments type into comments.
r1324 this.cancelButton = this.withLineNo('#cancel-btn');
this.commentType = this.withLineNo('#comment_type');
project: added all source files and assets
r1
comments: allow submitting id of comment which submitted comment resolved....
r1325 this.resolvesId = null;
this.resolvesActionId = null;
pull-requests: add explicit CLOSE pr action instead of closed status from selector....
r1445 this.closesPr = '#close_pull_request';
comments: add comments type into comments.
r1324 this.cmBox = this.withLineNo('#text');
comments: register different slash commands for inline vs general comments.
r1362 this.cm = initCommentBoxCodeMirror(this, this.cmBox, this.initAutocompleteActions);
project: added all source files and assets
r1
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 this.statusChange = this.withLineNo('#change_status');
project: added all source files and assets
r1
this.submitForm = formElement;
this.submitButton = $(this.submitForm).find('input[type="submit"]');
this.submitButtonText = this.submitButton.val();
comments: edit functionality added
r4401
repo-commits: ported changeset code into pyramid views....
r1951 this.previewUrl = pyroutes.url('repo_commit_comment_preview',
{'repo_name': templateContext.repo_name,
'commit_id': templateContext.commit_data.commit_id});
project: added all source files and assets
r1
comments: edit functionality added
r4401 if (edit){
this.submitButtonText = _gettext('Updated Comment');
$(this.commentType).prop('disabled', true);
$(this.commentType).addClass('disabled');
var editInfo =
comment-history: UI fixes
r4404 '';
comments: edit functionality added
r4401 $(editInfo).insertBefore($(this.editButton).parent());
}
comments: allow submitting id of comment which submitted comment resolved....
r1325 if (resolvesCommentId){
this.resolvesId = '#resolve_comment_{0}'.format(resolvesCommentId);
this.resolvesActionId = '#resolve_comment_action_{0}'.format(resolvesCommentId);
$(this.commentType).prop('disabled', true);
$(this.commentType).addClass('disabled');
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 // disable select
setTimeout(function() {
$(self.statusChange).select2('readonly', true);
}, 10);
comments: allow submitting id of comment which submitted comment resolved....
r1325 var resolvedInfo = (
comments: show links to unresolved todos...
r1344 '<li class="resolve-action">' +
comments: allow submitting id of comment which submitted comment resolved....
r1325 '<input type="hidden" id="resolve_comment_{0}" name="resolve_comment_{0}" value="{0}">' +
'<button id="resolve_comment_action_{0}" class="resolve-text btn btn-sm" onclick="return Rhodecode.comments.submitResolution({0})">{1} #{0}</button>' +
'</li>'
).format(resolvesCommentId, _gettext('resolve comment'));
$(resolvedInfo).insertAfter($(this.commentType).parent());
}
// based on commitId, or pullRequestId decide where do we submit
project: added all source files and assets
r1 // out data
if (this.commitId){
comments: edit functionality added
r4401 var pyurl = 'repo_commit_comment_create';
if(edit){
pyurl = 'repo_commit_comment_edit';
}
this.submitUrl = pyroutes.url(pyurl,
project: added all source files and assets
r1 {'repo_name': templateContext.repo_name,
comments: edit functionality added
r4401 'commit_id': this.commitId,
'comment_id': comment_id});
repo-commits: ported changeset code into pyramid views....
r1951 this.selfUrl = pyroutes.url('repo_commit',
comments: allow submitting id of comment which submitted comment resolved....
r1325 {'repo_name': templateContext.repo_name,
repo-commits: ported changeset code into pyramid views....
r1951 'commit_id': this.commitId});
project: added all source files and assets
r1
} else if (this.pullRequestId) {
comments: edit functionality added
r4401 var pyurl = 'pullrequest_comment_create';
if(edit){
pyurl = 'pullrequest_comment_edit';
}
this.submitUrl = pyroutes.url(pyurl,
project: added all source files and assets
r1 {'repo_name': templateContext.repo_name,
comments: edit functionality added
r4401 'pull_request_id': this.pullRequestId,
'comment_id': comment_id});
comments: allow submitting id of comment which submitted comment resolved....
r1325 this.selfUrl = pyroutes.url('pullrequest_show',
{'repo_name': templateContext.repo_name,
'pull_request_id': this.pullRequestId});
project: added all source files and assets
r1
} else {
throw new Error(
'CommentForm requires pullRequestId, or commitId to be specified.')
}
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 // FUNCTIONS and helpers
var self = this;
this.isInline = function(){
return this.lineNo && this.lineNo != 'general';
};
project: added all source files and assets
r1 this.getCmInstance = function(){
return this.cm
};
comments: allow submitting id of comment which submitted comment resolved....
r1325 this.setPlaceholder = function(placeholder) {
var cm = this.getCmInstance();
if (cm){
cm.setOption('placeholder', placeholder);
}
};
project: added all source files and assets
r1 this.getCommentStatus = function() {
return $(this.submitForm).find(this.statusChange).val();
};
comments: add comments type into comments.
r1324 this.getCommentType = function() {
return $(this.submitForm).find(this.commentType).val();
};
comments: allow submitting id of comment which submitted comment resolved....
r1325
this.getResolvesId = function() {
return $(this.submitForm).find(this.resolvesId).val() || null;
};
pull-requests: add explicit CLOSE pr action instead of closed status from selector....
r1445
this.getClosePr = function() {
return $(this.submitForm).find(this.closesPr).val() || null;
};
comments: allow submitting id of comment which submitted comment resolved....
r1325 this.markCommentResolved = function(resolvedCommentId){
$('#comment-label-{0}'.format(resolvedCommentId)).find('.resolved').show();
$('#comment-label-{0}'.format(resolvedCommentId)).find('.resolve').hide();
};
project: added all source files and assets
r1 this.isAllowedToSubmit = function() {
return !$(this.submitButton).prop('disabled');
};
this.initStatusChangeSelector = function(){
var formatChangeStatus = function(state, escapeMarkup) {
var originalOption = state.element;
ui: changed status icons to <i> elements instead of div.
r3883 var tmpl = '<i class="icon-circle review-status-{0}"></i><span>{1}</span>'.format($(originalOption).data('status'), escapeMarkup(state.text));
return tmpl
project: added all source files and assets
r1 };
var formatResult = function(result, container, query, escapeMarkup) {
return formatChangeStatus(result, escapeMarkup);
};
var formatSelection = function(data, container, escapeMarkup) {
return formatChangeStatus(data, escapeMarkup);
};
$(this.submitForm).find(this.statusChange).select2({
i18n: replaced fragile extraction of JS translations from an _TM variable....
r325 placeholder: _gettext('Status Review'),
project: added all source files and assets
r1 formatResult: formatResult,
formatSelection: formatSelection,
containerCssClass: "drop-menu status_box_menu",
dropdownCssClass: "drop-menu-dropdown",
dropdownAutoWidth: true,
minimumResultsForSearch: -1
});
$(this.submitForm).find(this.statusChange).on('change', function() {
var status = self.getCommentStatus();
pull-requests: add explicit CLOSE pr action instead of closed status from selector....
r1445
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 if (status && !self.isInline()) {
project: added all source files and assets
r1 $(self.submitButton).prop('disabled', false);
}
comments: allow submitting id of comment which submitted comment resolved....
r1325
i18n: replaced fragile extraction of JS translations from an _TM variable....
r325 var placeholderText = _gettext('Comment text will be set automatically based on currently selected status ({0}) ...').format(status);
comments: allow submitting id of comment which submitted comment resolved....
r1325 self.setPlaceholder(placeholderText)
project: added all source files and assets
r1 })
};
// reset the comment form into it's original state
this.resetCommentFormState = function(content) {
content = content || '';
$(this.editContainer).show();
comments: improved comments form layout....
r1281 $(this.editButton).parent().addClass('active');
project: added all source files and assets
r1
$(this.previewContainer).hide();
comments: improved comments form layout....
r1281 $(this.previewButton).parent().removeClass('active');
project: added all source files and assets
r1
this.setActionButtonsDisabled(true);
self.cm.setValue(content);
self.cm.setOption("readOnly", false);
comments: do a better reset state.
r1327
if (this.resolvesId) {
// destroy the resolve action
$(this.resolvesId).parent().remove();
}
pull-requests: add explicit CLOSE pr action instead of closed status from selector....
r1445 // reset closingPR flag
$('.close-pr-input').remove();
comments: do a better reset state.
r1327
$(this.statusChange).select2('readonly', false);
project: added all source files and assets
r1 };
pull-request: introduced new merge-checks....
r1334 this.globalSubmitSuccessCallback = function(){
// default behaviour is to call GLOBAL hook, if it's registered.
if (window.commentFormGlobalSubmitSuccessCallback !== undefined){
comments: edit functionality added
r4401 commentFormGlobalSubmitSuccessCallback();
pull-request: introduced new merge-checks....
r1334 }
};
comments: fixed compare view comments.
r1331
project: added all source files and assets
r1 this.submitAjaxPOST = function(url, postData, successHandler, failHandler) {
pull-requests: allow markup rendered description.
r2816 return _submitAjaxPOST(url, postData, successHandler, failHandler);
project: added all source files and assets
r1 };
// overwrite a submitHandler, we need to do it for inline comments
this.setHandleFormSubmit = function(callback) {
this.handleFormSubmit = callback;
};
comments: fixed compare view comments.
r1331 // overwrite a submitSuccessHandler
this.setGlobalSubmitSuccessCallback = function(callback) {
this.globalSubmitSuccessCallback = callback;
};
project: added all source files and assets
r1 // default handler for for submit for main comments
this.handleFormSubmit = function() {
var text = self.cm.getValue();
var status = self.getCommentStatus();
comments: add comments type into comments.
r1324 var commentType = self.getCommentType();
comments: allow submitting id of comment which submitted comment resolved....
r1325 var resolvesCommentId = self.getResolvesId();
pull-requests: add explicit CLOSE pr action instead of closed status from selector....
r1445 var closePullRequest = self.getClosePr();
project: added all source files and assets
r1
if (text === "" && !status) {
return;
}
var excludeCancelBtn = false;
var submitEvent = true;
self.setActionButtonsDisabled(true, excludeCancelBtn, submitEvent);
self.cm.setOption("readOnly", true);
comments: enabled resolution for general comments, and finalized how general comment is build
r1326
project: added all source files and assets
r1 var postData = {
'text': text,
'changeset_status': status,
comments: add comments type into comments.
r1324 'comment_type': commentType,
project: added all source files and assets
r1 'csrf_token': CSRF_TOKEN
};
pull-requests: add explicit CLOSE pr action instead of closed status from selector....
r1445
if (resolvesCommentId) {
comments: allow submitting id of comment which submitted comment resolved....
r1325 postData['resolves_comment_id'] = resolvesCommentId;
}
comments: fixed compare view comments.
r1331
pull-requests: add explicit CLOSE pr action instead of closed status from selector....
r1445 if (closePullRequest) {
postData['close_pull_request'] = true;
}
project: added all source files and assets
r1 var submitSuccessCallback = function(o) {
pull-request: introduced new merge-checks....
r1334 // reload page if we change status for single commit.
if (status && self.commitId) {
project: added all source files and assets
r1 location.reload(true);
} else {
$('#injected_page_comments').append(o.rendered_text);
self.resetCommentFormState();
timeagoActivate();
hovercacrds: added new tooltips and hovercards to expose certain information for objects shown in UI
r4026 tooltipActivate();
comments: allow submitting id of comment which submitted comment resolved....
r1325
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 // mark visually which comment was resolved
comments: allow submitting id of comment which submitted comment resolved....
r1325 if (resolvesCommentId) {
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 self.markCommentResolved(resolvesCommentId);
comments: allow submitting id of comment which submitted comment resolved....
r1325 }
project: added all source files and assets
r1 }
comments: fixed compare view comments.
r1331
// run global callback on submit
self.globalSubmitSuccessCallback();
project: added all source files and assets
r1 };
comments: added better alerts for failed commenting operations.
r4311 var submitFailCallback = function(jqXHR, textStatus, errorThrown) {
var prefix = "Error while submitting comment.\n"
var message = formatErrorMessage(jqXHR, textStatus, errorThrown, prefix);
ajaxErrorSwal(message);
comments: allow submitting id of comment which submitted comment resolved....
r1325 self.resetCommentFormState(text);
project: added all source files and assets
r1 };
self.submitAjaxPOST(
self.submitUrl, postData, submitSuccessCallback, submitFailCallback);
};
this.previewSuccessCallback = function(o) {
$(self.previewBoxSelector).html(o);
$(self.previewBoxSelector).removeClass('unloaded');
comments: improved comments form layout....
r1281 // swap buttons, making preview active
$(self.previewButton).parent().addClass('active');
$(self.editButton).parent().removeClass('active');
project: added all source files and assets
r1
// unlock buttons
self.setActionButtonsDisabled(false);
};
this.setActionButtonsDisabled = function(state, excludeCancelBtn, submitEvent) {
excludeCancelBtn = excludeCancelBtn || false;
submitEvent = submitEvent || false;
$(this.editButton).prop('disabled', state);
$(this.previewButton).prop('disabled', state);
if (!excludeCancelBtn) {
$(this.cancelButton).prop('disabled', state);
}
var submitState = state;
comments: unlock submit if we use slash commands to set status.
r1444 if (!submitEvent && this.getCommentStatus() && !self.isInline()) {
project: added all source files and assets
r1 // if the value of commit review status is set, we allow
comments: unlock submit if we use slash commands to set status.
r1444 // submit button, but only on Main form, isInline means inline
project: added all source files and assets
r1 submitState = false
}
pull-requests: add explicit CLOSE pr action instead of closed status from selector....
r1445
project: added all source files and assets
r1 $(this.submitButton).prop('disabled', submitState);
if (submitEvent) {
i18n: replaced fragile extraction of JS translations from an _TM variable....
r325 $(this.submitButton).val(_gettext('Submitting...'));
project: added all source files and assets
r1 } else {
$(this.submitButton).val(this.submitButtonText);
}
};
// lock preview/edit/submit buttons on load, but exclude cancel button
var excludeCancelBtn = true;
this.setActionButtonsDisabled(true, excludeCancelBtn);
// anonymous users don't have access to initialized CM instance
if (this.cm !== undefined){
this.cm.on('change', function(cMirror) {
if (cMirror.getValue() === "") {
self.setActionButtonsDisabled(true, excludeCancelBtn)
} else {
self.setActionButtonsDisabled(false, excludeCancelBtn)
}
});
}
$(this.editButton).on('click', function(e) {
e.preventDefault();
comments: improved comments form layout....
r1281 $(self.previewButton).parent().removeClass('active');
project: added all source files and assets
r1 $(self.previewContainer).hide();
comments: improved comments form layout....
r1281
$(self.editButton).parent().addClass('active');
project: added all source files and assets
r1 $(self.editContainer).show();
});
$(this.previewButton).on('click', function(e) {
e.preventDefault();
var text = self.cm.getValue();
if (text === "") {
return;
}
var postData = {
'text': text,
comments: allow submitting id of comment which submitted comment resolved....
r1325 'renderer': templateContext.visual.default_renderer,
project: added all source files and assets
r1 'csrf_token': CSRF_TOKEN
};
// lock ALL buttons on preview
self.setActionButtonsDisabled(true);
$(self.previewBoxSelector).addClass('unloaded');
i18n: replaced fragile extraction of JS translations from an _TM variable....
r325 $(self.previewBoxSelector).html(_gettext('Loading ...'));
comments: improved comments form layout....
r1281
project: added all source files and assets
r1 $(self.editContainer).hide();
$(self.previewContainer).show();
// by default we reset state of comment preserving the text
comments: added better alerts for failed commenting operations.
r4311 var previewFailCallback = function(jqXHR, textStatus, errorThrown) {
var prefix = "Error while preview of comment.\n"
var message = formatErrorMessage(jqXHR, textStatus, errorThrown, prefix);
ajaxErrorSwal(message);
project: added all source files and assets
r1 self.resetCommentFormState(text)
};
self.submitAjaxPOST(
comments: improved comments form layout....
r1281 self.previewUrl, postData, self.previewSuccessCallback,
previewFailCallback);
project: added all source files and assets
r1
comments: improved comments form layout....
r1281 $(self.previewButton).parent().addClass('active');
$(self.editButton).parent().removeClass('active');
project: added all source files and assets
r1 });
$(this.submitForm).submit(function(e) {
e.preventDefault();
var allowedToSubmit = self.isAllowedToSubmit();
if (!allowedToSubmit){
return false;
}
self.handleFormSubmit();
});
}
return CommentForm;
comments: allow submitting id of comment which submitted comment resolved....
r1325 });
dan
ux: add hidden comments indicators plus style tweaks...
r1157
comment-history: fixes/ui changes...
r4408 /* selector for comment versions */
var initVersionSelector = function(selector, initialData) {
var formatResult = function(result, container, query, escapeMarkup) {
return renderTemplate('commentVersion', {
show_disabled: true,
version: result.comment_version,
user_name: result.comment_author_username,
gravatar_url: result.comment_author_gravatar,
size: 16,
timeago_component: result.comment_created_on,
})
};
$(selector).select2({
placeholder: "Edited",
containerCssClass: "drop-menu-comment-history",
dropdownCssClass: "drop-menu-dropdown",
dropdownAutoWidth: true,
minimumResultsForSearch: -1,
data: initialData,
formatResult: formatResult,
});
$(selector).on('select2-selecting', function (e) {
// hide the mast as we later do preventDefault()
$("#select2-drop-mask").click();
e.preventDefault();
e.choice.action();
});
$(selector).on("select2-open", function() {
timeagoActivate();
});
};
comments: allow submitting id of comment which submitted comment resolved....
r1325 /* comments controller */
var CommentsController = function() {
var mainComment = '#text';
dan
ux: add hidden comments indicators plus style tweaks...
r1157 var self = this;
comments: edit functionality added
r4401 this.cancelComment = function (node) {
dan
ux: add hidden comments indicators plus style tweaks...
r1157 var $node = $(node);
comments: edit functionality added
r4401 var edit = $(this).attr('edit');
if (edit) {
var $general_comments = null;
var $inline_comments = $node.closest('div.inline-comments');
if (!$inline_comments.length) {
$general_comments = $('#comments');
var $comment = $general_comments.parent().find('div.comment:hidden');
// show hidden general comment form
$('#cb-comment-general-form-placeholder').show();
} else {
var $comment = $inline_comments.find('div.comment:hidden');
}
$comment.show();
}
comments: allow submitting id of comment which submitted comment resolved....
r1325 $node.closest('.comment-inline-form').remove();
dan
ux: add hidden comments indicators plus style tweaks...
r1157 return false;
pull-requests: added version browsing for pull requests....
r1192 };
comment-history: fixes/ui changes...
r4408 this.showVersion = function (comment_id, comment_history_id) {
comments: edit functionality added
r4401
var historyViewUrl = pyroutes.url(
'repo_commit_comment_history_view',
{
'repo_name': templateContext.repo_name,
'commit_id': comment_id,
'comment_history_id': comment_history_id,
}
);
successRenderCommit = function (data) {
swal: changed to dedicated version without animation
r4402 SwalNoAnimation.fire({
comments: edit functionality added
r4401 html: data,
title: '',
});
};
failRenderCommit = function () {
swal: changed to dedicated version without animation
r4402 SwalNoAnimation.fire({
comment-history: UI fixes
r4404 html: 'Error while loading comment history',
comments: edit functionality added
r4401 title: '',
});
};
_submitAjaxPOST(
comment-history: fixes/ui changes...
r4408 historyViewUrl, {'csrf_token': CSRF_TOKEN},
successRenderCommit,
comments: edit functionality added
r4401 failRenderCommit
);
};
dan
ux: add hidden comments indicators plus style tweaks...
r1157 this.getLineNumber = function(node) {
var $node = $(node);
diffs/files: fix and improve line selections and anchor links.
r2642 var lineNo = $node.closest('td').attr('data-line-no');
comments: allow to properly initialize outdated comments that are attached...
r2250 if (lineNo === undefined && $node.data('commentInline')){
lineNo = $node.data('commentLineNo')
}
return lineNo
pull-requests: added version browsing for pull requests....
r1192 };
pull-requests: updated versioning support....
r1268 this.scrollToComment = function(node, offset, outdated) {
comments: fixed scroll issue.
r1386 if (offset === undefined) {
offset = 0;
}
pull-requests: updated versioning support....
r1268 var outdated = outdated || false;
var klass = outdated ? 'div.comment-outdated' : 'div.comment-current';
dan
ux: add hidden comments indicators plus style tweaks...
r1157 if (!node) {
node = $('.comment-selected');
if (!node.length) {
node = $('comment-current')
}
}
pull-requests: expose TODO box in dedicated panel...
r4140
comments: show links to unresolved todos...
r1344 $wrapper = $(node).closest('div.comment');
dan
ux: add hidden comments indicators plus style tweaks...
r1157
comments: show links to unresolved todos...
r1344 // show hidden comment when referenced.
if (!$wrapper.is(':visible')){
$wrapper.show();
}
pull-requests: expose TODO box in dedicated panel...
r4140 $comment = $(node).closest(klass);
$comments = $(klass);
dan
ux: add hidden comments indicators plus style tweaks...
r1157 $('.comment-selected').removeClass('comment-selected');
pull-requests: updated versioning support....
r1268 var nextIdx = $(klass).index($comment) + offset;
dan
ux: add hidden comments indicators plus style tweaks...
r1157 if (nextIdx >= $comments.length) {
nextIdx = 0;
}
pull-requests: updated versioning support....
r1268 var $next = $(klass).eq(nextIdx);
commit-page: show unresolved TODOs on commit page below comments.
r1385
dan
ux: add hidden comments indicators plus style tweaks...
r1157 var $cb = $next.closest('.cb');
pull-requests: added version browsing for pull requests....
r1192 $cb.removeClass('cb-collapsed');
dan
ux: add hidden comments indicators plus style tweaks...
r1157
var $filediffCollapseState = $cb.closest('.filediff').prev();
$filediffCollapseState.prop('checked', false);
$next.addClass('comment-selected');
scrollToElement($next);
return false;
pull-requests: added version browsing for pull requests....
r1192 };
dan
ux: add hidden comments indicators plus style tweaks...
r1157 this.nextComment = function(node) {
return self.scrollToComment(node, 1);
pull-requests: added version browsing for pull requests....
r1192 };
dan
ux: add hidden comments indicators plus style tweaks...
r1157 this.prevComment = function(node) {
return self.scrollToComment(node, -1);
pull-requests: added version browsing for pull requests....
r1192 };
pull-requests: updated versioning support....
r1268 this.nextOutdatedComment = function(node) {
return self.scrollToComment(node, 1, true);
};
this.prevOutdatedComment = function(node) {
return self.scrollToComment(node, -1, true);
};
comments: use better sweet alert confirm dialog.
r4312 this._deleteComment = function(node) {
dan
ux: add hidden comments indicators plus style tweaks...
r1157 var $node = $(node);
var $td = $node.closest('td');
var $comment = $node.closest('.comment');
var comment_id = $comment.attr('data-comment-id');
var url = AJAX_COMMENT_DELETE_URL.replace('__COMMENT_ID__', comment_id);
var postData = {
'csrf_token': CSRF_TOKEN
};
$comment.addClass('comment-deleting');
$comment.hide('fast');
var success = function(response) {
$comment.remove();
return false;
};
comments: added better alerts for failed commenting operations.
r4311 var failure = function(jqXHR, textStatus, errorThrown) {
var prefix = "Error while deleting this comment.\n"
var message = formatErrorMessage(jqXHR, textStatus, errorThrown, prefix);
ajaxErrorSwal(message);
dan
ux: add hidden comments indicators plus style tweaks...
r1157 $comment.show('fast');
$comment.removeClass('comment-deleting');
return false;
};
ajaxPOST(url, postData, success, failure);
comments: use better sweet alert confirm dialog.
r4312 }
this.deleteComment = function(node) {
var $comment = $(node).closest('.comment');
var comment_id = $comment.attr('data-comment-id');
quick-switcher: handle errors using Swal, and create a new helper to make calls the same across whole app.
r4339 SwalNoAnimation.fire({
comments: use better sweet alert confirm dialog.
r4312 title: 'Delete this comment?',
icon: 'warning',
showCancelButton: true,
templates: switched most of confirm dialogs to sweetalert2
r4313 confirmButtonText: _gettext('Yes, delete comment #{0}!').format(comment_id),
quick-switcher: handle errors using Swal, and create a new helper to make calls the same across whole app.
r4339
comments: use better sweet alert confirm dialog.
r4312 }).then(function(result) {
if (result.value) {
self._deleteComment(node);
}
})
pull-requests: added version browsing for pull requests....
r1192 };
diffs: added wide-mode button to expand large diffs.
r1193 this.toggleWideMode = function (node) {
if ($('#content').hasClass('wrapper')) {
$('#content').removeClass("wrapper");
$('#content').addClass("wide-mode-wrapper");
$(node).addClass('btn-success');
diffs: store wide-diff mode in user sessions for saved state.
r3642 return true
diffs: added wide-mode button to expand large diffs.
r1193 } else {
$('#content').removeClass("wide-mode-wrapper");
$('#content').addClass("wrapper");
$(node).removeClass('btn-success');
diffs: store wide-diff mode in user sessions for saved state.
r3642 return false
diffs: added wide-mode button to expand large diffs.
r1193 }
diffs: store wide-diff mode in user sessions for saved state.
r3642
diffs: added wide-mode button to expand large diffs.
r1193 };
dan
ux: add hidden comments indicators plus style tweaks...
r1157 this.toggleComments = function(node, show) {
var $filediff = $(node).closest('.filediff');
if (show === true) {
$filediff.removeClass('hide-comments');
} else if (show === false) {
$filediff.find('.hide-line-comments').removeClass('hide-line-comments');
$filediff.addClass('hide-comments');
} else {
$filediff.find('.hide-line-comments').removeClass('hide-line-comments');
$filediff.toggleClass('hide-comments');
}
return false;
pull-requests: added version browsing for pull requests....
r1192 };
dan
ux: add hidden comments indicators plus style tweaks...
r1157 this.toggleLineComments = function(node) {
self.toggleComments(node, true);
var $node = $(node);
comments: toggle icon will now mark hidden inline comments as visible for easier switching of outdated comments.
r2612 // mark outdated comments as visible before the toggle;
$(node.closest('tr')).find('.comment-outdated').show();
dan
ux: add hidden comments indicators plus style tweaks...
r1157 $node.closest('tr').toggleClass('hide-line-comments');
pull-requests: added version browsing for pull requests....
r1192 };
comments: edit functionality added
r4401 this.createCommentForm = function(formElement, lineno, placeholderText, initAutocompleteActions, resolvesCommentId, edit, comment_id){
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 var pullRequestId = templateContext.pull_request_data.pull_request_id;
var commitId = templateContext.commit_data.commit_id;
var commentForm = new CommentForm(
comments: edit functionality added
r4401 formElement, commitId, pullRequestId, lineno, initAutocompleteActions, resolvesCommentId, edit, comment_id);
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 var cm = commentForm.getCmInstance();
if (resolvesCommentId){
pull-requests: expose TODO box in dedicated panel...
r4140 var placeholderText = _gettext('Leave a resolution comment, or click resolve button to resolve TODO comment #{0}').format(resolvesCommentId);
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 }
setTimeout(function() {
// callbacks
if (cm !== undefined) {
commentForm.setPlaceholder(placeholderText);
if (commentForm.isInline()) {
cm.focus();
cm.refresh();
}
}
}, 10);
// trigger scrolldown to the resolve comment, since it might be away
// from the clicked
if (resolvesCommentId){
var actionNode = $(commentForm.resolvesActionId).offset();
setTimeout(function() {
if (actionNode) {
$('body, html').animate({scrollTop: actionNode.top}, 10);
}
}, 100);
}
comments: added support for adding comment attachments using the artifacts logic....
r3973 // add dropzone support
var insertAttachmentText = function (cm, attachmentName, attachmentStoreUrl, isRendered) {
var renderer = templateContext.visual.default_renderer;
if (renderer == 'rst') {
var attachmentUrl = '`#{0} <{1}>`_'.format(attachmentName, attachmentStoreUrl);
if (isRendered){
attachmentUrl = '\n.. image:: {0}'.format(attachmentStoreUrl);
}
} else if (renderer == 'markdown') {
var attachmentUrl = '[{0}]({1})'.format(attachmentName, attachmentStoreUrl);
if (isRendered){
attachmentUrl = '!' + attachmentUrl;
}
} else {
var attachmentUrl = '{}'.format(attachmentStoreUrl);
}
cm.replaceRange(attachmentUrl+'\n', CodeMirror.Pos(cm.lastLine()));
return false;
};
//see: https://www.dropzonejs.com/#configuration
var storeUrl = pyroutes.url('repo_commit_comment_attachment_upload',
{'repo_name': templateContext.repo_name,
'commit_id': templateContext.commit_data.commit_id})
comments: fix JS for attachments for anonymous users.
r3989 var previewTmpl = $(formElement).find('.comment-attachment-uploader-template').get(0);
if (previewTmpl !== undefined){
var selectLink = $(formElement).find('.pick-attachment').get(0);
$(formElement).find('.comment-attachment-uploader').dropzone({
url: storeUrl,
headers: {"X-CSRF-Token": CSRF_TOKEN},
paramName: function () {
return "attachment"
}, // The name that will be used to transfer the file
clickable: selectLink,
parallelUploads: 1,
maxFiles: 10,
maxFilesize: templateContext.attachment_store.max_file_size_mb,
uploadMultiple: false,
autoProcessQueue: true, // if false queue will not be processed automatically.
createImageThumbnails: false,
previewTemplate: previewTmpl.innerHTML,
comments: added support for adding comment attachments using the artifacts logic....
r3973
comments: fix JS for attachments for anonymous users.
r3989 accept: function (file, done) {
done();
},
init: function () {
comments: added support for adding comment attachments using the artifacts logic....
r3973
comments: fix JS for attachments for anonymous users.
r3989 this.on("sending", function (file, xhr, formData) {
$(formElement).find('.comment-attachment-uploader').find('.dropzone-text').hide();
$(formElement).find('.comment-attachment-uploader').find('.dropzone-upload').show();
});
comments: added support for adding comment attachments using the artifacts logic....
r3973
comments: fix JS for attachments for anonymous users.
r3989 this.on("success", function (file, response) {
$(formElement).find('.comment-attachment-uploader').find('.dropzone-text').show();
$(formElement).find('.comment-attachment-uploader').find('.dropzone-upload').hide();
comments: added support for adding comment attachments using the artifacts logic....
r3973
comments: fix JS for attachments for anonymous users.
r3989 var isRendered = false;
var ext = file.name.split('.').pop();
var imageExts = templateContext.attachment_store.image_ext;
if (imageExts.indexOf(ext) !== -1){
isRendered = true;
}
comments: added support for adding comment attachments using the artifacts logic....
r3973
comments: fix JS for attachments for anonymous users.
r3989 insertAttachmentText(cm, file.name, response.repo_fqn_access_path, isRendered)
});
comments: added support for adding comment attachments using the artifacts logic....
r3973
comments: fix JS for attachments for anonymous users.
r3989 this.on("error", function (file, errorMessage, xhr) {
$(formElement).find('.comment-attachment-uploader').find('.dropzone-upload').hide();
comments: added support for adding comment attachments using the artifacts logic....
r3973
comments: fix JS for attachments for anonymous users.
r3989 var error = null;
comments: added support for adding comment attachments using the artifacts logic....
r3973
comments: fix JS for attachments for anonymous users.
r3989 if (xhr !== undefined){
var httpStatus = xhr.status + " " + xhr.statusText;
uploads: handle server errors nicer
r3994 if (xhr !== undefined && xhr.status >= 500) {
comments: fix JS for attachments for anonymous users.
r3989 error = httpStatus;
}
comments: added support for adding comment attachments using the artifacts logic....
r3973 }
comments: fix JS for attachments for anonymous users.
r3989 if (error === null) {
error = errorMessage.error || errorMessage || httpStatus;
}
$(file.previewElement).find('.dz-error-message').html('ERROR: {0}'.format(error));
comments: added support for adding comment attachments using the artifacts logic....
r3973
comments: fix JS for attachments for anonymous users.
r3989 });
}
});
}
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 return commentForm;
};
comments: fixed compare view comments.
r1331 this.createGeneralComment = function (lineNo, placeholderText, resolvesCommentId) {
comments: enabled resolution for general comments, and finalized how general comment is build
r1326
var tmpl = $('#cb-comment-general-form-template').html();
tmpl = tmpl.format(null, 'general');
var $form = $(tmpl);
comments: fixed compare view comments.
r1331 var $formPlaceholder = $('#cb-comment-general-form-placeholder');
var curForm = $formPlaceholder.find('form');
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 if (curForm){
curForm.remove();
}
comments: fixed compare view comments.
r1331 $formPlaceholder.append($form);
comments: enabled resolution for general comments, and finalized how general comment is build
r1326
var _form = $($form[0]);
comments: register different slash commands for inline vs general comments.
r1362 var autocompleteActions = ['approve', 'reject', 'as_note', 'as_todo'];
comments: edit functionality added
r4401 var edit = false;
var comment_id = null;
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 var commentForm = this.createCommentForm(
comments: edit functionality added
r4401 _form, lineNo, placeholderText, autocompleteActions, resolvesCommentId, edit, comment_id);
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 commentForm.initStatusChangeSelector();
comments: fixed compare view comments.
r1331
return commentForm;
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 };
comment-history: fixes/ui changes...
r4408
comments: edit functionality added
r4401 this.editComment = function(node) {
var $node = $(node);
var $comment = $(node).closest('.comment');
var comment_id = $comment.attr('data-comment-id');
var $form = null
comments: enabled resolution for general comments, and finalized how general comment is build
r1326
comments: edit functionality added
r4401 var $comments = $node.closest('div.inline-comments');
var $general_comments = null;
var lineno = null;
if($comments.length){
// inline comments setup
$form = $comments.find('.comment-inline-form');
lineno = self.getLineNumber(node)
}
else{
// general comments setup
$comments = $('#comments');
$form = $comments.find('.comment-inline-form');
lineno = $comment[0].id
$('#cb-comment-general-form-placeholder').hide();
}
this.edit = true;
if (!$form.length) {
var $filediff = $node.closest('.filediff');
$filediff.removeClass('hide-comments');
var f_path = $filediff.attr('data-f-path');
// create a new HTML from template
var tmpl = $('#cb-comment-inline-form-template').html();
tmpl = tmpl.format(escapeHtml(f_path), lineno);
$form = $(tmpl);
$comment.after($form)
var _form = $($form[0]).find('form');
var autocompleteActions = ['as_note',];
var commentForm = this.createCommentForm(
_form, lineno, '', autocompleteActions, resolvesCommentId,
this.edit, comment_id);
var old_comment_text_binary = $comment.attr('data-comment-text');
var old_comment_text = b64DecodeUnicode(old_comment_text_binary);
commentForm.cm.setValue(old_comment_text);
$comment.hide();
$.Topic('/ui/plugins/code/comment_form_built').prepareOrPublish({
form: _form,
parent: $comments,
lineno: lineno,
f_path: f_path}
);
comment-history: fixes/ui changes...
r4408
comments: edit functionality added
r4401 // set a CUSTOM submit handler for inline comments.
commentForm.setHandleFormSubmit(function(o) {
var text = commentForm.cm.getValue();
var commentType = commentForm.getCommentType();
if (text === "") {
return;
}
comment-history: fixes/ui changes...
r4408
comments: edit functionality added
r4401 if (old_comment_text == text) {
swal: changed to dedicated version without animation
r4402 SwalNoAnimation.fire({
comments: updated edit message when body is still the same.
r4403 title: 'Unable to edit comment',
html: _gettext('Comment body was not changed.'),
comments: edit functionality added
r4401 });
return;
}
var excludeCancelBtn = false;
var submitEvent = true;
commentForm.setActionButtonsDisabled(true, excludeCancelBtn, submitEvent);
commentForm.cm.setOption("readOnly", true);
comment-history: fixes/ui changes...
r4408
// Read last version known
var versionSelector = $('#comment_versions_{0}'.format(comment_id));
var version = versionSelector.data('lastVersion');
comments: edit functionality added
r4401
comment-history: fixes/ui changes...
r4408 if (!version) {
version = 0;
comments: edit functionality added
r4401 }
comment-history: fixes/ui changes...
r4408
comments: edit functionality added
r4401 var postData = {
'text': text,
'f_path': f_path,
'line': lineno,
'comment_type': commentType,
'version': version,
comment-history: fixes/ui changes...
r4408 'csrf_token': CSRF_TOKEN
comments: edit functionality added
r4401 };
var submitSuccessCallback = function(json_data) {
$form.remove();
$comment.show();
var postData = {
'text': text,
'renderer': $comment.attr('data-comment-renderer'),
'csrf_token': CSRF_TOKEN
};
comment-history: fixes/ui changes...
r4408 /* Inject new edited version selector */
comments: edit functionality added
r4401 var updateCommentVersionDropDown = function () {
comment-history: fixes/ui changes...
r4408 var versionSelectId = '#comment_versions_'+comment_id;
var preLoadVersionData = [
{
id: json_data['comment_version'],
text: "v{0}".format(json_data['comment_version']),
action: function () {
Rhodecode.comments.showVersion(
json_data['comment_id'],
json_data['comment_history_id']
)
},
comment_version: json_data['comment_version'],
comment_author_username: json_data['comment_author_username'],
comment_author_gravatar: json_data['comment_author_gravatar'],
comment_created_on: json_data['comment_created_on'],
},
]
if ($(versionSelectId).data('select2')) {
var oldData = $(versionSelectId).data('select2').opts.data.results;
$(versionSelectId).select2("destroy");
preLoadVersionData = oldData.concat(preLoadVersionData)
}
initVersionSelector(versionSelectId, {results: preLoadVersionData});
comments: edit functionality added
r4401 $comment.attr('data-comment-text', btoa(text));
comment-history: fixes/ui changes...
r4408
var versionSelector = $('#comment_versions_'+comment_id);
// set lastVersion so we know our last edit version
versionSelector.data('lastVersion', json_data['comment_version'])
versionSelector.parent().show();
comments: edit functionality added
r4401 }
updateCommentVersionDropDown();
comment-history: fixes/ui changes...
r4408
comments: edit functionality added
r4401 // by default we reset state of comment preserving the text
var failRenderCommit = function(jqXHR, textStatus, errorThrown) {
comment-history: fixes/ui changes...
r4408 var prefix = "Error while editing this comment.\n"
comments: edit functionality added
r4401 var message = formatErrorMessage(jqXHR, textStatus, errorThrown, prefix);
ajaxErrorSwal(message);
comment-history: fixes/ui changes...
r4408 };
comments: edit functionality added
r4401
var successRenderCommit = function(o){
$comment.show();
$comment[0].lastElementChild.innerHTML = o;
comment-history: fixes/ui changes...
r4408 };
var previewUrl = pyroutes.url(
'repo_commit_comment_preview',
{'repo_name': templateContext.repo_name,
'commit_id': templateContext.commit_data.commit_id});
comments: edit functionality added
r4401
_submitAjaxPOST(
previewUrl, postData, successRenderCommit,
failRenderCommit
);
try {
var html = json_data.rendered_text;
var lineno = json_data.line_no;
var target_id = json_data.target_id;
$comments.find('.cb-comment-add-button').before(html);
// run global callback on submit
commentForm.globalSubmitSuccessCallback();
} catch (e) {
console.error(e);
}
// re trigger the linkification of next/prev navigation
linkifyComments($('.inline-comment-injected'));
timeagoActivate();
tooltipActivate();
if (window.updateSticky !== undefined) {
// potentially our comments change the active window size, so we
// notify sticky elements
updateSticky()
}
commentForm.setActionButtonsDisabled(false);
};
var submitFailCallback = function(jqXHR, textStatus, errorThrown) {
var prefix = "Error while editing comment.\n"
var message = formatErrorMessage(jqXHR, textStatus, errorThrown, prefix);
comment-history: fixes/ui changes...
r4408 if (jqXHR.status == 409){
message = 'This comment was probably changed somewhere else. Please reload the content of this comment.'
ajaxErrorSwal(message, 'Comment version mismatch.');
} else {
ajaxErrorSwal(message);
}
comments: edit functionality added
r4401 commentForm.resetCommentFormState(text)
};
commentForm.submitAjaxPOST(
comment-history: fixes/ui changes...
r4408 commentForm.submitUrl, postData,
submitSuccessCallback,
submitFailCallback);
comments: edit functionality added
r4401 });
}
$form.addClass('comment-inline-form-open');
};
comment-history: fixes/ui changes...
r4408
comments: allow submitting id of comment which submitted comment resolved....
r1325 this.createComment = function(node, resolutionComment) {
var resolvesCommentId = resolutionComment || null;
dan
ux: add hidden comments indicators plus style tweaks...
r1157 var $node = $(node);
var $td = $node.closest('td');
var $form = $td.find('.comment-inline-form');
comments: edit functionality added
r4401 this.edit = false;
dan
ux: add hidden comments indicators plus style tweaks...
r1157
if (!$form.length) {
comments: enabled resolution for general comments, and finalized how general comment is build
r1326
dan
ux: add hidden comments indicators plus style tweaks...
r1157 var $filediff = $node.closest('.filediff');
$filediff.removeClass('hide-comments');
var f_path = $filediff.attr('data-f-path');
var lineno = self.getLineNumber(node);
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 // create a new HTML from template
var tmpl = $('#cb-comment-inline-form-template').html();
comments: escape file-paths on commenting to prevent html breakage
r2182 tmpl = tmpl.format(escapeHtml(f_path), lineno);
dan
ux: add hidden comments indicators plus style tweaks...
r1157 $form = $(tmpl);
var $comments = $td.find('.inline-comments');
if (!$comments.length) {
$comments = $(
$('#cb-comments-inline-container-template').html());
$td.append($comments);
}
$td.find('.cb-comment-add-button').before($form);
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 var placeholderText = _gettext('Leave a comment on line {0}.').format(lineno);
comments: allow submitting id of comment which submitted comment resolved....
r1325 var _form = $($form[0]).find('form');
comments: register different slash commands for inline vs general comments.
r1362 var autocompleteActions = ['as_note', 'as_todo'];
comments: edit functionality added
r4401 var comment_id=null;
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 var commentForm = this.createCommentForm(
comments: edit functionality added
r4401 _form, lineno, placeholderText, autocompleteActions, resolvesCommentId, this.edit, comment_id);
comments: enabled resolution for general comments, and finalized how general comment is build
r1326
$.Topic('/ui/plugins/code/comment_form_built').prepareOrPublish({
form: _form,
parent: $td[0],
lineno: lineno,
f_path: f_path}
);
dan
ux: add hidden comments indicators plus style tweaks...
r1157
// set a CUSTOM submit handler for inline comments.
commentForm.setHandleFormSubmit(function(o) {
var text = commentForm.cm.getValue();
comments: add comments type into comments.
r1324 var commentType = commentForm.getCommentType();
comments: allow submitting id of comment which submitted comment resolved....
r1325 var resolvesCommentId = commentForm.getResolvesId();
dan
ux: add hidden comments indicators plus style tweaks...
r1157
if (text === "") {
return;
}
if (lineno === undefined) {
alert('missing line !');
return;
}
if (f_path === undefined) {
alert('missing file path !');
return;
}
var excludeCancelBtn = false;
var submitEvent = true;
commentForm.setActionButtonsDisabled(true, excludeCancelBtn, submitEvent);
commentForm.cm.setOption("readOnly", true);
var postData = {
'text': text,
'f_path': f_path,
'line': lineno,
comments: add comments type into comments.
r1324 'comment_type': commentType,
dan
ux: add hidden comments indicators plus style tweaks...
r1157 'csrf_token': CSRF_TOKEN
};
comments: allow submitting id of comment which submitted comment resolved....
r1325 if (resolvesCommentId){
postData['resolves_comment_id'] = resolvesCommentId;
}
dan
ux: add hidden comments indicators plus style tweaks...
r1157 var submitSuccessCallback = function(json_data) {
$form.remove();
try {
var html = json_data.rendered_text;
var lineno = json_data.line_no;
var target_id = json_data.target_id;
$comments.find('.cb-comment-add-button').before(html);
comments: allow submitting id of comment which submitted comment resolved....
r1325 //mark visually which comment was resolved
if (resolvesCommentId) {
commentForm.markCommentResolved(resolvesCommentId);
}
comments: fixed compare view comments.
r1331 // run global callback on submit
commentForm.globalSubmitSuccessCallback();
dan
ux: add hidden comments indicators plus style tweaks...
r1157 } catch (e) {
console.error(e);
}
// re trigger the linkification of next/prev navigation
linkifyComments($('.inline-comment-injected'));
timeagoActivate();
hovercacrds: added new tooltips and hovercards to expose certain information for objects shown in UI
r4026 tooltipActivate();
diffs: sticky top-file bar + context aware file labels....
r3126
dan
diffs: update all sticky elements on dom changes to handle cases like:...
r3129 if (window.updateSticky !== undefined) {
diffs: sticky top-file bar + context aware file labels....
r3126 // potentially our comments change the active window size, so we
dan
diffs: update all sticky elements on dom changes to handle cases like:...
r3129 // notify sticky elements
updateSticky()
diffs: sticky top-file bar + context aware file labels....
r3126 }
dan
ux: add hidden comments indicators plus style tweaks...
r1157 commentForm.setActionButtonsDisabled(false);
};
comments: added better alerts for failed commenting operations.
r4311 var submitFailCallback = function(jqXHR, textStatus, errorThrown) {
var prefix = "Error while submitting comment.\n"
var message = formatErrorMessage(jqXHR, textStatus, errorThrown, prefix);
ajaxErrorSwal(message);
dan
ux: add hidden comments indicators plus style tweaks...
r1157 commentForm.resetCommentFormState(text)
};
commentForm.submitAjaxPOST(
commentForm.submitUrl, postData, submitSuccessCallback, submitFailCallback);
});
}
$form.addClass('comment-inline-form-open');
pull-requests: added version browsing for pull requests....
r1192 };
dan
ux: add hidden comments indicators plus style tweaks...
r1157
comments: allow submitting id of comment which submitted comment resolved....
r1325 this.createResolutionComment = function(commentId){
// hide the trigger text
$('#resolve-comment-{0}'.format(commentId)).hide();
var comment = $('#comment-'+commentId);
var commentData = comment.data();
if (commentData.commentInline) {
this.createComment(comment, commentId)
} else {
comments: enabled resolution for general comments, and finalized how general comment is build
r1326 Rhodecode.comments.createGeneralComment('general', "$placeholder", commentId)
comments: allow submitting id of comment which submitted comment resolved....
r1325 }
return false;
};
this.submitResolution = function(commentId){
var form = $('#resolve_comment_{0}'.format(commentId)).closest('form');
var commentForm = form.get(0).CommentForm;
var cm = commentForm.getCmInstance();
var renderer = templateContext.visual.default_renderer;
if (renderer == 'rst'){
var commentUrl = '`#{0} <{1}#comment-{0}>`_'.format(commentId, commentForm.selfUrl);
} else if (renderer == 'markdown') {
var commentUrl = '[#{0}]({1}#comment-{0})'.format(commentId, commentForm.selfUrl);
} else {
var commentUrl = '{1}#comment-{0}'.format(commentId, commentForm.selfUrl);
}
cm.setValue(_gettext('TODO from comment {0} was fixed.').format(commentUrl));
form.submit();
return false;
};
diffs: fixed other file source when using pull requests. It must use...
r1194 };