# HG changeset patch # User Milka Kuzminski # Date 2020-10-27 10:54:31 # Node ID 883fcc39541abf3b91f6b5b681ec7b98e6fe7ce2 # Parent 2f66e04cc39256c50e59493e9a8d3f3db2fdca59 drafts: draft finize boilerplate diff --git a/rhodecode/public/css/comments.less b/rhodecode/public/css/comments.less --- a/rhodecode/public/css/comments.less +++ b/rhodecode/public/css/comments.less @@ -554,6 +554,10 @@ form.comment-form { margin-right: 0; } + #save_general { + margin-left: -6px; + } + } diff --git a/rhodecode/public/js/rhodecode/routes.js b/rhodecode/public/js/rhodecode/routes.js --- a/rhodecode/public/js/rhodecode/routes.js +++ b/rhodecode/public/js/rhodecode/routes.js @@ -386,6 +386,7 @@ function registerRCRoutes() { pyroutes.register('my_account_auth_tokens_add', '/_admin/my_account/auth_tokens/new', []); pyroutes.register('my_account_external_identity', '/_admin/my_account/external-identity', []); pyroutes.register('my_account_external_identity_delete', '/_admin/my_account/external-identity/delete', []); + pyroutes.register('pullrequest_draft_comments_submit', '/%(repo_name)s/pull-request/%(pull_request_id)s/draft_comments_submit', ['repo_name', 'pull_request_id']); pyroutes.register('repo_artifacts_list', '/%(repo_name)s/artifacts', ['repo_name']); pyroutes.register('repo_artifacts_data', '/%(repo_name)s/artifacts_data', ['repo_name']); pyroutes.register('repo_artifacts_new', '/%(repo_name)s/artifacts/new', ['repo_name']); diff --git a/rhodecode/public/js/src/rhodecode/comments.js b/rhodecode/public/js/src/rhodecode/comments.js --- a/rhodecode/public/js/src/rhodecode/comments.js +++ b/rhodecode/public/js/src/rhodecode/comments.js @@ -735,8 +735,6 @@ var CommentsController = function() { }; ajaxPOST(url, postData, success, failure); - - } this.deleteComment = function(node) { @@ -757,7 +755,32 @@ var CommentsController = function() { }; this._finalizeDrafts = function(commentIds) { - window.finalizeDrafts(commentIds) + + // remove the drafts so we can lock them before submit. + $.each(commentIds, function(idx, val){ + $('#comment-{0}'.format(val)).remove(); + }) + + var params = { + 'pull_request_id': templateContext.pull_request_data.pull_request_id, + 'repo_name': templateContext.repo_name, + }; + var url = pyroutes.url('pullrequest_draft_comments_submit', params) + var postData = {'comments': commentIds, 'csrf_token': CSRF_TOKEN}; + + var submitSuccessCallback = function(json_data) { + self.attachInlineComment(json_data); + + if (window.refreshDraftComments !== undefined) { + // if we have this handler, run it, and refresh all comments boxes + refreshDraftComments() + } + + return false; + }; + + ajaxPOST(url, postData, submitSuccessCallback) + } this.finalizeDrafts = function(commentIds) { @@ -766,7 +789,7 @@ var CommentsController = function() { title: _ngettext('Submit {0} draft comment.', 'Submit {0} draft comments.', commentIds.length).format(commentIds.length), icon: 'warning', showCancelButton: true, - confirmButtonText: _gettext('Yes, finalize drafts'), + confirmButtonText: _gettext('Yes'), }).then(function(result) { if (result.value) { diff --git a/rhodecode/public/js/src/rhodecode/pullrequests.js b/rhodecode/public/js/src/rhodecode/pullrequests.js --- a/rhodecode/public/js/src/rhodecode/pullrequests.js +++ b/rhodecode/public/js/src/rhodecode/pullrequests.js @@ -1066,14 +1066,14 @@ window.ReviewerPresenceController = func this.handlePresence = function (data) { if (data.type == 'presence' && data.channel === self.channel) { this.storeUsers(data.users); - this.render() + this.render(); } }; this.handleChannelUpdate = function (data) { if (data.channel === this.channel) { this.storeUsers(data.state.users); - this.render() + this.render(); } }; @@ -1181,6 +1181,10 @@ window.refreshAllComments = function (ve refreshTODOs(version); }; +window.refreshDraftComments = function () { + alert('TODO: refresh Draft Comments needs implementation') +}; + window.sidebarComment = function (commentId) { var jsonData = $('#commentHovercard{0}'.format(commentId)).data('commentJsonB64'); if (!jsonData) { diff --git a/rhodecode/templates/changeset/changeset_file_comment.mako b/rhodecode/templates/changeset/changeset_file_comment.mako --- a/rhodecode/templates/changeset/changeset_file_comment.mako +++ b/rhodecode/templates/changeset/changeset_file_comment.mako @@ -51,14 +51,12 @@
DRAFT
+ % elif is_new: +
+ NEW +
% endif - % if is_new: -
- NEW -
- % endif -
## TODO COMMENT @@ -515,7 +513,7 @@ ## Disable the button for CE, the "real" validation is in the backend code anyway % else: - + % endif % endif diff --git a/rhodecode/templates/pullrequests/pullrequest_show.mako b/rhodecode/templates/pullrequests/pullrequest_show.mako --- a/rhodecode/templates/pullrequests/pullrequest_show.mako +++ b/rhodecode/templates/pullrequests/pullrequest_show.mako @@ -552,6 +552,35 @@ ## CONTENT